Skip to content

Fix GH-9271: Conflicts between interface constants and trait constants should trigger fatal error #9274

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sj-i
Copy link
Contributor

@sj-i sj-i commented Aug 8, 2022

This fixes #9271

The cause

The order of processing was:

  1. inheritance
  2. trait
  3. interface

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.

@Girgias
Copy link
Member

Girgias commented Aug 12, 2022

@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

@kocsismate
Copy link
Member

Thank you for bringing this to my attention! I've just answered in the issue: #9271 (comment)

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

Successfully merging this pull request may close these issues.

Collision of interface constant and trait constant doesn't produce fatal error
3 participants