Repository navigation
Report PossiblyInvalidPropertyFetch for @property and __get() reads on unions with non-objects - #14706
Conversation
…-objects The pseudo-property read is shared between propertyFetchCanBeAnalyzed() and handleNonExistentProperty(); only the latter marked the fetch as valid, so a union with a non-object reported InvalidPropertyFetch instead of PossiblyInvalidPropertyFetch. The fake __set() call is also analysed on the object part of the receiver only, as the fake __get() call already is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e833bf8536
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $context, | ||
| $statements_analyzer, | ||
| $stmt, | ||
| $lhs_type_part, |
There was a problem hiding this comment.
Join setter side effects across the receiver union
For an A|B receiver of final, unsealed classes whose __set() implementations both write n, with A::$n declared int and B::$n declared ?int, the new per-atomic calls share $context but each MethodCallAnalyzer::analyze() allocates a separate AtomicMethodCallAnalysisResult. Consequently, MethodCallPurityAnalyzer::setPropertyTypeAfterCall() cannot merge the alternatives, and the setter analyzed last replaces $x->n's cached type with int. $x->foo = 1; return $x->n; can then incorrectly satisfy an int return type even though B can return null; previously the cache retained int|null. Merge effects across receiver alternatives instead of applying them sequentially to one context.
Useful? React with 👍 / 👎.
| $stmt, | ||
| Type::combineUnionTypes($stmt_type, $statements_analyzer->node_data->getType($stmt)), | ||
| ); | ||
| $has_valid_fetch_type = true; |
There was a problem hiding this comment.
Isolate fetch validity for each union alternative
For a receiver A|(B&object{q:int}), where A and non-final B provide __get() and declare @property-read int $foo and @property-read string $foo respectively, setting this shared flag for A makes the intersection loop in analyze() return after inspecting B's object{q:int} member, even though that member has no foo. B's own magic property is never analyzed. A targeted base-versus-commit probe infers int|string before this change but only int afterward, allowing invalid returns or arguments on the B branch to go undetected. Use a local success flag for intersection probing and aggregate it into the union-level validity flag.
Useful? React with 👍 / 👎.
…ccessors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Performance: unchanged · Types: decreased
How to read this table
✅ wordpress: drift: same issue count, weight changed; issues +13 −13Memory 2 042 → 2 042 MB (+0.0 %) · Wall 112.3 → 111.6 s (−0.7 %) Weighted 678 190 → 678 151 (−39, −0.01 %): L3 +13 · L6 −13
Changed in place (13) @@ 13 places @@
src/wp-admin/includes/class-wp-ms-sites-list-table.php:651
src/wp-includes/Requests/src/Requests.php:798
src/wp-includes/Requests/src/Session.php:282
src/wp-includes/class-wp-xmlrpc-server.php:3981
src/wp-includes/class-wp-xmlrpc-server.php:3982
src/wp-includes/class-wp-xmlrpc-server.php:3983
src/wp-includes/pluggable.php:2208
src/wp-includes/pluggable.php:2210
src/wp-includes/pluggable.php:2273
src/wp-includes/pluggable.php:2288
… and 3 more
- InvalidPropertyFetch: Cannot fetch property on non-object $_site of type false
+ PossiblyInvalidPropertyFetch: Cannot fetch property on possible non-object $_site of type falsehead bbd6abe · base 71a650b (merge-base) · workflow run |
…le baseline entries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading a
@propertyor a__get()property on a union with a non-object reportsInvalidPropertyFetchinstead ofPossiblyInvalidPropertyFetch, and writing through__set()on such a union adds aPossiblyInvalidMethodCall.@property/__get()readBefore
After
__set()writeBefore
After