A
A
Alexey2020-05-27 12:01:30
PHP
Alexey, 2020-05-27 12:01:30

How to write possible methods in __call()?

Hello. I want to make a wrapper for a class. It turns out something like this:

class WebCategory{
  private $cat;
  public function __construct(Category $cat){
    $this->cat = $cat;
  }

  public function __call($name, $arguments){
    return $this->cat->$name($arguments);
  }

}

Can you please tell me how to make hints about existing methods that are called via __call() work in phpstorm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Artemyev, 2020-05-27
@dzheka3d

/**
 * Class WebCategory
 *
 * @mixin Category
 */
class WebCategory
{
    private $cat;

    public function __construct(Category $cat)
    {
        $this->cat = $cat;
    }

    public function __call($name, $arguments)
    {
        return $this->cat->$name($arguments);
    }
}

5ece38cb6ce10426224529.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question