Search code examples
phpnetbeanscode-hinting

Add Dynamic @return code hinting in Netbeans php


I have a ->load() method that includes and returns given class name. So it can return different data types. Can I enable any kind of code hinting in netbeans?

$msg = $this->load('message');
$msg-> // hinting should list message class methods

$usr = $this->load('user');
$usr-> // hinting should list user class methods

Solution

  • Similar question has been answered here: Dynamic return type with type hint in PHP?

    any kind of code hinting

    Yes, try this.

    $usr = $this->load('user');/* @var $usr user */
    

    You may wanna use shortcut "vdoc" and press {tab} in the code to generate the type-hinting comment.