PhpED's PHP Code completion feature set is unique because of its ability to take the advantage of PHP Type Hints defined in PHPDoc comments.
PhpED expects certain syntax to be placed in PHPDoc comments in order to provide Code Insight (PHP IDE autocomplete features) with the information about the correct type of variables and properties. This syntax constructs are explained below.
PHP Class PROPERTIES:
Code:
class Y {
/**
* @var SomeClassA this is to tell CODE INSIGHT that this is SomeClassA instance
*/
public $ $ynSomeClassA;
/**
* @var SomeClassB this is to tell CODE INSIGHT that this is SomeClassB instance
*/
public $ $ynSomeClassB;
}
This PHPDoc syntax is illustrated here:
|
|
|
PHP Function ARGUMENTS:
Code:
/**
* example of basic @param usage
* @param SomeClassA $bA some comments may follow...
* @param SomeClassB $bB some other comments may follow...
*/
function function1($bA, $bB) {
}
// php5 syntax is also supported:
function function1(SomeClassA $bA, param SomeClassB $bB) {
}
This PHPDoc PHP code completion syntax is illustrated here:
|
|
|
RETURN VALUES:
Code:
/**
* example of basic @returns usage
* @returns SomeClassA some comments may follow...
*/
function function1() {
$v[0] = new SomeClassA();
return $v[0];
}
note: in case if simple variable was returned, type hint would not be required
PHP VARIABLES:
Code:
/**
* @var SomeClassA
*/
$a->
// auto-defined:
$d = new SomeClassA();
$d->
This PHP code completion syntax for class instance variables return value is illustrated here:
|
|
|
When PHP types are defined in PHPDoc with these syntax conventions, PHP Code completion will work fine for the PHP variables displaying the methods corresponding to the types if the classes expected in these php variables.
NOTE: If you use .php file extension, PLEASE MAKE SURE that it is associated with appropriate php version in Tools->Settings->File Associations. If you develop php5 code, .php extension must be included in to the PHP5 list and removed from PHP4.
|