rob-revisited/docs/ide/php.md

31 lines
1.7 KiB
Markdown

# PHP code intelligence
The IDE analyses every PHP file of the project (and the libraries of `vendor/` when needed) with nikic/php-parser, a little at each
frame, and keeps a cache: the index is ready a few seconds after a project opens. **Tools > Rebuild the PHP Index** starts again.
## Completion
Completion follows types: `$this->engine->config->`, return types, `@var`, `@property`, `@method`, generics (`list<Foo>`,
`@template`, `class-string<T>`), `foreach` over collections, array shapes and their keys. It knows the libraries' classes and
functions (`use` lines added for you), PHP's own classes and the extensions' stubs.
In JumPHP projects it also completes `config/project.yaml`, `input.yaml`, `services.yaml`, `lang.yaml`, forms, the game's texts in
`t('…')` and its actions in `isPressed('…')`.
## Navigate and refactor
- Go to declaration (`Ctrl+B`), implementations (`Ctrl+Alt+B`), find usages (`Alt+F7`), quick documentation (`Ctrl+Q`),
parameter hints (`Ctrl+P`), the symbol under the cursor highlighted.
- **Rename** (`Shift+F6`): classes (the file too), methods, properties, constants, variables.
- **Structure** (`Alt+7`, `Ctrl+F12`): the outline of the file.
- **Hierarchy** (`Ctrl+H`): the ancestors of a class and the classes under it.
- **Calls** (`Ctrl+Alt+H`): who calls a method, grouped by caller and unfolded up the chain. A **↳ N calls** line above each method
opens it.
## Problems
Syntax errors, unknown classes, methods and functions are underlined as you type and listed in **Problems** (`Alt+6`).
## Play from the code
A `src/Scene/*.php` has a green ▶ (`Ctrl+Shift+F10`): the game starts in that scene. A test file runs its tests ([Tests](tests.md)).