PhpStorm 2018.2 Help

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 Navigate | Declaration command enables you to navigate to the initial declaration of a symbol from its usage. The Navigate | Type Declaration command enables you to navigate to the symbol's type declaration.

Important note

Navigate | Declaration/Type Declaration

  • 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

  1. Place the caret at the desired symbol in the editor.

  2. Do one of the following:
    • On the main menu, choose Navigate | Declaration.

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

      ps_viewDeclaration.png

To navigate to the type declaration of a symbol

  1. Place the caret at the desired symbol in the editor.

  2. Do one of the following:
    • On the main menu, choose Navigate | Type Declaration.

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

      ps_viewTypeDeclaration.png

Example

Consider the following sample code fragment:

class C {} class D { public function f() { return new C; } } $a = new D; $a->f();
  • Invoking Navigate | Type Declaration on the $a variable will move the caret to class D, since it is the a variable's type.

  • Invoking Navigate | Type Declaration on the f method call will move the caret to class C, which is the f method's return type.

  • Invoking Navigate | Declaration on the f method call will move the caret to the f method's declaration within class D.

Last modified: 2 November 2018

See Also

Procedures:

Concepts: