PHP Code completion is one of the most important feature that makes a differences between PHP Editor and true PHP IDE. PHP IDE autocomplete features in PhpED are often referred to as Code Insight. PHP Code completion in PhpED works in several ways:
- PHP Variables code completion provides the pop up menu with the list of the variables used in the script when the user starts typing new variable name
- PHP Function code completion provides the pop up menu with the list of available PHP functions, both built in and user-defined php functions, when the user starts typing a function name. Hints show you the arguments and returning value for a just typed function, as well as a short description for them.
- PHP class method code completion provides available properties and methods for a given variable or class, and automatically finishes partially typed keywords. Nested calls are supported with unlimited nesting level. Fast functions reference shows you all the PHP functions provided by the loaded PHP extensions.
|
|
|
- Code completion works for HTML and CSS as well. It shows the properties for tags, classes and attributes on dynamic pop-up menu
- PhpED code completion covers virtually all of PHP syntax constructs and objects, including closers, array's indexes, builtin functions like foreach and iterators
How to setup PHP Code Completion in PhpED Code Insight settings
You can configure how PHP and other languages Code completion work in PhpED using Tools->Settings Menu. Code Completion Configuration is controlled by two settings categories:
- Code Insight, available under Tools->Settings->IDE->Code Insight
- Autocorrection, available under Tools->Settings->Editor->Autocorrection
How to enable code complete for php objects with PhpED Code Autocorrection?
Autocorrection is a powerful productivity boosting part of Code Completion tools set - used for PHP code completion as well as any other language code completion.
Autocorrection will automatically replace the word/phrase that you type in the editor with the one you defined in Tools->Settings->Editor-> Autocorrection tab.
To create the Autocorrection set:
- Go to Tools->Settings->Editor-> Autocorrection and select Add button, as shown on the figure:
- Type in the expression you want to be auto corrected in the column Typed text
- Type in the expression you want to be placed instead of the Typed in the column Correct to.
- Make sure that Enabled box is checked and now, every time when you type the text from Typed text column and hit Enter or whitespace key, PHP IDE will automatically replace it with the corresponding Correct to text.
How to enable PHP IDE Autocomplete features for PHP classes - PHP Editor code completion for dynamic typing in PHP
PhpED PHP Code completion does the excellent job detecting which class instance is assigned to a variable.
That means that all corresponding class properties, constants and methods will be shown in the PHP IDE autocomplete code completion popup menu.
However, due to the dynamic assignments of the types in PHP Code Insight can not always detect the content of the variable prior to the run time. If that happens the IDE display the following warning:
"Code completion is not available due to the following error(s):
Failed to identify type of "XXX" variable"
PhpED introduced the PHP editor code completion "type hints" - the helpers, which serve two purposes:
- Enable PHP code completion for the situations when the type of the variable or class instance can not be readily defined
- Encourage proper use of PHP Documentation Starting with version 4 PHPED
|
|
|
PhpED expects certain syntax constructs to be in place in PHPDoc in order to help Code Insight with identifying correct type info of variables and properties. This PHPDoc syntax constructs are explained here. The example of how PHP IDE autocomplete works with Type Hints is shown below
Nusphere PhpED's PHP Code Completion and Code Insight parse the files included in PhpED project to build the database of classes and functions definitions. IN some cases these definitions might be missing for PHP built-in classes. Using PHP Code Completion Helper script helps to fix that problem easily.
In this tutorial you learned about the many features of the PHP Code Completion and how to use them to code PHP faster. Additional technical information is available from the NuSphere Forum. Download a free trial of our PHP IDE with PHP Code completion today!
|