Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type casting of class variables in PHP/Symfony/Netbeans

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

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

Is there a way I can avoid this by type-casting the variable when getting it? Or atleast a hack to fool Netbeans?

Thanks!

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

like image 467
Prasad Avatar asked Feb 27 '23 13:02

Prasad


1 Answers

$moo = Cow::getById(1); /* @var $moo Cow */

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

like image 76
Maerlyn Avatar answered Mar 10 '23 23:03

Maerlyn