Skip to content

feat(symfony): add events and Messenger intelligence - #402

Open
sidux wants to merge 48 commits into
PHPantom-dev:mainfrom
sidux:feat/symfony-events-messenger-intelligence
Open

sidux wants to merge 48 commits into
PHPantom-dev:mainfrom
sidux:feat/symfony-events-messenger-intelligence

Conversation

@sidux

@sidux sidux commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • read final Symfony event-listener wiring from generated container PHP without loading or executing it
  • make publisher and subscriber attributes declarative through .phpantom.toml
  • navigate events, messages, handlers, and Messenger buses across PHP and Symfony resources
  • expose publisher → event → subscriber relationships through standard LSP Call Hierarchy nodes
  • index Messenger class mappings for constant-time candidate lookup by class

Why

Event names and Messenger mappings are runtime/framework metadata spread across PHP attributes, service configuration, and the compiled container. Static container inspection recovers the final listener wiring without executing application code, while configurable attribute rules avoid hardcoding application packages. Both the container and the attributes name the real classes (a proxy factory is handed the real class), so navigation lands on application code, and synthetic event nodes preserve the standard editor Call Hierarchy experience instead of introducing a custom protocol.

Dependencies

Validation

  • focused Symfony event, Messenger, and Call Hierarchy tests
  • cargo clippy --fix --allow-dirty -- -D warnings
  • cargo fmt
  • cargo test --all-targets on the rebuilt Symfony head

@codecov-commenter

codecov-commenter commented Aug 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 86.11374% with 586 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/code_lens.rs 86.17% 119 Missing ⚠️
src/symfony/events.rs 91.63% 117 Missing ⚠️
src/symfony/container.rs 73.72% 108 Missing ⚠️
src/completion/symfony.rs 83.39% 92 Missing ⚠️
src/rename/prepare.rs 79.04% 35 Missing ⚠️
src/references/member_scope.rs 91.14% 24 Missing ⚠️
src/backend/documents.rs 48.83% 22 Missing ⚠️
src/indexing/watch.rs 78.57% 21 Missing ⚠️
src/references/dispatch.rs 67.74% 20 Missing ⚠️
src/definition/resolve.rs 84.28% 11 Missing ⚠️
... and 5 more

📢 Thoughts on this report? Let us know!

