xref: /PHP-8.4/Zend/tests/traits/constant_009.phpt (revision 3b62d660)
1--TEST--
2Conflicting constants in another traits in same composing classes with different values should result in a fatal error, since this indicates that the code is incompatible.
3--FILE--
4<?php
5
6trait Trait1 {
7  public const Constant = 123;
8}
9
10trait Trait2 {
11  public const Constant = 456;
12}
13
14echo "PRE-CLASS-GUARD\n";
15
16class TraitsTest {
17    use Trait1;
18    use Trait2;
19}
20
21echo "POST-CLASS-GUARD\n";
22?>
23--EXPECTF--
24PRE-CLASS-GUARD
25
26Fatal error: Trait1 and Trait2 define the same constant (Constant) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
27