0

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
Positivity
  • 5,406
  • 6
  • 41
  • 61

1 Answers1

0

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.

Community
  • 1
  • 1
Edvard Rejthar
  • 1,245
  • 13
  • 14
  • I think I tried similar trick, BTW I'll try this again and check if it works. – Positivity Nov 07 '13 at 11:18
  • Note that there is difference if you are typehinting inside method (as I did - after the variable decalration) or a class attribute (in that case - the parenthesis should be above the attribute).. (If sth does not work, you may try /** , /*, @var, @param...) – Edvard Rejthar Nov 09 '13 at 00:59