Casting class variables in PHP / Symfony / Netbeans

Whenever I need to use Netbeans intelligence to display properties / methods, I explicitly declare a new object and then re-reference it. Sort of..

$moo = new Cow(); $moo = Cow::getById(1); $hasMilk = $moo->hasMilk(); 

Is there a way to avoid this by entering the type of the variable when it is received? Or at least a hack to trick Netbeans?

Thanks!

PS: the main reason for solving this is something, if I forgot to comment on line 1, and when obj is not found, it works with a fresh object !: (

+4
source share
2 answers
 $moo = Cow::getById(1); /* @var $moo Cow */ 

this will tell netbeans that $ moo is an object of type Cow

+7
source

Type vdoc and click on the tab. In the comment that appears, enter the class name.

+1
source

All Articles