-
Notifications
You must be signed in to change notification settings - Fork 7.8k
PHP 8.3 | Incorrect error when using static
on parameter in extended class
#12069
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
Comments
This is a side-effect of #9926. Anyhow, the definition is simple: any keyword which may be used before a variable to declare it within class scope, is considered an attempt to declare a promoted property. And it's not possible to create a static promoted property, hence the error. It might be possible to craft a special case error message here, but it won't be a syntax error. |
@bwoebi I'd be fine with it not being a parse error, as long as the reference to promoted properties does not show for non- Something along the lines of |
When replacing the
Perhaps the order of the checks just needs to be reversed: https://3v4l.org/AM49EF/rfc#vgit.master? |
I don't think this is possible as it looks like the new error happens during lexing, while the
Error happens while compiling a list of parameters together. |
We could just change the error message from "Cannot use the static modifier on a promoted property" to "Cannot use the static modifier on a parameter" in all cases. That should make it less confusing. |
The ZEND_MODIFIER_TARGET_CPP should really have been called _PARAM, but we shouldn't break API at this point. Closes phpGH-12069
@iluuu1994 Makes sense to me. Thanks for getting this sorted. |
Description
The following code:
PHP 8.0 - 8.2: https://3v4l.org/c5r5q
PHP 8.3: https://3v4l.org/c5r5q/rfc#vgit.master
Resulted in this output:
But I expected this output instead:
As this method is not a class constructor, the reference to promoted properties is confusing.
Discovered by accident while creating a code sample to test something else completely.
PHP Version
PHP 8.3.0-dev
Operating System
No response
The text was updated successfully, but these errors were encountered: