Skip to content

Fix union types for @param-closure-this tags - #444

Open
ace-of-aces wants to merge 1 commit into
PHPantom-dev:mainfrom
ace-of-aces:fix-param-closure-this-unions
Open

Fix union types for @param-closure-this tags#444
ace-of-aces wants to merge 1 commit into
PHPantom-dev:mainfrom
ace-of-aces:fix-param-closure-this-unions

Conversation

@ace-of-aces

Copy link
Copy Markdown

Note

The code in this PR was written and reviewed by AI (GPT-6 Astra). I am not really proficient in Rust, but I tested the outcome and read through the code and tests.

Fixes union types in @param-closure-this: an annotation such as FirstContext|SecondContext previously failed to resolve the closure's $this binding. This fixes the same issue that existed in Intelephense #3512.

Closure bindings now resolve through the shared type engine and retain all class alternatives. The forward walker installs the binding before applying type guards, preserving narrowing in nested callbacks while allowing explicit rebinding. Call resolution also carries the alternatives through $this, self::, and static:: chains, with hover and navigation reflecting the union.

Adds regression tests for resolution, narrowing, diagnostics, hover, and navigation, plus a working demo with runtime assertions.

Screenshot of a working example

Screenshot 2026-09-13 at 13 43 15

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, examples/)
  • I have updated the config schema (config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    an eye towards deleting anything that is irrelevant, clarifying anything
    that is confusing, and adding details that are relevant. This includes,
    for example, commit descriptions, PR descriptions, and code comments.

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.

1 participant