-
-
Notifications
You must be signed in to change notification settings - Fork 897
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
Add the sameBehaviour for offsetExists/offsetGet than isset #3323
Add the sameBehaviour for offsetExists/offsetGet than isset #3323
Comments
@ondrejmirtes I wouldlike to try to implement this. Could you explain to me how isset works with phpstan and what I should do for offsetExist/offsetGet ? :) |
For offsetGet to work, there needs to be a dynamic return type extension that asks the type in For offsetExists to work, there has to be a type-specifying extension for that method with similar logic as this one https://github.com/phpstan/phpstan-src/blob/master/src/Type/Php/ArrayKeyExistsFunctionTypeSpecifyingExtension.php. |
@VincentLanglet PHPStan now reports different result with your code snippet: @@ @@
-No errors
+6: Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
+6: Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
+6: Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
+6: Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess. Full report
|
@VincentLanglet PHPStan now reports different result with your code snippet: @@ @@
+ 6: Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess.
14: Cannot access property $vars on FormView|null. Full report
|
@VincentLanglet PHPStan now reports different result with your code snippet: @@ @@
+ 6: Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
+ 6: Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess.
14: Cannot access property $vars on FormView|null. Full report
|
Feature request
This is working
https://phpstan.org/r/1e164242-ebc4-40ca-a92e-c6c61c306bdf
This is not
https://phpstan.org/r/9ffb60c5-c6b2-460d-a2af-7708c3c70004
This is not
https://phpstan.org/r/ebbd7013-d22f-403f-bc14-6dcda8026def
All should be working the same way IMHO.
The text was updated successfully, but these errors were encountered: