Repository navigation
Report a possibly missing offset on a type that only maybe has offsets - #6725
Open
SanderMuller wants to merge 1 commit into
Open
SanderMuller wants to merge 1 commit into
SanderMuller wants to merge 1 commit into
Conversation
On array{host?: string}|false, NonexistentOffsetInArrayDimFetchRule
reported only "Cannot access offset 'host' on ...|false" and returned, so
the possibly missing 'host' key on the array part was never reported.
Continue to the offset check after that error, for reads only: a write
creates the offset. The check now skips the members that are not
certainly offset-accessible, which the rule already reports, so
array{host: string}|false does not get a "might not exist".
ArrayDestructuringRule had the same early return for a type that is only
maybe an array, such as array|false. It now checks the keys on the array
part as well.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
SanderMuller
force-pushed
the
offset-missing-key-on-maybe-accessible
branch
from
October 9, 2026 23:24
12258aa to
981ca41
Compare
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.
On
array{host?: string}|false,NonexistentOffsetInArrayDimFetchRulereported only thefalsepart and returned, so the possibly missing'host'key on the array part was never reported:With
array{host?: string}|nullthe missing key was already reported, so the result depended on whether the second member isnullorfalse.NonexistentOffsetInArrayDimFetchCheckafter the "Cannot access offset" error, for reads only. A write creates the offset, so it stops there as before.array{host: string}|falsewould get a "might not exist" for thefalsepart, although the key always exists on the array part.ArrayDestructuringRulehad the same early return for a type that is only maybe an array.[$a, $b] = $arrayOrFalsereported only "Cannot use array destructuring on ...|false". It now checks the keys on the array part as well.On WordPress trunk from 2026-10-07 at level 8, this adds 46 errors and removes none. 42 of them are a possibly missing key on a
parse_url()orwp_get_attachment_metadata()result. The other 4 come from anullorstringmember next to the array, whicharray|nullalready reported before this change. WordPress once fixed this exact case in WordPress/wordpress-develop@68b2338:$parsed['host']on a relativeparse_url()result inmedia.php. Before that fix, PHPStan reported only thefalsepart on that line.🤖 Generated with Claude Code