You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixphpstan/phpstan#7317: SimpleXMLElement::current() tentative return type not checked
- The tentative return type check in OverridingMethodRule only checked the deepest
prototype (e.g., Iterator::current() with tentative type mixed), missing more
specific tentative types from intermediate parent classes (e.g.,
SimpleXMLElement::current() with tentative type SimpleXMLElement)
- Added getParentMethodTentativeReturnType() to also check the direct parent class
method's tentative return type and use the more specific one
- Updated Bug9615 test expectation to reflect the more accurate parent class reference
- New regression test in tests/PHPStan/Rules/Methods/data/bug-7317.php
Copy file name to clipboardExpand all lines: tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -677,7 +677,7 @@ public function testBug9615(): void
677
677
$tipText,
678
678
],
679
679
[
680
-
'Return type mixed of method Bug9615\ExpectComplaintsHere::getChildren() is not covariant with tentative return type RecursiveIterator|null of method RecursiveIterator<mixed,mixed>::getChildren().',
680
+
'Return type mixed of method Bug9615\ExpectComplaintsHere::getChildren() is not covariant with tentative return type RecursiveFilterIterator|null of method RecursiveFilterIterator::getChildren().',
681
681
20,
682
682
$tipText,
683
683
],
@@ -839,6 +839,24 @@ public function testSimpleXmlElementChildClass(): void
'Return type bool of method Bug7317\MySimpleXMLElement::current() is not covariant with tentative return type static(SimpleXMLElement)|null of method SimpleXMLElement::current().',
849
+
8,
850
+
'Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.',
851
+
],
852
+
[
853
+
'Return type int of method Bug7317\MySimpleXMLElement::valid() is not covariant with tentative return type bool of method Iterator<string,static(SimpleXMLElement)>::valid().',
854
+
12,
855
+
'Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.',
0 commit comments