 |
PHPDoc for PHP Type Hints
|
|
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;
}
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) {
}
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:
|
 |

click to enlarge
|
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.
|
|
 |
Download NuSphere PHP IDE
Download a free trial of the fast PHP EDitor and robust Integrated Development Environment for PHP.
|
Buy NuSphere PhpED® now
|
"To be honest its bloody awesome, I have looked at loads of PHP editors and this is THE only one that actual works straight out of the box!!! Brilliant, well done."
Andrew Breward, Director of Technology caboodal.com
|
Guide
|
Special Team4 Offer
|
 |
Get 4 copies of PhpED for the price of 3!
Optimum solution for development teams.
|
|
Need more than 4 licenses? Contact Us for more quantity discounts, please use "Ordering/Payment issue" subject on the form.
|
|
Dr. Dobb's
Dr. Dobb's Magazine covers NuSphere PhpED in New and Noteworthy section.
|
InfoWorld

PhpED is a proper, world-class IDE for PHP code. It is the only IDE worth considering if PHP development is your primary job
|
|