PHPStan 2.2 compatibility#85
Merged
Merged
Conversation
PHPStan 2.2 flags the constant in the third arg of `json_decode`, since `$depth` only accepts integer depths. Move it to the `$flags` slot with the default depth of 512.
PHPStan 2.2 enforces sealed array shapes by default, rejecting the generator's pattern where a parent forwards `$this->data` (or a wider loaders registry) into a child fragment, inline-fragment, error, or loader constructor that declared a narrower shape. The forwarding is structurally correct — children only read the keys they declare — but the sealed-shape rule treats the extras as type errors. Mark generated payload, error, hooks, and loaders shapes as unsealed so the wider parent shape fits. `HookLoader`'s template params become `@template-covariant` so any specific instantiation fits the unsealed extras slot in nested classes' `\$loaders` parameter. Input object shapes stay sealed — those describe a closed GraphQL input schema and are constructed by user code with exactly the declared fields. Extras are emitted explicitly as `...<int|string, mixed>` rather than the short `...`, since PHPStan's `missingType.iterableValue` rule at level 6+ rejects the implicit `array-key, mixed` extras.
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.
Bump to PHPStan 2.2
Pass JSON_THROW_ON_ERROR as $flags, not $depth
PHPStan 2.2 flags the constant in the third arg of
json_decode, since$depthonly accepts integer depths. Move it to the$flagsslot with the default depth of 512.Unseal generated array shapes for PHPStan 2.2
PHPStan 2.2 enforces sealed array shapes by default, rejecting the generator's pattern where a parent forwards
$this->data(or a wider loaders registry) into a child fragment, inline-fragment, error, or loader constructor that declared a narrower shape. The forwarding is structurally correct — children only read the keys they declare — but the sealed-shape rule treats the extras as type errors.Mark generated payload, error, hooks, and loaders shapes as unsealed so the wider parent shape fits.
HookLoader's template params become@template-covariantso any specific instantiation fits the unsealed extras slot in nested classes'\$loadersparameter. Input object shapes stay sealed — those describe a closed GraphQL input schema and are constructed by user code with exactly the declared fields.Extras are emitted explicitly as
...<int|string, mixed>rather than the short..., since PHPStan'smissingType.iterableValuerule at level 6+ rejects the implicitarray-key, mixedextras.