-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
Readonly object ArrayAccess assignment detection #8929
Labels
Milestone
Comments
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 24, 2025
In case a readonly property is an object which implements ArrayAccess, offet accesses to said property are turned into method calls on PHP's side and are allowed even on read-only properties. this fixes phpstan/phpstan#8929
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 24, 2025
In case a readonly property is an object which implements ArrayAccess, offet accesses to said property are turned into method calls on PHP's side and are allowed even on read-only properties. this fixes phpstan/phpstan#8929
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 24, 2025
of course just checking for ArrayAccess isn't enough - it's only valid for index assignment operations 🤦
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 28, 2025
of course just checking for ArrayAccess isn't enough - it's only valid for index assignment operations 🤦
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 28, 2025
of course just checking for ArrayAccess isn't enough - it's only valid for index assignment operations 🤦
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 28, 2025
In case a readonly property is an object which implements ArrayAccess, offet accesses to said property are turned into method calls on PHP's side and are allowed even on read-only properties. this fixes phpstan/phpstan#8929
pilif
added a commit
to pilif/phpstan-src
that referenced
this issue
Jan 28, 2025
of course just checking for ArrayAccess isn't enough - it's only valid for index assignment operations 🤦
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
ArrayAccess offsetSet mistakenly detected as assignment of the property itself.
Code snippet that reproduces the problem
https://phpstan.org/r/a97143d1-7447-4a63-8b43-683f17783572
Expected output
Since WeakMap implements ArrayAccess the
$this->cache[$key] = $value
assignement wont update the object itself but calls a method on it. I think it should not generate the warning.Did PHPStan help you today? Did it make you happy in any way?
Yes, keep up the good work.
The text was updated successfully, but these errors were encountered: