You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Collision of interface constant and trait constant should not produce fatal error #16198
Fatal error: I1 and T1 define the same constant (C1) in the composition of O4. However, the definition differs and is considered incompatible. Class was composed in /home/user/scripts/code.php on line 32
The behavior of a trait is to copy code into class, so if we can do something without trait and without error, it should be possible to do the same thing but with trait. I don't understand why I get this error with my code.
if (status1==INHERITANCE_ERROR||status2==INHERITANCE_ERROR) {
When lifting the restriction, the compilation would then fail because the constant values are not compatible (i.e. not the same, as is checked in this case):
Hmm, I think it can be "fixed", but I'm not sure whether the current implementation is by design. Maybe @kocsismate can explain the rationale of the current implementation.
Activity
cmb69 commentedon Oct 3, 2024
Well, could go beyond this error with the following patch
But then the compilation would fail, because trait constants are apparently invariant:
php-src/Zend/zend_inheritance.c
Lines 2711 to 2713 in 2d8a93c
When lifting the restriction, the compilation would then fail because the constant values are not compatible (i.e. not the same, as is checked in this case):
php-src/Zend/zend_inheritance.c
Lines 2719 to 2723 in 2d8a93c
Renji-FR commentedon Oct 4, 2024
@cmb69 Thank you, so the fix requires more dev or it can not be fixed?
The behavior is different with trait and could not be fixed?
cmb69 commentedon Oct 4, 2024
Hmm, I think it can be "fixed", but I'm not sure whether the current implementation is by design. Maybe @kocsismate can explain the rationale of the current implementation.
iluuu1994 commentedon Oct 8, 2024
Likely related to #15753, with a fix here. I quickly applied it to 8.3 and tried the test, and it indeed passes.
Renji-FR commentedon Oct 8, 2024
related to #16198
Thank you @iluuu1994
Renji-FR commentedon Nov 14, 2024
What is the next step to have the fix in the next minor release please?
iluuu1994 commentedon Nov 14, 2024
Nothing on your side. I need to think through the consequences of my patch when I have the time.
Bind traits before parent class
Bind traits before parent class