You are here:Home arrow Home arrow PHP arrow Code autocomplete for array objects (foreach)
  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • green color
  • blue color

Code autocomplete for array objects (foreach)

Saturday, 06 February 2010
Here is a quick tip on enabling code auto-completion on array of objects (i.e. when you fetch array of objects from a database table adapter).
Imagine you have a Users model which extends Zend_Db_Table_Abstract, and you assign that every row will be object of class User (which implements your application logic). Somewhere in code you will have: $usersList = $users->fetchAll();
foreach($usersList as $user) {
To get autocomplete for User's methods, simply add below foreach line:     /* @var $user User */
    // This will indicate your PHP IDE the class of the array item

Last Updated ( Saturday, 06 February 2010 )

Add comment

Security code

< Prev   Next >