xref: /PHP-8.4/Zend/tests/traits/constant_016.phpt (revision bfa56cf6)
1--TEST--
2Compatibility of values of same name trait constants is checked after their constant expressions are evaluated
3--ENV--
4ENSURE_CONSTANT_IS_DEFINED_AT_RUNTIME=1
5--INI--
6variables_order=EGPCS
7--FILE--
8<?php
9
10// Ensure CONSTANT is defined at runtime
11if ($_ENV['ENSURE_CONSTANT_IS_DEFINED_AT_RUNTIME']) {
12    define('CONSTANT', 2);
13}
14
15trait TestTrait {
16  public const Constant = 40 + CONSTANT;
17}
18
19class ComposingClass {
20    use TestTrait;
21    public const Constant = 42;
22}
23
24echo ComposingClass::Constant;
25?>
26--EXPECTF--
2742
28