Repository navigation
Fix static kept on the union of $this and another object of its class - #14078
Conversation
✅ Performance: unchanged · Types: increased
How to read this table
✅ symfony: issues +1 −0Memory 3 613 → 3 613 MB (<0.1 %) · Wall 163.2 → 170.7 s (+4.6 %) Weighted 99 062 → 99 065 (+3, <0.01 %): L3 +1
Added (1)
✅ doctrine-orm: issues +2 −2Memory 392 → 392 MB (+0.0 %) · Wall 16.2 → 16.1 s (−0.7 %)
Added (2)
Removed (2)
head 412ccdb · base ad06cb6 (merge-base) · workflow run |
alies-dev
left a comment
There was a problem hiding this comment.
🤖 The bug is real on current master ($f ? $this : $other is A&static, $f ? $other : $this is A), and the fix gives A for both orders while $f ? $this : $this->me() keeps static. Different-class pairs (A&static|B, A&static|I) stay unions on master and on the PR, so this same-key branch is the only place where static is collapsed wrongly.
No blocking findings.
Recommendations (non-blocking)
TypeCombineralready tracks$combination->object_staticper class name (set for everyTNamedObject, and read back for generic objects viasetIsStatic($combination->object_static[...])), but the plainnamed_object_typesentries are emitted as whichever atomic was stored first. Applyingobject_staticwhennamed_object_typesare merged intovalue_types(the same way the generic branch does) would make this order-independent without rewriting the stored atomic in the middle of the scrape, and would keep one rule for generic and non-generic objects.- The perf run adds one
MoreSpecificReturnTypeforRequest::createRequestFromFactory(symfony). It looks like a true positive (the method can return a plainRequestafterinstanceof self), but note that a@return staticfunction returning$f ? $this : $othernow reports bothMoreSpecificReturnTypeandLessSpecificReturnStatement(reproduced), which is worth a line in the description.
|
Thanks for the review. Moved the fix to where |
The union of
$this(OB&static) and anotherOBkeeps&staticwhen$thiscomes first, so returning it asstaticis not reported.Before
After
A
@return staticmethod returning such a union now reports bothMoreSpecificReturnTypeandLessSpecificReturnStatement(as for any declared return type narrower than what is returned). Twostaticobjects of the class still combine tostatic($f ? $this : $this->me()).Fixes #13521