PhpStorm:代码分析 - 来自类名的静态调用

I have got a warning in PhpStorm for a common use of static calls. I have:

class Test {
  public static function thisIsATest(){
     // do stuff
  }
}

Then, I have:

$className = 'Test';
$className::thisIsATest();

This is not an error, btw I have this in my PhpStorm: warning_phpstorm

Is there a way to handle this? At least, is it possible to just hide this warning?

There are some solutions, for this problem:

  1. change to a PHP Version >= 5.3.0

  2. use call_user_func(array('Test','thisIsATest')); in older PHP versions

  3. change code-inspection-behavior in phpstrom under project settings (also ensure phpstrom has the right PhpVersion set up for your current project)

  4. [Solution] Declare the variable with annotations in phpstrom in the right way!

Like:

  <?php
  /**
   * @var $className Test
   */
  $className::thisIsATest();

Now phpstrom know that $className is a instance of Test that has a method called thisIsATest, and no error hint pops up.