eh1160 eh1160 - 3 months ago 11
PHP Question

Netbeans Code Complete not activating when looping through array of objects

In my Netbeans PHP projects, I recently started stuffing custom objects into arrays in order to increase performance. I found its much faster to query the database and get a bunch of objects all at once instead of querying over and over again.

I love the new approach, except when I loop through the array and try to access each of the objects, Netbeans doesn't know that the items in the array are actually objects. Try to following example code, for instance:

foreach ($arrAccounts as $objAccount) {
echo ( $objAccount->get_name() . " - " . $objAccount->get_type() );
...

}


When I type "$objAccount->", Netbeans doesn't recognize that it is a custom Account class.

Answer

inside the loop add vdoc and enter classname of the $objAccount

Shortcut = [vdoc + tab]

foreach ($arrAccounts as $objAccount) {
    /* @var $objAccount ClassName */
    ...
}
Comments