Cannot access static:: when no class scope is active¶
Description¶
static
refers to the class that was called to access the class elements (constants, method, properties..). As such, static
can only be used inside a class or a trait.
Example¶
<?php
static::x;
?>
Solutions¶
Move the code inside a method, in a trait or a class.
Use the full name of the class that should be used.
In more recent PHP versions, this error message is now Cannot use “static” when no class scope is active.