Skip to content

Guard inline-fragment getters on hook-required fields#92

Merged
ruudk merged 1 commit into
mainfrom
ruudk/bug
Jun 9, 2026
Merged

Guard inline-fragment getters on hook-required fields#92
ruudk merged 1 commit into
mainfrom
ruudk/bug

Conversation

@ruudk

@ruudk ruudk commented Jun 9, 2026

Copy link
Copy Markdown
Owner

A @hook placed inside ... on ConcreteType on an interface or union generated a parent asConcreteType getter that handed its own $data straight to the leaf constructor. The leaf requires the fields the hook requires — they are injected into the operation and returned by the server — but the parent types them as optional offsets, since they sit behind a type condition. PHPStan then rejected the construction with an argument.type error, so any such query failed analysis at max level.

Required-field collection skipped every @hook field. That is correct for the synthetic hook field itself, which is never in the response, but it also dropped the hook's requires fields. Those now feed the variant's presence guards, so the getter narrows them with array_key_exists before constructing the leaf.

A `@hook` placed inside `... on ConcreteType` on an interface or union
generated a parent `asConcreteType` getter that handed its own `$data`
straight to the leaf constructor. The leaf requires the fields the hook
`requires` — they are injected into the operation and returned by the
server — but the parent types them as optional offsets, since they sit
behind a type condition. PHPStan then rejected the construction with an
`argument.type` error, so any such query failed analysis at max level.

Required-field collection skipped every `@hook` field. That is correct
for the synthetic hook field itself, which is never in the response, but
it also dropped the hook's `requires` fields. Those now feed the
variant's presence guards, so the getter narrows them with
`array_key_exists` before constructing the leaf.
@ruudk ruudk enabled auto-merge (squash) June 9, 2026 12:24
@ruudk ruudk merged commit 00ecae2 into main Jun 9, 2026
3 checks passed
@ruudk ruudk deleted the ruudk/bug branch June 9, 2026 12:24
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