You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rename): handle variables in dynamic property selectors
Dynamic property selectors like `$message->{$attribute}` were only
partially
walked. The scope collector skipped selector expressions when tracking
local
variable reads, which caused false `unused_variable` diagnostics for the
selector variable.
The symbol map extractor also ignored non-identifier property selectors,
so
find-references and rename missed variable occurrences inside dynamic
property
accesses. Renaming `$attribute` updated plain variable uses but not the
selector inside `$message->{$attribute}`.
Walk selector expressions during scope collection and emit variable
symbol
spans for dynamic property selectors in the symbol map. Add regression
tests
covering unused-variable diagnostics, references, and rename behavior
for this
pattern.
Signed-off-by: Anders Jenbo <anders@jenbo.dk>
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
53
53
-**Go-to-definition, rename, and highlight accuracy.** References in `@see` tags to qualified names like `App\Foo::bar()` now land on the correct location, and renaming a property selects the whole `$name` instead of `$nam`.
54
54
-**`@phpstan-require-extends` and `@phpstan-require-implements` navigation.** Class and interface names in these trait constraint tags now support go-to-definition and hover, and an import used only by such a tag is no longer flagged as unused. Contributed by @calebdw in https://github.com/PHPantom-dev/phpantom_lsp/pull/172.
55
55
-**Renaming variables captured by nested closures and arrow functions.** Renaming or finding references to a variable used inside deeply nested arrow functions (`fn () => fn () => $var`) or closures with `use ($var)` now updates every occurrence, whether the rename is triggered on the declaration or from deep inside the nesting. Contributed by @calebdw in https://github.com/AJenbo/phpantom_lsp/pull/145.
56
+
-**Variables inside dynamic property accesses are tracked.** A variable used as a dynamic property selector (`$message->{$attribute}`) now counts as a use, so it is no longer wrongly reported as unused, find-references includes it, and renaming the variable updates the selector along with its other occurrences. Contributed by @calebdw in https://github.com/PHPantom-dev/phpantom_lsp/pull/174.
56
57
-**Member rename stays scoped to the declaration it targets.** Renaming a method or property no longer touches same-named members on unrelated classes. A private method rename updates only that method and its real usages, calls on a receiver whose type cannot be resolved are left alone, renaming one implementation of an interface no longer renames sibling implementations, and renaming a child override stays on the child branch. Renaming a parent or interface declaration still updates the inherited overrides and implemented usages. Contributed by @calebdw in https://github.com/PHPantom-dev/phpantom_lsp/pull/160.
57
58
-**Find references on a constructor lists every call site.** Finding references to a `__construct` declaration now reports the `new ClassName(...)` instantiations, `#[ClassName(...)]` attribute usages, and explicit delegation calls written as `parent::__construct()`, `self::__construct()`, or `Class::__construct()`, including for subclasses that inherit the constructor (and excluding subclasses that override it). Attribute classes that are never written as `new` are now found. Contributed by @RemcoSmitsDev in https://github.com/AJenbo/phpantom_lsp/pull/155.
58
59
-**Positions on lines with multibyte characters.** Signature help, go-to-definition on virtual properties, named-argument completion, unused-import removal, and the `@phpstan-ignore` quickfix placed cursors and edits at the wrong column on lines containing multibyte characters; they now use the correct UTF-16 columns. Type strings containing `*` wildcards or variance annotations are also no longer mangled.
0 commit comments