xref: /PHP-8.3/Zend/tests/traits/constant_002.phpt (revision 3b62d660)
1--TEST--
2Defining a constant in both trait and its composing class with the same name, visibility, finality and value is allowed
3--FILE--
4<?php
5
6trait TestTrait1 {
7    public const A = 42;
8}
9
10trait TestTrait2 {
11    public const A = 42;
12}
13
14trait TestTrait3 {
15    use TestTrait2;
16    public const A = 42;
17}
18
19class ComposingClass1 {
20    use TestTrait1;
21    use TestTrait2;
22}
23
24class ComposingClass2 {
25    use TestTrait1;
26    use TestTrait3;
27}
28
29class ComposingClass3 {
30    use TestTrait1;
31    use TestTrait3;
32    public const A = 42;
33}
34
35echo ComposingClass1::A, PHP_EOL;
36echo ComposingClass2::A, PHP_EOL;
37echo ComposingClass3::A, PHP_EOL;
38?>
39--EXPECTF--
4042
4142
4242
43