xref: /PHP-8.3/Zend/tests/traits/constant_008.phpt (revision 3b62d660)
1--TEST--
2Conflicting constants in another traits in same composing classes with different visibility modifiers 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 = 42;
8}
9
10trait Trait2 {
11  private const Constant = 42;
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