@AJenbo AJenbo added this to the Sprint 8 milestone Aug 27, 2026
@sidux sidux mentioned this pull request Aug 27, 2026
6 tasks
sidux added 7 commits August 30, 2026 17:12
Use the coarse reference index for conclusive zero counts and cache bounded exact member locations for non-zero lenses. Refresh-capable clients avoid eager resolve storms while older clients retain lazy resolution.
Stop reference counts and CodeLens resolves from repeating the full workspace walk for every declaration. Internal annotation requests share the initial index, including callers queued behind it, while an explicit Find References command keeps its single refresh for files created without watcher notifications.
@sidux
sidux force-pushed the feat/symfony-events-messenger-intelligence branch from 69e4f02 to 2b619aa Compare August 30, 2026 15:33
sidux added 18 commits August 30, 2026 17:40
Resolve fully-qualified classes and Class::member references from arbitrary YAML and XML positions without schema-specific rules.
Feed schema-free class and member occurrences into Find References and CodeLens, including transparent-proxy metadata aliases.
Index semantic framework relationships alongside generic YAML and XML class references.
Pass every indexed target to editor-native navigation and ignore empty PHP resource strings.
Generic YAML and XML navigation now returns early only when it resolves a PHP symbol. Otherwise the semantic Symfony resolver still handles aliases, form fields, validation mappings, and configuration keys.
Build entity-to-repository pairs alongside the framework resource index and update them per URI. CodeLens and reference lookups now read the derived index instead of reopening and rescanning every YAML/XML resource for each declaration.
Discover opt-in generated subclasses by path and marker interface, then canonicalize external metadata without changing PHP type resolution.
Reuse the existing definition and reference pipelines for standard incoming and outgoing call navigation.
sidux added 3 commits August 30, 2026 17:41
Model publishers, events, and subscribers through standard LSP call hierarchy nodes, canonicalizing configured proxy owners before matching.
@sidux
sidux force-pushed the feat/symfony-events-messenger-intelligence branch from 2b619aa to 596c503 Compare August 30, 2026 15:54
sidux and others added 6 commits September 28, 2026 10:27
The reference CodeLens and YAML/XML navigation this branch was built on
landed upstream (PHPantom-dev#392, PHPantom-dev#394) and were reworked there, so this applies
only the branch's own changes on top of main.

- Member-scope resolution moved to references/member_scope.rs; the
  Doctrine getRepository() receiver resolution now lives there, using
  the namespace-aware use map, and framework member lookups filter
  through MemberScope.
- Document open/change/close and startup indexing moved to
  backend/documents.rs and backend/startup.rs; the framework resource
  index hooks follow them. YAML/XML watchers already exist upstream.
- Code lenses use the request's LineIndex; the framework method lens
  skips methods no resource names and builds its class scope once.
- Rename keeps working across file types: YAML/XML class and namespace
  occurrences are rewritten by the framework index in each document's
  own spelling and verified one by one, so an escaped name can no longer
  cancel a rename. A rename started in a resource renames the PHP
  declaration it names.
- Fix namespace segment indexing for escaped (App\\Domain) and rooted
  (\App\Domain) spellings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntainer-intelligence

Brings in main through the updated framework-resource-navigation branch.

- Symfony PHP configurator strings join the cross-file-type rename: a
  position with no PHP symbol falls back to the framework index, class
  searches for a rename leave framework locations to the index, and
  the index skips occurrences the PHP rename already edits
  (`Foo::class`), so no edit is written twice.
- Service and parameter renames keep their own escaping-aware edits.
- Keep upstream's rule that a doubled backslash is not a valid new
  name; escaping is applied per occurrence instead.
- Framework Symfony symbol locations use a per-file line index and the
  shared de-duplicating sort; the Symfony resource lens uses the
  request's line index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oute-intelligence

Brings in main through the updated service-container branch.

- Route parameters rename through the framework index like service ids.
- Twig templates became framework resources here, so the document
  lifecycle indexes YAML, XML, and Twig alike without parsing them as
  PHP, and `*.twig` is now watched so a template changed on disk is
  re-indexed.
- Framework symbol and route-parameter lookups share one location
  helper built on a per-file line index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-intelligence

Brings in main through the updated route-intelligence branch.

- Opening or editing a framework resource schedules its diagnostics in
  the moved document handlers, after the off-loop re-index commits.
- Template names stay out of rename.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lation-intelligence

Brings in main through the updated Twig-template branch. Translation
keys stay out of rename, and translation lookups share the framework
location helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…messenger-intelligence

Brings in main through the updated translation branch. Call hierarchy
already landed upstream (PHPantom-dev#413), so only the proxy and events commits
are applied on top of it.

- Transparent proxies: in YAML/XML a proxy name counts as a reference to
  its real class inside upstream's reworked class search; proxy and
  compiled-container paths are recognised before the watcher's exclusion
  filter, since both usually live in ignored cache directories; startup
  indexing moved to backend/startup.rs.
- Event calls join upstream's cached call-hierarchy resolution; event
  definitions and references run after the workspace index is ready.
- Messenger handler lookups share the framework location helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Service-proxy and Doctrine proxies are created at runtime, and every
input the event features read names the real class: the compiled
container records the class it hands to the proxy factory, and the
configured #[Event]/#[Listen] rules live on the real methods. The
proxy-to-real-class relation had nothing to feed it, so remove it
along with the [[php.proxies]] setting.
- Skip vendor/var/cache directories relative to the workspace root, so a
  project that itself lives under /var/www or a temp directory is still
  indexed.
- Convert framework reference offsets through one line index per file
  instead of rescanning the file for every reference.
- Let the type engine answer a member receiver first; the getRepository()
  shortcut only applies when it knows nothing or only Doctrine's generic
  repository, and only reads assignments inside the enclosing function.
- Treat a class as a Doctrine repository only when it extends or
  implements one of Doctrine's repository types, so a project's own
  UserRepository gets no Doctrine lenses, and look repositories and
  entities up by convention and the inheritance index instead of scanning
  every indexed class on each lens request.
…ntainer-intelligence

Brings in the resource indexing and Doctrine lookup fixes. The PHP
configuration paths this branch indexes get the same workspace-relative
skip check, and a `config` directory above the workspace no longer makes
every PHP file look like configuration.

Symfony diagnostics now gather every declared name in one pass over the
framework index, and only for a file that uses one, instead of scanning
the whole index once per symbol kind. Declared names are de-duplicated
through a hash set rather than a linear search per name.
…oute-intelligence

Route declarations are checked through the single-pass declared-name lookup.
…-intelligence

Template declarations are checked through the single-pass declared-name lookup.
…lation-intelligence

Brings in the resource indexing, Doctrine, and diagnostics fixes. The
translation catalogs this branch indexes get the workspace-relative path
checks, and translation usages open the single-pass declared-name lookup.

XLIFF catalogs are now watched alongside YAML, XML, and Twig, so a key
added on disk while the catalog is closed is known without a restart.
…messenger-intelligence

Brings in the resource indexing, Doctrine, diagnostics, and XLIFF watching fixes. Event and bus declarations are checked through the single-pass declared-name lookup.
Refreshing a file's event sites on every parse cloned the whole
configuration and took the event index's write lock even in projects
with no publisher or subscriber rules, where there is nothing to scan.
Check the rules under the configuration lock and only take the write
lock when a previous rule set left sites to drop.

Pass the attributed method to the publisher and subscriber scanners as
one value instead of eight arguments, which removes the clippy allows.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants