NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
TIP: Type hints
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
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:
Code:
class Y {
   /**
   * @var SomeClassA it is an example1
   */
   public $anX;
   /**
   * @var SomeClassB it is an example2
   */
   public $anY;
}


ARGUMENTS:
Code:
/**
* 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:
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 used, type hint would not be required

VARIABLES:
Code:
/**
* @var SomeClassE
*/
$a->

// auto-defined:
$d = new SomeClassF();
$d->


If types are properly defined, code insight knows all to show correct code completion Smile


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.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
TIP: Type hints
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic