PhpStorm and Yii behaviours

Hi all,

Just wondering if anyone has come across a way of getting PhpStorm to recognise behaviours?

I’ve got a couple of behaviours in my application and everything works fine.

It’s just a little annoying that PhpStorm doesn’t recognise the method and complains that the methods don’t exist.

As an example, in my controller I have this:




public function behaviors()

    {

        return array(

            'myBehavior' => array(

                'class' => 'application.components.myBehavior',

            )

        );

    }



Calling a method from the behaviour works fine




$this->myMethod();



but PhpStorm just doesn’t know about it. It confuses the hell out of people when I’m training them on the system. :blink:

Anybody happen to know anything we can do about it to help PhpStorm figure it out? Annotations etc?

Thanks

Add this method into class phpdoc.

http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.method.pkg.html

Hi and thanks a lot for replying to me.

I have tried that before and it works fine, but I suppose I was just hoping for something a bit more semantic.

For example, if I put this into my class phpdoc:




@method array compare



I have to back it up with a comment to explain what it is.

I also have to put a comment over the call to provide further info. Otherwise a newbie will go searching through the controller for a method that doesn’t exist. Also if you use PhpStorm’s “Go To Declaration or Implementation” tools, they’ll just take you to the @method declaration rather than the behaviour itself.

It’s no big deal anyway and it’s more a limitation of PhpStorm than Yii. Just one of those little annoyances.

Thanks again for your input. It’s greatly appreciated!

Cheers