Content Assist

The Content 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.

code_assist_triangle.png

Reserved PHP Words

code_assist_circle.png

Functions

template_icon.png

Templates

classes_icon.png

Classes

interfaces_icon.png

Interfaces

constants_icon.png

Constants

variables_icon.png

Variables (public)

php_file_icon.png

PHP File Include Call

namespace_icon.png

Namespaces (PHP 5.3)

package_icon.png

Packages

 

Content 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:

Content 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.

Content Assist in PHPDoc Block

Content Assist provides proposals for the PHPDoc tags:

 

 

Usage Example

Example:

Function Parameter Hint

 

 

Templated Content Assist

Applying Content Assist proposals to the editor creates a templated expression that provides argument completion according to the declaration of the method. Templated Content Assist helps you edit your method parameters quicker.

 

 

Usage Example

Example:

Function Parameter Hint

 

 

Using elements within the same scope

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

Usage Example

Examples:

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

  • Elements defined within one file will be available in the Content 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:

Function Parameter Hint

 

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 content assist of this variable accordingly.

 

 

Usage Example

Example:

code_assist_class_type_hint_example.png

Note:    

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

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

To assign a variable its class value using a comment:

  1. Create your function and assign variables to it.

  2. Enter a comment in the form:

/* @var $"new variable" "Class name" */

Content Assist for Magic Members

PDT supports Content 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:

magic_members_example.png

 

Camel Case Matches

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

 

 

Usage Example

Example:

code_assist_cc_example.png

Note:   

Camel Case matching is case sensitive.

Configuring Content Assist

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

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

 

 

link_icon.png

Related Links:

Working with Content Assist

Using ContentAssist

Content Assist Preferences

Hover Support

Commenting PHP DocBlocks

Using Templates