In most cases, PhpED CodeInsight engine works excellent on detecting what class instance is supposed to be in a variable.
It means that all corresponding class properties, constants and methods will be shown fine in the code completion popup.
Yet, there are some situation when Code Insight can not determine type and shows something like this:
"Code completion is not available due to the following error(s):
Failed to identify type of "XXX" variable"
Starting with version 4 PHPED supports the following syntax to help CodeInsight with identifying correct
type info of variables and properties:
PROPERTIES:
class Y {
/**
* @var SomeClassA it is an example1
*/
public $anX;
/**
* @var SomeClassB it is an example2
*/
public $anY;
} |
ARGUMENTS:
/**
* example of basic @param usage
* @param SomeClassC $bax some comments may follow...
* @param SomeClassD $bay some other comments may follow...
*/
function function1($bax, $bay) {
}
// php5 way is supported too:
function function1(SomeClassC $bax, SomeClassD $bay) {
}
|
RETURNING VALUES:
/**
* 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 used, type hint would not be required
VARIABLES:
/**
* @var SomeClassE
*/
$a->
// auto-defined:
$d = new SomeClassF();
$d->
|
If types are properly defined, code insight knows all to show correct code completion
NOTE: If you use .php file extension, PLEASE MAKE SURE that it is associlated 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.