Skip to content

Decide what a member access is in one place - #882

Merged
Firehed merged 24 commits into
mainfrom
member-access-one-owner
Oct 29, 2026
Merged

Firehed merged 24 commits into
mainfrom
member-access-one-owner

Conversation

@Firehed

@Firehed Firehed commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What a member access is now has one owner, the new MemberAccess data type. It holds which syntax nodes are member accesses, what each is accessed on, its member name, and its kind (->, ::, parent::, or :: after an expression). ExpressionResolverInterface::memberTarget() takes a MemberAccess and is the one place that resolves it: the type it is on, the class-like it is written in, and what static names.

Routes removed

  • PositionLocator and ExpressionResolver each listed the member access node classes and read ->var or ->class themselves. Both now go through MemberAccess::of().
  • SymbolAtPosition found the access a member name belongs to by walking up from the name, although Located already carries it. It now reads Located::$access.
  • PositionLocator split Slot::Member from Slot::StaticMember by node class. Neither consumer used the difference, so they are one slot.
  • ExpectedAtPosition::memberAccess decided the kind three ways: from the slot, from whether the receiver was a Name, and from whether static was set.
  • resolveStaticCall, resolveStaticPropertyFetch and resolveClassConstFetch each rejected an expression before ::. That is now MemberAccess::kind() returning null. The five per-node resolve* methods are folded into one resolveMember.
  • memberTarget used "the receiver is a Name" in place of "this is a :: access".
  • Scope::staticFor decided parent::.
  • MemberTarget::$static duplicated the kind. It is now MemberTarget::static(), derived from kind.
  • MemberAccessContext copied type, from and static, and its three named constructors restated the kind. It now holds the MemberTarget and the typed prefix, and reads its completion rules from kind.
  • Constructor lookups (new X, #[X]) went through memberTarget as if they were X:: accesses. They now look up __construct directly.

Behavior

No user-visible change.
One internal difference: new parent() no longer passes the calling class as static to the constructor lookup. PHP creates a parent instance there, so static is the parent. Constructors cannot use static in their types, so nothing shows.

Not in this PR

Notes for reviewers

  • resolveMember still picks the lookup (method, property, or constant and enum case) by node class. That decides which kind of member a name refers to, a different fact from what the access is, and only resolveMember decides it. Its match has no default, so a node added to MemberAccess without a lookup fails static analysis.
  • When no static is passed, MemberResolver binds static to the class searched. That's its documented contract, so memberTarget names static only for parent::.- The call-site union (FuncCall|MethodCall|NullsafeMethodCall|StaticCall|New_|Attribute) is still spelled out in ExpressionResolverInterface, ExpressionResolver, PositionLocator and CallSite. That's "what is a call", not member access, and is untouched here.

Closes #859, which tried the same consolidation on an older base.

🤖 Generated with Claude Code

Firehed and others added 11 commits October 29, 2026 09:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.70%. Comparing base (380065b) to head (2a4d5bd).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #882      +/-   ##
============================================
+ Coverage     99.64%   99.70%   +0.06%     
+ Complexity     1969     1951      -18     
============================================
  Files           145      146       +1     
  Lines          4513     4459      -54     
============================================
- Hits           4497     4446      -51     
+ Misses           16       13       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Firehed and others added 3 commits October 29, 2026 09:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Firehed
Firehed marked this pull request as ready for review October 29, 2026 16:24
Firehed and others added 5 commits October 29, 2026 09:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Firehed
Firehed marked this pull request as draft October 29, 2026 16:34
Firehed and others added 5 commits October 29, 2026 09:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Firehed
Firehed marked this pull request as ready for review October 29, 2026 16:52
@Firehed
Firehed merged commit 91c383b into main Oct 29, 2026
8 checks passed
@Firehed
Firehed deleted the member-access-one-owner branch October 29, 2026 17:23
Firehed added a commit that referenced this pull request Nov 2, 2026
Writes down, in the repository, the way of working that fixed member
access (#882), class edges (#888), trait and inheritance composition
(#890) and trait alias modifiers (#892) without leaving partial routes
behind. Until now it lived only in one session's history and in per-user
memories, which other agents and sessions do not reliably see.

## Changes

- **New skill `fix-a-fact`** (`.claude/skills/fix-a-fact/SKILL.md`): the
workflow for any change to what the server says about code.
1. State the fact and PHP's real behavior, asking which to follow when
PHP versions differ.
  2. Find every route from a closed set of files and read them all.
3. Write a short design and have fresh agents attack it against the two
rules (do what PHP does; one route per fact) until a round finds
nothing; fix lower-level facts first, in their own pull request.
4. Build test-first against an oracle where one exists, reusing
fixtures.
5. Review with `pr-review` and an adversarial "who else decides this
fact" pass; fix findings in the pull request's own code fully; track the
rest as issues or known-defect scripts.

  It includes the two adversarial prompts, since their wording mattered.
- **`pr-review`** gains a fourth pass, remaining routes: code anywhere
in `src/` that still decides a fact the pull request claims to own. In
this session that pass found a route a general review missed.
- **AGENTS.md** gains always-on rules: the `fix-a-fact` workflow for
changes to what the server says, fixing at the root instead of patching
symptoms, pull request descriptions written for a reader with no context
and without php-src citations, and answering broken-code questions from
the parser's guarantees rather than from how recovery works.

The pr-review change landed in the AGENTS.md commit; the squash merge
makes that moot.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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