You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array object nested types are not properly identified #7976
@@ @@
7: Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
-50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<int|string, non-empty-array>.+50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<1|2|3|string, non-empty-array>.
Full report
Line
Error
7
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
50
`Method HelloWorld::sayHello() should return ArrayObject<int
@@ @@
7: Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
-50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<int|string, non-empty-array>.+50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<int|string, non-empty-array<mixed>>.
Full report
Line
Error
7
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
50
`Method HelloWorld::sayHello() should return ArrayObject<int
@@ @@
7: Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
-50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<int|string, non-empty-array>.+50: Method HelloWorld::sayHello() should return ArrayObject<int|string, array<string, mixed>> but returns ArrayObject<int|string, array<mixed>>.
Full report
Line
Error
7
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValue
50
`Method HelloWorld::sayHello() should return ArrayObject<int
Activity
razvan-tache commentedon Sep 9, 2022
Original discussion: #7892 (comment)
Relevant comments:
I managed by changing the typehint of the init data, to be the type in the ArrayObject typehint, to receive an error:
It basically tells me that should return A but returns A.
Method HelloWorld::sayHello() should return ArrayObject<int|string, non-empty-array<string, mixed>> but returns ArrayObject<int|string, non-empty-array<string, mixed>>
I managed by changing the typehint of the init data, to be the type in the ArrayObject typehint, to receive an error:
It basically tells me that should return A but returns A.
Method HelloWorld::sayHello() should return ArrayObject<int\|string, non-empty-array<string, mixed>> but returns ArrayObject<int\|string, non-empty-array<string, mixed>>https://phpstan.org/r/4062d367-a8eb-4154-a57a-cdbd33f02bbd
From @ondrejmirtes :
This is the reason why the type isn't accepted: https://phpstan.org/r/bbccbef1-6759-437d-9081-3c309efcd700
phpstan-bot commentedon Sep 21, 2022
@razvan-tache After the latest push in 1.8.x, PHPStan now reports different result with your code snippet:
Full report
razvan-tache commentedon Sep 26, 2022
Cool, thanks, we'll check it out, as soon as we have the time!
razvan-tache commentedon Sep 26, 2022
phpstan-bot commentedon Sep 16, 2024
@razvan-tache After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValuephpstan-bot commentedon Sep 16, 2024
@razvan-tache After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
phpstan-bot commentedon Sep 16, 2024
@razvan-tache After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
phpstan-bot commentedon Jan 31, 2026
@razvan-tache After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValuephpstan-bot commentedon Mar 20, 2026
@razvan-tache After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
phpstan-bot commentedon Apr 23, 2026
@razvan-tache After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
Class Arr extends generic class ArrayObject but does not specify its types: TKey, TValuephpstan-bot commentedon Apr 23, 2026
@razvan-tache After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
phpstan-bot commentedon Apr 23, 2026
@razvan-tache After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report