PhpStorm 2022.1 Help

Code Inspection: Static method called as dynamic

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. See Static methods (php.net) for details.

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();

Suppress an inspection in the editor

  1. Position the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 16 May 2022