Defining a variable type in Netbeans PHP

I found a way to tell the type of the netbeans variable like this:

/* @var $variablename Type */ 

However, in this case there are no hints (the database is my class):

  //model.php abstract class Model { /* @var $db Database */ protected $db; (...) } //Mymodel.php class MyModel extends Model { (...) $this->db-> //no hints (...) } 

Is Netbeans a limitation, or rather, my mistake?

+6
source share
2 answers

First of all, first determine the type of the variable, for example:

 /* @var Database $db This is my Database object */ 

And secondly, I would suggest using phpdoc comments, for example:

 class Model { /** * @var Database $db This is my Database object */ protected $db; 

There should be no problems ...

+4
source

NetBeans can use two similar, but different comment annotations:

  • Good old phpdoc to block comments starting with /** and placed immediately before the element definition:

     /** * @var Database $db Database connection instance */ protected $db; 
  • variable type inline comments starting with /* and placed somewhere before using the element:

     $foo = $this->db; /* @var $foo Database*/ $foo->... 

The second type is useful when docblock comments are either not available or not useful, for example. you are using a third-party library that is not documented, or your variable type cannot be tracked automatically.

You basically used the syntax for # 2 in context for # 1; -)

+8
source

All Articles