xref: /PHP-8.4/Zend/tests/traits/constant_015.phpt (revision 3b62d660)
1--TEST--
2The same name constant of a trait used in a class that inherits a constant defined in a parent can be defined only if they are compatible.
3--FILE--
4<?php
5
6trait TestTrait1 {
7    public final const Constant = 123;
8}
9
10class BaseClass1 {
11    public final const Constant = 123;
12}
13
14class DerivedClass1 extends BaseClass1 {
15    use TestTrait1;
16}
17
18trait TestTrait2 {
19    public final const Constant = 123;
20}
21
22class BaseClass2 {
23    public final const Constant = 456;
24}
25
26class DerivedClass2 extends BaseClass2 {
27    use TestTrait2;
28}
29
30?>
31--EXPECTF--
32Fatal error: BaseClass2 and TestTrait2 define the same constant (Constant) in the composition of DerivedClass2. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
33