Basic code completion helps you complete the names of classes, methods, and keywords within the visibility scope. When you invoke code completion, PhpStorm analyses the context and suggests the choices that are reachable from the current position of the caret.
If basic code completion is applied to a part of a parameter, or variable declaration, PhpStorm suggests a list of possible names with regard to the type of the item.
PhpStorm recognizes variables declared in PHP-specific ways, for example, as parameters in function calls or defined by reference argument.
Code completion covers supported file types and custom file types. However, PhpStorm does not recognize the structure of custom file types and suggests completion options regardless of whether a specific type is appropriate in the current context.
- Type a name or a part of a name.
While typing, use the following techniques:
Narrow down the suggestion
list by typing
any part of a word, even the characters somewhere in the middle, or invoking code
after a dot separator. PhpStorm will show suggestion list
that includes occurrences with all the possible positions of the entered characters.
This makes the use of the asterisk wildcard unnecessary:
- In case of CamelCase or snake_case names, type the initial letters only. So doing, PhpStorm automatically recognizes and matches the initial letters.
- Narrow down the suggestion list by typing any part of a word, even the characters somewhere in the middle, or invoking code completion after a dot separator. PhpStorm will show suggestion list that includes occurrences with all the possible positions of the entered characters.
- Do one of the following:
- On the main menu, choose .
- Press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space.
The image below shows a suggestion list containing a variable name:
The image below shows a suggestion list containing keywords:
If necessary, press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space for the second time.
This action produces the same effect as pressing Ctrl+Alt+SpaceCtrl+Alt+SpaceCtrl+Alt+SpaceCtrl+Alt+SpaceCtrl+Alt+SpaceCtrl+Alt+SpaceCtrl+Alt+Space or Ctrl+Alt+Back SlashCtrl+Alt+SpaceControl Alt SpaceControl Alt SpaceControl Alt Space.
- Select the desired class from the suggestion list, and do one of the following:
- Press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter or double-click the desired choice .
- Press TabTabTabTabTabTabTabTabTabTabTab .
- The option Autocomplete common prefix ( ) makes PhpStorm look for common prefixes and automatically complete them in the editor. This feature is useful for classes with numerous similar-named members.
- If a suggestion list shows n variants of a class, type a dot, and the next suggestion list after dot will show all the possible qualified names of the members. After selecting the desired one, import statement will be added automatically.
- Suggestion list includes literals, already defined in a file.