Code Inspection: Static method called as dynamic
Configure inspections: Settings | Editor | Inspections
Show intention actions: AltEnter
Reports dynamic calls to static class methods.
If the target has the magic method __call
, a separate inspection severity and highlighting level can be set.
In PHP 5, calling non-static methods statically generates an E_STRICT
warning. In PHP 7, calling non-static methods statically is deprecated, and will generate an E_DEPRECATED
warning. For more information, refer to Static methods (php.net).
In the following example, the method foo()
is called as dynamic while actually it is static.
class A {
public static function foo() {}
}
$a = new A();
$a->foo();
Place the caret at the highlighted line and press AltEnter or click
.
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.