Traits cannot have constants¶
Description¶
Constants int traits were added in PHP 8.2. Until then, they were not allowed: at compile time this error was yield.
Example¶
<?php
trait T {
const X = 1;
}
echo T::X;
?>
Solutions¶
Put the constant in the host class.
Put the constant in an interface.
Do not use the constant.
Move to PHP 8.2 or later.