Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
@hookplaced inside... on ConcreteTypeon an interface or union generated a parentasConcreteTypegetter that handed its own$datastraight to the leaf constructor. The leaf requires the fields the hookrequires— 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 anargument.typeerror, so any such query failed analysis at max level.Required-field collection skipped every
@hookfield. That is correct for the synthetic hook field itself, which is never in the response, but it also dropped the hook'srequiresfields. Those now feed the variant's presence guards, so the getter narrows them witharray_key_existsbefore constructing the leaf.