Fix GH-9271: Conflicts between interface constants and trait constants should trigger fatal error#9274
Open
sj-i wants to merge 1 commit intophp:masterfrom
Open
Fix GH-9271: Conflicts between interface constants and trait constants should trigger fatal error#9274sj-i wants to merge 1 commit intophp:masterfrom
sj-i wants to merge 1 commit intophp:masterfrom
Conversation
…ants should trigger fatal error
Member
|
@kocsismate can you give your opinion on this as the author of https://wiki.php.net/rfc/final_class_const . I'm still not sure if that behaviour is correct considering our current semantics, for me either the current one or this one are fine as in the former we override the interface constant which is possible in a class and traits are basically just copy and paste code into the class. But on the other hand this can be confusing and was explicitly disallowed in the RFC |
Member
|
Thank you for bringing this to my attention! I've just answered in the issue: #9271 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #9271
The cause
The order of processing was:
So when processing the trait constants, the constants derived from interfaces were not found in the constant table of the composing class.
The same problem with property conflicts did not occur because interfaces don't allow properties to be defined.
Since simply flipping bindings of traits and interfaces breaks other tests, I moved only the binding of trait constants to after the binding of interfaces.