-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix #69804: ::getStaticPropertyValue() throws on protected props #5367
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
Conversation
`ReflectionClass` allows reading of the values of private and protected constants, and also to get private and protected static methods. Therefore getting the values of private and protected static properties is also permissible, especially since `::getStaticProperties()` already allows to do so.
|
What about setStaticPropertyValue? |
Well, you can't invoke (static) private/protected methods without making them accessible first, so I think |
|
@cmb69 Doesn't the same argument apply to getStaticPropertyValue() as well? TBH I don't understand why these methods are a thing at all, they don't seem to provide anything on top of |
|
You can read private constants via ReflectionClass, but you can't read private static properties: https://3v4l.org/GdKJn. Also, |
Forbidding to modify private and protected properties renders this method useless, as modifying public properties can be done directly.
Well, after reconsideration I agree that it makes no sense to restrict this method to public properties (see also https://www.php.net/manual/en/reflectionclass.setstaticpropertyvalue.php#114740). PR updated. Can this still target PHP-7.3? The change could break some tests/expectations. |
I think it's best to leave 7.3 alone. |
Fine. :) But for 7.4 I'm hitting https://bugs.php.net/79487. :( |
|
Applied as 26aefb7. Thanks! |
https://bugs.php.net/bug.php?id=69804
ReflectionClassallows reading of the values of private and protectedconstants, and also to get private and protected static methods.
Therefore getting the values of private and protected static properties
is also permissible, especially since
::getStaticProperties()alreadyallows to do so.