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

Code Inspection: Dynamic method called as static

Last modified: 16 May 2022

Reports static calls to dynamic class methods.

For classes having the magic method __callStatic, a separate inspection severity and highlighting level can be set.

In PHP 5.6 and later, calling static methods dynamically is deprecated and generates an E_DEPRECATED warning. As of PHP 7.0, calling a non-static method statically results in $this being undefined inside the method. For more information, refer to OOP Basics (php.net).

In the following example, the method foo() is called as static while actually it is dynamic.