2

in a Yii Application in PHPStorm i have the following Code:

$datasource = Yii::app()->someComponent;

PHPStorm is now not able to find the definition of method parameters in autocomplete, if i write

$datasource->aMethod(

Is there a way to tell phpstorm the source in order to have a working autocomplete?, e.g.

// @definition components/SomeComponent.php
$datasource = Yii::app()->someComponent;

Thanks,

markus

2 Answers 2

2

You could use a PHP Doc comment to tell PHPStorm which type the var has.

/** @var SomeClassName $datasource */
$datasource = Yii::app()->someComponent;
Sign up to request clarification or add additional context in comments.

Comments

1

There's better solution. One which makes PhpStorm able to assign Yii::app()->someComponent to class for entire project.

Put in CAplication's php doc (above class):

/**
 * @property Someclass $someComponent.
 */

Solved with one line of code. It works with PhpStorm 9.0, haven't tested earlier versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.