0

Is there a phpdoc tag for telling PhpStorm explicitly a class implements an interface?

I'm writing a "semi-mixin system" for PHP 5.3 (traits are not available). The way this is typically done is by using the magic __call method. I was looking for a way to tell PhpStorm my class implements an interface/other class. I noticed code completion suggest an "@is" doc tag, but is doesn't seem to do anything.

I tried to use it something like this:


<?php

/**
*  @is MixinA
*  @is MixinB
*/

class MyClass {

     private $a;
     private $b;

     public function __construct() {
          $this->a = new MixinA();
          $this->b = new MixinB();
     }


     public function __call($name, $args) {
          $callObject = null;


          if (is_callable($this->a, $name)) {
               $callObject = $this->a;
          } elseif (is_callable($this->b, $name)) {
               $callObject = $this->b;
          }


          if ($callObject !== null) {
               call_user_func (array($callObject, $name), $args);
          }
     }

}


class MixinA {
     public function methodA() { ... }
     public function methodB() { ... }
}


class MixinB {
     public function methodC() { ... };
     public function methodD() { ... };
}


$object = new MyClass();

$object->methodA();
$object->methodD();



Is there a phpdoc tag to do this, and how do I use it? I know I can use @method and @property, but that's too cumbersome since there a lot of methods.

Thanks in advance.

1 comment

Please sign in to leave a comment.