Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Move property accessor phpdoc to interface #60860

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

Open
wants to merge 1 commit into
base: 7.2
Choose a base branch
from

Conversation

VincentLanglet
Copy link
Contributor

Q A
Branch? 7.2
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #...
License MIT

This gives the same help for static analyser than #60374 but for the Interface.
I targeted the 7.2 branch since it's the one the phpdoc was introduced.

I copy the explanation:

This pull request was made to help static code analyzers understand that when calling PropertyAccessor::setValue, this will > not change the type of the passed $objectOrArray.
At the moment static analysis will point out that the value of $objectOrArray can be any object or an array after calling the > setValue method, which is of course not the case.

The solution comes directly from this closed PHPStan issue: phpstan/phpstan#12399
(Other tools like Psalm also support @param-out)

According to the Interface description this behavior shouldn't be restricted to PropertyAccessor but should be enforced/described in the interface too.

@carsonbot carsonbot added this to the 7.4 milestone Jun 20, 2025
@carsonbot

This comment has been minimized.

@VincentLanglet VincentLanglet changed the base branch from 7.4 to 7.2 June 20, 2025 21:19
@VincentLanglet
Copy link
Contributor Author

Failures are unrelated

@OskarStark OskarStark modified the milestones: 7.4, 7.2 Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants