Skip to content

Commit 73172cf

Browse files
mglamanclaude
andauthored
Fix InspectorTypeExtension compatibility with PHPStan 2.1.47 mixed~null type (#976)
PHPStan 2.1.47 now infers mixed~null instead of mixed in certain scopes. Update the assertAll check to use instanceof MixedType rather than equals() so mixed~null inputs are also narrowed to iterable. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0d050e1 commit 73172cf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Type/InspectorTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private function specifyAssertAll(MethodReflection $staticMethodReflection, Stat
111111
// If it is already not mixed (narrowed by other code, like
112112
// '::assertAllArray()'), we could not provide any additional
113113
// information. We can only narrow this method to 'array<mixed, mixed>'.
114-
if (!$traversableType->equals(new MixedType())) {
114+
if (!$traversableType instanceof MixedType) {
115115
return new SpecifiedTypes();
116116
}
117117

tests/src/Type/data/bug-857.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function mixed_function(): mixed {}
1414

1515
// If the type is narrowed before '::assertAll()', it shouldn't change it.
1616
$array = mixed_function();
17-
assertType('mixed', $array);
17+
assertType('mixed~null', $array);
1818
\assert(Inspector::assertAllArrays($array));
1919
assertType('iterable<array>', $array);
2020
\assert(Inspector::assertAll(fn (array $i): bool => TRUE, $array));

0 commit comments

Comments
 (0)