New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong assignation to ArrayAccess&SomeOtherType
not reported
#6184
Comments
@julienfalque After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
+ 6: Property Foo::$collection1 is never written, only read.
+ 9: Property Foo::$collection2 is never written, only read.
13: ArrayAccess<int, string> does not accept int. Full report
|
@julienfalque After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
+ 6: Property Foo::$collection1 is never read, only written.
+ 9: Property Foo::$collection2 is never read, only written.
13: ArrayAccess<int, string> does not accept int. Full report
|
@julienfalque After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: ArrayAccess<int, string> does not accept int.
+ 6: Property Foo::$collection1 is never read, only written.
+ 9: Property Foo::$collection2 is never read, only written.
+13: ArrayAccess<int, string> does not accept int.
+13: Property Foo::$collection1 (ArrayAccess<int, string>) does not accept array{1}.
+14: Property Foo::$collection2 (ArrayAccess<int, string>&Countable) does not accept array{2}. Full report
|
@julienfalque After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: ArrayAccess<int, string> does not accept int.
+ 6: Property Foo::$collection1 is never read, only written.
+ 9: Property Foo::$collection2 is never read, only written.
+13: ArrayAccess<int, string> does not accept int.
+14: Property Foo::$collection2 (ArrayAccess<int, string>&Countable) does not accept Countable. Full report
|
Fixed: phpstan/phpstan-src@3b5fd94 |
Thank you @ondrejmirtes! |
Shouldn't the last error be
? |
Yes, it should, but for complicated reasons this is the best we can do right now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
When assigning a wrong new value to a variable of type
ArrayAccess
, the error is not reported if the type of the variable includes an intersection with another type.Code snippet that reproduces the problem
https://phpstan.org/r/8142895e-0a04-44b6-82c9-e1eed898da54
Expected output
Both assignations should be reported as they don't accept
int
.The text was updated successfully, but these errors were encountered: