0 已登录用户 * =0 未登录 * <0 访客 * @var int */ public int $userId; /** * 用户类型 * @var UserTypeEnum * USER 标准用户 * VISITOR 未登录访客 */ public UserTypeEnum $userType; public function __construct($userId, $userType) { $this->userId = $userId; $this->userType = $userType; } public function isLogin(): bool { return $this->userId > 0; } }