Behaviors and IDE code analysis

Hi,

Presuming this is a "Crazy" model class:


public function behaviors()

{

    return array_merge(parent::behaviors(),

    [

        'crazy' => [

            'class' => '\namespace\CrazyBehavior',

        ],

    ]);

}

Now somewhere else:


$model = new \models\Crazy();

$crazyValue = $model->crazyBehaviorMethod($someParam);

The problem is that for PHPStorm ‘crazyBehaviorMethod’ is ‘not found’ in Crazy model and remains highlighted due to code-analysis warning.

Any idea how to overcome?

Thanks ahead!

@method tags work in most (probably all) IDEs.

Yeap - but this requires manually copy/paste all public methods annotations from a behavior to each and every model using it - a bit confusing IMHO. :-/

Can you use a Trait instead? I find traits easier unless there’s a specific reason to use behaviors.