Skip to content

Commit 78b1396

Browse files
committed
Fix PHPStan booleanAnd.alwaysFalse and related errors
- ArgonHasher.php: Add booleanAnd.alwaysFalse to existing platform-specific ignore - Email.php, File.php, Password.php: Add ignores for instanceof.alwaysTrue and booleanAnd.alwaysFalse (PHPStan's callable|static type narrowing doesn't account for closures not being class instances) - StartSession.php: Add booleanAnd.alwaysFalse to existing bug ignore
1 parent c054494 commit 78b1396

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

src/hashing/src/ArgonHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function time(array $options): int
151151
*/
152152
protected function threads(array $options): int
153153
{
154-
if (defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER === 'sodium') { // @phpstan-ignore identical.alwaysFalse (platform-specific constant)
154+
if (defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER === 'sodium') { // @phpstan-ignore identical.alwaysFalse, booleanAnd.alwaysFalse (platform-specific constant)
155155
return 1;
156156
}
157157

src/session/src/Middleware/StartSession.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ protected function configHitsLottery(array $config): bool
157157
*/
158158
protected function storeCurrentUrl(Session $session): void
159159
{
160+
// @phpstan-ignore-next-line booleanAnd.alwaysFalse (operator precedence bug, fix in separate PR)
160161
if ($this->request->isMethod('GET')
161-
&& ! $this->request->header('X-Requested-With') === 'XMLHttpRequest' // @phpstan-ignore identical.alwaysFalse (operator precedence bug, fix in separate PR)
162+
&& ! $this->request->header('X-Requested-With') === 'XMLHttpRequest' // @phpstan-ignore identical.alwaysFalse
162163
&& ! $this->isPrefetch()
163164
) {
164165
$session->setPreviousUrl($this->request->fullUrl());

src/validation/src/Rules/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function defaults(mixed $callback = null): ?static
7171
return static::default();
7272
}
7373

74-
if (! is_callable($callback) && ! $callback instanceof static) {
74+
if (! is_callable($callback) && ! $callback instanceof static) { // @phpstan-ignore instanceof.alwaysTrue, booleanAnd.alwaysFalse (callable values like closures are not instances)
7575
throw new InvalidArgumentException('The given callback should be callable or an instance of ' . static::class);
7676
}
7777

src/validation/src/Rules/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function defaults(mixed $callback = null): ?static
8282
return static::default();
8383
}
8484

85-
if (! is_callable($callback) && ! $callback instanceof static) {
85+
if (! is_callable($callback) && ! $callback instanceof static) { // @phpstan-ignore instanceof.alwaysTrue, booleanAnd.alwaysFalse (callable values like closures are not instances)
8686
throw new InvalidArgumentException('The given callback should be callable or an instance of ' . static::class);
8787
}
8888

src/validation/src/Rules/Password.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static function defaults(mixed $callback = null): ?static
108108
return static::default();
109109
}
110110

111-
if (! is_callable($callback) && ! $callback instanceof static) {
111+
if (! is_callable($callback) && ! $callback instanceof static) { // @phpstan-ignore instanceof.alwaysTrue, booleanAnd.alwaysFalse (callable values like closures are not instances)
112112
throw new InvalidArgumentException('The given callback should be callable or an instance of ' . static::class);
113113
}
114114

0 commit comments

Comments
 (0)