(expression)::class cannot be used in constant expressions¶
Description¶
This error appears when the value of a constant is not entirely static, but may depend on context. In this case, the self::A will only be known when the trait t is used in a class.
Example¶
<?php
trait T {
const A = parent::class;
const B = self::A::class;
}
?>
Solutions¶
Keep values of constants simple.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.