Code Assist

The Code Assist feature enables the selection and insertion of existing code elements to complete partially entered code.

A list of possible code elements is displayed in relevant locations within your files according to the context of your cursor, which you can then select to be automatically entered into your code.

Each type of code element will have a unique icon. See PHP Icons for a description of each of the icons.

Reserved PHP Words

Functions

Templates

Classes

Interfaces

Constants

Variables (public)

PHP File Include Call

Namespaces (PHP 5.3)

Packages

 

Code Assist works with the following elements: PHP Classes, Functions, Variables, Constants, Keywords, Interfaces, attributes, values, nested functions, names, syntax and include calls, as well as all user defined Classes, Functions and Constants.

Note:

Code Assist will also be available for JavaScript elements if JavaScript support was enabled for the project. See Enabling JavaScript Support in PHP Projects for more information.

Using elements within the same scope

Elements within the same active project, file or function will be available for use with Code Assist.

Usage Example

Examples:

  • Variables within a function will be added to the Code Assist list when the cursor is within that function.

  • Elements defined within one file will be available in the Code Assist menu in other files within the same project.

 

Function Parameter Hints

When entering a function call, a Function Parameter Hint box will be displayed detailing the types of parameters which should be entered within the parentheses of the function call.

 

 

Usage Example

Example:

 

If the Function Parameter Hint box is not displayed automatically, place your cursor between the parentheses and press Ctrl+Shift+Space.

Class Type Hints

By using a comment you can assign a variable its exact class value. This assignment will affect the code assist of this variable accordingly.

 

 

Usage Example

Example:

Note:    

Without the comment, code assist will not be available for the function.

Code Assist for Magic Members

PDT supports code assist options for 'magic members'. These are properties and methods which were declared using the @property or @method tags within PHP DocBlock comments rather than in the PHP script itself.

See http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.property.pkg.html for more information on magic members.

 

 

Usage Example

Example:

 

Camel Case Matches

Code assist supports camel case matches when entering code, which displays code assist options based on an element's initials.

 

 

Usage Example

Example:

Note:   

Camel Case matching is case sensitive.

Namespaces

When the PHP executable used for the project is set to version 5.3, code assist is available for namespaces.

Namespace elements are represented by the Namespace icon .

 

 

Usage Example

Example:

 

Configuring Code Assist

To configure PHP Code Assist options, go to the Code Assist Preferences page, accessible from Window | Preferences | PHP | Editor | Code Assist.

To configure JavaScript Code Assist options, go to the JavaScript Content Assist Preferences page, accessible from Window | Preferences | JavaScript | Editor | Content Assist.

 

 

Related Links

Related Links:

Working with Code Assist

Using Code Assist

Code Assist Preferences

Hover Support

Commenting PHP DocBlocks

Using Templates