PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: Static method called as dynamic

Last modified: 16 May 2022

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.