Skip to content

Commit fb85314

Browse files
committed
refactor: vendor/bin/rector
1 parent c9bd934 commit fb85314

File tree

11 files changed

+17
-17
lines changed

11 files changed

+17
-17
lines changed

src/Authentication/Actions/Email2FA.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function handle(IncomingRequest $request)
7878

7979
$identity = $this->getIdentity($user);
8080

81-
if (empty($identity)) {
81+
if (! $identity instanceof UserIdentity) {
8282
return redirect()->route('auth-action-show')->with('error', lang('Auth.need2FA'));
8383
}
8484

src/Authentication/Authenticators/AccessTokens.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function check(array $credentials): Result
193193
*/
194194
public function loggedIn(): bool
195195
{
196-
if (! empty($this->user)) {
196+
if ($this->user instanceof User) {
197197
return true;
198198
}
199199

@@ -226,7 +226,7 @@ public function loginById($userId): void
226226
{
227227
$user = $this->provider->findById($userId);
228228

229-
if (empty($user)) {
229+
if (! $user instanceof User) {
230230
throw AuthenticationException::forInvalidUser();
231231
}
232232

src/Authentication/Authenticators/Session.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function checkAction(UserIdentity $identity, string $token): bool
241241
throw new LogicException('Cannot get the User.');
242242
}
243243

244-
if (empty($token) || $token !== $identity->secret) {
244+
if ($token === '' || $token === '0' || $token !== $identity->secret) {
245245
return false;
246246
}
247247

@@ -485,7 +485,7 @@ private function setAuthAction(): bool
485485

486486
$identity = $this->userIdentityModel->getIdentityByType($this->user, $action->getType());
487487

488-
if ($identity) {
488+
if ($identity instanceof UserIdentity) {
489489
$this->userState = self::STATE_PENDING;
490490

491491
$this->setSessionKey('auth_action', $actionClass);
@@ -767,7 +767,7 @@ private function issueRememberMeToken(): void
767767

768768
// Reset so it doesn't mess up future calls.
769769
$this->shouldRemember = false;
770-
} elseif ($this->getRememberMeToken()) {
770+
} elseif ($this->getRememberMeToken() !== null && $this->getRememberMeToken() !== '' && $this->getRememberMeToken() !== '0') {
771771
$this->removeRememberCookie();
772772

773773
// @TODO delete the token record.
@@ -804,7 +804,7 @@ public function loginById($userId): void
804804
{
805805
$user = $this->provider->findById($userId);
806806

807-
if (empty($user)) {
807+
if (! $user instanceof User) {
808808
throw AuthenticationException::forInvalidUser();
809809
}
810810

src/Authentication/Passwords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function check(string $password, ?User $user = null): Result
112112

113113
$password = trim($password);
114114

115-
if (empty($password)) {
115+
if ($password === '' || $password === '0') {
116116
return new Result([
117117
'success' => false,
118118
'reason' => lang('Auth.errorPasswordEmpty'),

src/Authentication/Passwords/CompositionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CompositionValidator extends BaseValidator implements ValidatorInterface
3737
*/
3838
public function check(string $password, ?User $user = null): Result
3939
{
40-
if (empty($this->config->minimumPasswordLength)) {
40+
if ($this->config->minimumPasswordLength === 0) {
4141
throw AuthenticationException::forUnsetPasswordLength();
4242
}
4343

src/Authentication/Passwords/NothingPersonalValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function isNotPersonal(string $password, ?User $user): bool
8585

8686
// might be john.doe@example.com and we want all the needles we can get
8787
$emailParts = $this->strip_explode($localPart);
88-
if (! empty($domain)) {
88+
if ($domain !== null && $domain !== '' && $domain !== '0') {
8989
$emailParts[] = $domain;
9090
}
9191
$needles = [...$needles, ...$emailParts];

src/Authentication/Passwords/ValidationRules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function strong_password(string $value, ?string &$error1 = null, array $d
4949
$user = auth()->user();
5050
} else {
5151
/** @phpstan-ignore-next-line */
52-
$user = empty($data) ? $this->buildUserFromRequest() : $this->buildUserFromData($data);
52+
$user = $data === [] ? $this->buildUserFromRequest() : $this->buildUserFromData($data);
5353
}
5454

5555
$result = $checker->check($value, $user);
5656

5757
if (! $result->isOk()) {
58-
if (empty($data)) {
58+
if ($data === []) {
5959
$error1 = $result->reason();
6060
} else {
6161
$error2 = $result->reason();

src/Authentication/Traits/HasAccessTokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function accessTokens(): array
9797
*/
9898
public function getAccessToken(?string $rawToken): ?AccessToken
9999
{
100-
if (empty($rawToken)) {
100+
if ($rawToken === null || $rawToken === '' || $rawToken === '0') {
101101
return null;
102102
}
103103

src/Authorization/Traits/Authorizable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function can(string ...$permissions): bool
264264
return true;
265265
}
266266

267-
if (! count($this->groupCache)) {
267+
if (count($this->groupCache) === 0) {
268268
return false;
269269
}
270270

src/Entities/Group.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ public function can(string $permission): bool
8080
$this->populatePermissions();
8181

8282
// Check exact match
83-
if (! empty($this->permissions) && in_array($permission, $this->permissions, true)) {
83+
if ($this->permissions !== null && $this->permissions !== [] && in_array($permission, $this->permissions, true)) {
8484
return true;
8585
}
8686

8787
// Check wildcard match
8888
$check = substr($permission, 0, strpos($permission, '.')) . '.*';
8989

90-
return ! empty($this->permissions) && in_array($check, $this->permissions, true);
90+
return $this->permissions !== null && $this->permissions !== [] && in_array($check, $this->permissions, true);
9191
}
9292

9393
/**

0 commit comments

Comments
 (0)