-
-
Notifications
You must be signed in to change notification settings - Fork 204
PHP 8.0: NewNestedStaticAccess: add support for class constant dereferencing #1262
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
PHP 8.0: NewNestedStaticAccess: add support for class constant dereferencing #1262
Conversation
…rencing > ... class constant accesses are only array and object dereferencable. This > means that while `Foo::$bar::$baz` is legal, `Foo::BAR::$baz` is not. > > This RFC proposes to make class constant accesses static derefencable as > well, so that `Foo::BAR::$baz` and `Foo::BAR::BAZ` become legal. Ref: * https://wiki.php.net/rfc/variable_syntax_tweaks#class_constant_dereferencability * php/php-src#5061 * php/php-src@ab154b7 Includes unit tests. Relates to PHPCompatibility#809.
jrfnl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @elazar, thanks for this change!
Looking very good.
I only have a few small remarks, nothing major.
- Each error message should have a unique error code so error messages can be selectively ignored. As things are, they currently both have the same error code.
You can either just adjust the error code for the new error message or adjust both to made the distinction between the two clear.
As the next release will be a major, we don't have to worry too much about a change in the original error code being a BC break. - As this sniff now has checks related to different PHP versions, it would be a good idea to add a "no-violation on PHP 7.0" check to the
testNestedStaticAccess()method. - Aside from the existing "false positive" prevention checks, is there any other code pattern you can think of which we need to guard against specifically for the new class constant dereferencing ? I.e. are there new false positive code patterns which could be added in the test case file which aren't currently accounted for ? (if the answer is "no", that's perfectly fine, I just want to make sure this has been considered)
Non-blocking:
- The error message phrasing is inconsistent -
cannot be dereferenced in PHP 7.4 or earliervswas not supported in PHP 5.6 or earlier.
Not a blocker, but might be an idea to make the phasing more consistent. - Code-scouting: I realize the original
testNestedStaticAccess()test does not have a proper method description, but with an eye on the documentation clean up, it would be nice if the newly added test method has a proper description and if you feel like adding a proper description to thetestNestedStaticAccess()that would be awesome too! 😄
PHPCompatibility/Tests/Syntax/NewNestedStaticAccessUnitTest.inc
Outdated
Show resolved
Hide resolved
Done in f4e4e84.
Done in bdc6c09.
None that I can think of, no.
Done in bb66569.
Done in d5c7e51. |
jrfnl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 Thanks Matthew!
Ref:
Includes unit tests.
Relates to #809.