Skip to content
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

False positive UnusedMethodCall for ReflectionProperty::setAccessible #11066

Open
zerkms opened this issue Aug 6, 2024 · 3 comments
Open

False positive UnusedMethodCall for ReflectionProperty::setAccessible #11066

zerkms opened this issue Aug 6, 2024 · 3 comments

Comments

@zerkms
Copy link
Contributor

zerkms commented Aug 6, 2024

https://psalm.dev/r/14e6e58931

Copy link

I found these snippets:

https://psalm.dev/r/14e6e58931
<?php

$conn = new \stdClass();

$connReflection = new ReflectionClass($conn);
$ioProperty = $connReflection->getProperty('foo');
$ioProperty->setAccessible(true);
Psalm output (using commit 16b24bd):

ERROR: UnusedMethodCall - 7:14 - The call to ReflectionProperty::setAccessible is not used

@zerkms zerkms changed the title False positive UnusedMethodCall for ReflectionProperty::getProperty False positive UnusedMethodCall for ReflectionProperty::setAccessible Aug 6, 2024
@M393
Copy link

M393 commented Aug 7, 2024

Maybe it is because it is no longer necessary to call setAccessible.

Note: As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default.

https://www.php.net/manual/en/reflectionproperty.setaccessible.php

@zerkms
Copy link
Contributor Author

zerkms commented Aug 7, 2024

@M393 oh wow, didn't know that. In that case it possibly would be a room to improve the error message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants