我可以用phpstorm指示方法php返回的类型吗?

I use __call() magic php method to call non existing method with my own instructions.

I want know how can I indicate to phpstorm : this non-existing method returned an instance of a class?

exemple :

class Baz
{
   function __call()
   {
      return new Bar();
   }

   function test()
   {
      $this->foo()->bar();
   }
}


class Bar
{
   function bar()
   {
       //do something
   }
}

I want declare for all current class Baz :

/** @return foo() Bar */

I want PhpSotrm found the bar() method source and concider foo() like a Bar instance object.

How can I do that?

You could use the magic method annotations

/**
 * @method Bar foo()
 */
 class Baz
 {
   ...