Working with Content Assist
The purpose of this tutorial is to teach you how to use Zend Studio's Content Assist function in order to write code quickly, easily, and accurately.
Purpose and Usage
The Content Assist feature enables the selection and insertion of existing code elements to complete partially entered code.
A list of possible code elements appears 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:
|
Reserved PHP Words |
|
Functions |
|
Templates |
|
Classes |
|
Interfaces |
|
Constants |
|
Variables (public) |
Content Assist works with the following elements: PHP Classes, Functions, Variables, Constants, Keywords, Interfaces, Attributes, Values, Nested Functions, Names and Syntax, as well as all user defined Classes, Functions, and Constants.
Note:
Content Assist works with both PHP and HTML.
Activating Content Assist
By default, the Content Assist options will be automatically displayed once the first few characters of the code have been entered.
|
|
|
The following procedure demonstrates using Content Assist:
|
"define()" appears on the edit line. |
Note:
If the Content Assist window does not open automatically,
place your cursor at the required location and press Ctrl+Space.
To enable the Content Assist window to open automatically, go to the Content Assist Preferences page, accessed
from Window | Preferences | PHP | Editor
| Content Assist and mark the 'Enable auto-activation' checkbox.
Function Parameter Hints
When entering a function call, a Function Parameter Hint box will be displayed detailing the types of parameters that should be entered within the parentheses of the function call.
|
|
|
The following procedure demonstrates using the Function Parameter Hint feature:
|
A function parameter hint box will be displayed indicating the types of parameters that should be inserted between the parentheses.
|
Making Content Assist Elements Available Within the Same Scope
Added Code - Available within the same function and file
Elements within the same scope (e.g. within the same project, file or function) will be available for use with Content Assist.
Variables belonging to different scopes are not available to each other via Content Assist.
Added Code - Available Within the Same Project
Code elements defined in one file are also available for use by other files within the same project.
|
|
|
The following steps demonstrate using Content Assist for inserting elements within the same project:
|
When the element is highlighted, Content Assist displays the original location of the code element, its value ('africa') and all other information available.
|
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.
|
|
|
To see and trial this feature:
<?php function getClass() { return new Test(); } class Test { function printValues($a, $b) { echo "Values: $a, $b"; } }
/* @var $myVar Test */ $myVar = getClass();
$myVar-> ?>
|
|
Note:
Without the comment, Content Assist will not be available for the function.
Configuring Content Assist
Content Assist options can be configured through the Content Assist Preferences page, accessible from Window | Preferences | PHP | Editor | Content Assist.
|
|
|
Related Links |
|
|