Skip to content

Commit 36d043e

Browse files
committed
Fix PHPStan miscellaneous type errors
- Progress: Add ignore for match arm always-true (correct exhaustive logic) - Listener: Add ignore for intentional infinite while(true) loop - Reflector: Remove redundant is_string check (already validated above) - ExtractProperties: Add ignore for PHP version check - MessageSelector: Add ignore for Arabic plural formula (modulo <= 99) - Prompt/ValidatesAttributes: Add ignores for defensive null checks - EventFake: Add ignore for intentional assertTrue(false) test failure
1 parent 368914a commit 36d043e

File tree

8 files changed

+8
-9
lines changed

8 files changed

+8
-9
lines changed

src/prompts/src/Progress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(public string $label, public int|iterable $steps, pu
3939
$this->total = match (true) { // @phpstan-ignore assign.propertyType
4040
is_int($this->steps) => $this->steps,
4141
is_countable($this->steps) => count($this->steps),
42-
is_iterable($this->steps) => iterator_count($this->steps),
42+
is_iterable($this->steps) => iterator_count($this->steps), // @phpstan-ignore match.alwaysTrue
4343
default => throw new InvalidArgumentException('Unable to count steps.'),
4444
};
4545

src/prompts/src/Prompt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function prompt(): mixed
167167
*/
168168
public function runLoop(callable $callable): mixed
169169
{
170-
while (($key = static::terminal()->read()) !== null) {
170+
while (($key = static::terminal()->read()) !== null) { // @phpstan-ignore notIdentical.alwaysTrue
171171
/**
172172
* If $key is an empty string, Terminal::read
173173
* has failed. We can continue to the next

src/queue/src/Listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function listen(?string $connection, string $queue, ListenerOptions $opti
6161
{
6262
$process = $this->makeProcess($connection, $queue, $options);
6363

64-
while (true) {
64+
while (true) { // @phpstan-ignore while.alwaysTrue (intentional infinite loop)
6565
$this->runProcess($process, $options->memory);
6666

6767
if ($options->rest) {

src/support/src/Reflector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public static function isCallable(mixed $var, bool $syntaxOnly = false): bool
2727
}
2828

2929
if ($syntaxOnly
30-
&& (is_string($var[0]) || is_object($var[0]))
31-
&& is_string($var[1])) {
30+
&& (is_string($var[0]) || is_object($var[0]))) {
3231
return true;
3332
}
3433

src/support/src/Testing/Fakes/EventFake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function assertListening(string $expectedEvent, string $expectedListener)
8484
}
8585
}
8686

87-
PHPUnit::assertTrue(
87+
PHPUnit::assertTrue( // @phpstan-ignore staticMethod.impossibleType (intentional test failure)
8888
false,
8989
sprintf(
9090
'Event [%s] does not have the [%s] listener attached to it',

src/telescope/src/ExtractProperties.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function from(mixed $target): array
2121
->mapWithKeys(function ($property) use ($target) {
2222
$property->setAccessible(true);
2323

24-
if (PHP_VERSION_ID >= 70400 && ! $property->isInitialized($target)) {
24+
if (PHP_VERSION_ID >= 70400 && ! $property->isInitialized($target)) { // @phpstan-ignore greaterOrEqual.alwaysTrue
2525
return [];
2626
}
2727

src/translation/src/MessageSelector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public function getPluralIndex(string $locale, float|int $number): int
390390
case 'ar_SY':
391391
case 'ar_TN':
392392
case 'ar_YE':
393-
return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
393+
return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5)))); // @phpstan-ignore smallerOrEqual.alwaysTrue
394394
default:
395395
return 0;
396396
}

src/validation/src/Concerns/ValidatesAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ public function validateUuid(string $attribute, mixed $value, mixed $parameters)
21662166
{
21672167
$version = null;
21682168

2169-
if ($parameters !== null && count($parameters) === 1) {
2169+
if ($parameters !== null && count($parameters) === 1) { // @phpstan-ignore notIdentical.alwaysTrue
21702170
$version = $parameters[0];
21712171

21722172
if ($version !== 'max') {

0 commit comments

Comments
 (0)