PhpStorm 2023.3 Help

Code Inspection: Dynamic method called as static

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.

class A { public function foo() {} } $a = new A(); $a::foo();

Suppress an inspection in the editor

  1. Place 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: 25 March 2024