How can I get return type in php without @return in comment lines
Question
I am using Yii Framework with phpStorm ide for one of my php project.
$form = $this->beginWidget(
'CActiveForm', array(
'id' => 'form-id',
'enableAjaxValidation' => true,
'enableClientValidation' => true,
)
);
$form is an instance of CActiveForm after this call because of the first parameter of method. When I type
$form->
in ide it doesn't give parameter or method hints. So I need to tell the ide that $form's type is CActiveForm. I can't use comment @return because method's return type is changing by first parameter dynamically. I tried
$form = (CActiveForm) $this->beginWidget(...
But it didn't work. How can I get hint from the ide in this stiuation.
Solution
I don't know your IDE, but the phpDoc way to do this would be using @var
:
/** @var $form CActiveForm */
$form = $this->beginWidget(...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow