Type casting in PHP supported by NetBeans

A trick which can be helpful to some while trying to use intellisense in NetBeans for coding in php.

You can define a class as follows with a public static function called parse and documented to return object of type User.

class User{
/**
* @return User
*/
public static function parse($object){
return $object;
}
}

How you use it:

$object = $connectionManager->getTable('User')->find(2232);
$user = User::parse($object);

//here you can access the function of user class using intellisense feature of Netbeans.

I am not sure might be helpful to some, I personally love this trick. If you have a better suggestion please feel free to comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>