I'm using CakePHP 3 and PHPStorm 9 for my current PHP project and I have a class GroupsTable
which is using the TreeBehavior
.
In my GroupsController
I have the following docblock:
/**
* Class GroupsController
*
* @property GroupsTable $Groups
*
* @package App\Controller
*/
With the @property
part I make sure that I can access my GroupsTable
methods via the autocompletion of PHPStorm by typing $this->Groups->
and then it will show all the available methods of the GroupsTable
class.
But, as I said before I added the TreeBehavior
to this GroupsTable
, and so I want to be able to see the methods of this behavior via the autocompletion as well. I access methods of the behavior via a call like this: $this->Groups->recover()
, which is a method defined in the TreeBehavior
. You could say CakePHP is "extending" the behavior, but that's not what's fysically happening, resulting in a lack of autocompletion.
So my question is:
How can I append methods to a class, as if the current class is extending another class.
So in my case:
How can I add the TreeBehavior
methods to the GroupsTable
, so that PHPStorm "thinks" recover()
is part of the GroupsTable
class and therefore is able to autocomplete as such?
I tried things like @property TreeBehavior $this
and @var TreeBehavior $this
in the docblock of the GroupsTable
class. I also tried other methods as defined in the PHPDoc manual but nothing seems to work.
I find it hard to believe there is nothing to find about this subject via a search engine or on SO, but I can't seem to find anything about this. Perhaps because there is a term for it which I don't know?