Bug report
In Strict mode it is not allowed to overwrite properties already defined in Traits.
For this reason the Trait method checks if the property exists before accessing it.
Stan reports here
Access to an undefined static property
Foo::$default.
https://phpstan.org/r/63d8e0bc-78b4-41ab-b077-5244e2e218b0
Code snippet that reproduces the problem
trait EnumTrait {
protected $value;
final public function __construct($value) {
$this->value = $value;
}
public static function getDefault() {
if (property_exists(static::class, 'default') && null !== static::$default) {
$obj = static::$default;
return new static($obj);
}
return null;
}
}
Classes we don't want to have a default are reporting
class Foo {
use EnumTrait;
public const BLA = 'bla';
}
This is ok
class Foo {
use EnumTrait;
public static $default = 'bla';
public const BLA = 'bla';
}
Expected output
Should not report undefined property when property_exists() was called.
Bug report
In Strict mode it is not allowed to overwrite properties already defined in Traits.
For this reason the Trait method checks if the property exists before accessing it.
Stan reports here
https://phpstan.org/r/63d8e0bc-78b4-41ab-b077-5244e2e218b0
Code snippet that reproduces the problem
Classes we don't want to have a default are reporting
This is ok
Expected output
Should not report undefined property when property_exists() was called.