Skip to content

Commit d0f9077

Browse files
calebdwAJenbo
authored andcommitted
feat(completion): array callable method completion
Add method name completion inside array callable strings. When the cursor is inside the method-name string of [Class::class, '|'] or [$obj, '|'], the LSP now offers method completions from the resolved class. Detection handles ::class constants, $this, typed variables, namespaced classes, whitespace variations, and unclosed strings. Completion reuses the standard member-completion builder so items have identical formatting to regular -> / :: member completions: label details, return type, deprecation tags, and data for lazy documentation resolve. Insert text is post-processed to strip snippet parentheses since we are inserting into a string literal. Works with both instance and static methods. Signed-off-by: Anders Jenbo <anders@jenbo.dk>
1 parent 9c304a5 commit d0f9077

6 files changed

Lines changed: 691 additions & 0 deletions

File tree

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- **Array-callable navigation.** Method-name strings in array callables — `[Controller::class, 'method']` and `[$object, 'method']` — now resolve like a real member reference. This makes go-to-definition, find-references, and rename work on Laravel controller actions such as `Route::get('/', [IndexPageController::class, 'indexPage'])`.
13+
- **Array-callable method completion.** Typing inside the method-name string of an array callable (`[Controller::class, '|']`) now offers method name completions from the resolved class, including inherited and trait methods. Works with `Class::class` constants, `$this`, and typed variables. (thanks @calebdw)
1314
- **Magic methods complete when implemented.** Magic methods declared on a class (`__invoke`, `__toString`, `__call`, and the rest) are now offered in member completion, so explicit calls like `$x->__invoke()` autocomplete and support go-to-definition. They are sorted below the regular methods so they never appear at the top of the list.
1415
- **Staleness detection and auto-refresh.** The class index, function index, and constant index now stay fresh automatically. When PHP files are created or deleted outside the editor (e.g. `git checkout`, code generation), the indices update without a restart, and edits made outside the editor are reflected the next time the file is used. When `composer.json` or `composer.lock` changes (e.g. after `composer install`), vendor packages are rescanned automatically.
1516
- **`#[ArrayShape]` attribute support.** Functions and methods annotated with `#[ArrayShape(["key" => "type", ...])]` (used by ~84 phpstorm-stubs entries) now produce array shape key completions, hover type info, and correct type resolution. Affects commonly used functions like `parse_url`, `stat`, `pathinfo`, `gc_status`, `getimagesize`, and `session_get_cookie_params`.

0 commit comments

Comments
 (0)