To check in a trait if a constant is defined in the class using the trait, prepend the constant name with `self::class`:
<?php
trait MyTrait {
public function checkConstant() {
assert(defined(self::class . "::MY_CONSTANT"));
print self::MY_CONSTANT;
}
}
class MyClass {
use MyTrait;
protected const MY_CONSTANT = 'my value';
}
$class = new MyClass();
$class->checkConstant();
?>