Skip to content

LSP rename: magic and implicitly-called interface methods are renamed without their callers #521

Description

@blacktrs

Problem

Renaming __construct, __invoke, __toString or an interface method that PHP calls implicitly (offsetGet, offsetSet, current, key, next, count, getIterator, jsonSerialize) edits the declaration and the sites that spell the name, but not the implicit callers (new Foo(), $f(), $a[..], casts, foreach). Member references miss them for the same reason, and the member-name filter used when searching closed files skips files that only call the method implicitly.

Proposed fix

Add a rename blocker for __* names and for the methods of PHP's built-in interfaces (ArrayAccess, Iterator, IteratorAggregate, Countable, JsonSerializable, Stringable) when the class implements them. References should either list the implicit sites or say they may be incomplete.

Acceptance

  • Rename of each of these is refused with a clear message.
  • Test at the Workspace level (renameBlockers) and at the LSP level.

Found in the final review of the LSP server (P3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions