Description
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.
Activity
VincentLanglet commentedon Jun 2, 2020
@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 ? :)
ondrejmirtes commentedon Jun 2, 2020
For offsetGet to work, there needs to be a dynamic return type extension that asks the type in
$methodCall->var
abouthasOffsetValueType
.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.
phpstan-bot commentedon Mar 9, 2021
@VincentLanglet PHPStan now reports different result with your code snippet:
Full report
Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess.
phpstan-bot commentedon Mar 9, 2021
@VincentLanglet PHPStan now reports different result with your code snippet:
Full report
Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess.
phpstan-bot commentedon Mar 9, 2021
@VincentLanglet PHPStan now reports different result with your code snippet:
Full report
Non-abstract class FormView contains abstract method offsetExists() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetGet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetSet() from interface ArrayAccess.
Non-abstract class FormView contains abstract method offsetUnset() from interface ArrayAccess.
ArrayAccess->offsetExists
narrowing phpstan/phpstan-src#3760