Navigating to Declaration or Type Declaration of a Symbol
While editing your source code, you might need to navigate to the location where a particular named code reference (a symbol) has been first declared. The
command enables you to navigate to the initial declaration of a symbol from its usage. The command enables you to navigate to the symbol's type declaration.Important note
- Applies source code symbols, CSS, HTML, or XML tags and attributes, DTD and schema elements and attributes, and references in comments.
- Does not apply to the primitive types.
To navigate to the symbol declaration
- Place the caret at the desired symbol in the editor.
- Do one of the following:
- On the main menu, choose .
- Press Ctrl+B.
- Click the middle mouse button.
-
Keeping Ctrl (⌘ for macOS) pressed, hover your mouse pointer over the symbol. When the symbol turns into a hyperlink, its declaration will be displayed in the tooltip. Click the hyperlink without releasing the key to open the declaration in the editor.
To navigate to the type declaration of a symbol
- Place the caret at the desired symbol in the editor.
- Do one of the following:
- On the main menu, choose .
- Press Ctrl+Shift+B.
-
Keeping Ctrl+Shift (⌘+⇧ for macOS) pressed, hover your mouse pointer over the symbol. When the symbol turns into a hyperlink, its type declaration will be displayed in the tooltip. Click the hyperlink without releasing the keys to open the type declaration of the symbol in the editor.
Example
Consider the following sample code fragment:
class C {}
class D {
public function f() {
return new C;
}
}
$a = new D;
$a->f();
- Invoking
$a
variable will move the caret toclass D
, since it is thea
variable's type. on the - Invoking
f
method call will move the caret toclass C
, which is thef
method's return type. on the - Invoking
f
method call will move the caret to thef
method's declaration withinclass D
. on the