@@ -19,6 +19,8 @@ class MethodSignatureRuleTest extends RuleTestCase
1919
2020 private bool $ reportStatic ;
2121
22+ private bool $ reportMethodPurityOverride = false ;
23+
2224 protected function getRule (): Rule
2325 {
2426 $ phpVersion = new PhpVersion (PHP_VERSION_ID );
@@ -27,7 +29,7 @@ protected function getRule(): Rule
2729
2830 return new OverridingMethodRule (
2931 $ phpVersion ,
30- new MethodSignatureRule (new ParentMethodHelper ($ phpClassReflectionExtension ), $ this ->reportMaybes , $ this ->reportStatic ),
32+ new MethodSignatureRule (new ParentMethodHelper ($ phpClassReflectionExtension ), $ this ->reportMaybes , $ this ->reportStatic , $ this -> reportMethodPurityOverride ),
3133 true ,
3234 new MethodParameterComparisonHelper ($ phpVersion ),
3335 new MethodVisibilityComparisonHelper (),
@@ -565,4 +567,67 @@ public function testBug14320(): void
565567 $ this ->analyse ([__DIR__ . '/data/bug-14320.php ' ], []);
566568 }
567569
570+ public function testBug14563 (): void
571+ {
572+ $ this ->reportMaybes = true ;
573+ $ this ->reportStatic = true ;
574+ $ this ->reportMethodPurityOverride = true ;
575+ $ this ->analyse ([__DIR__ . '/data/bug-14563.php ' ], [
576+ [
577+ 'Impure method Bug14563\ChildImpureOverridesPure::pure() overrides pure method Bug14563\Foo::pure(). ' ,
578+ 31 ,
579+ ],
580+ [
581+ 'Impure method Bug14563\ImpureImplementation::pureMethod() overrides pure method Bug14563\PureInterface::pureMethod(). ' ,
582+ 93 ,
583+ ],
584+ [
585+ 'Impure method Bug14563\ImpureChildOfAllMethodsPure::method() overrides pure method Bug14563\AllMethodsPureParent::method(). ' ,
586+ 126 ,
587+ ],
588+ [
589+ 'Impure method Bug14563\ChildImpureOverridesPureExtended::pure() overrides pure method Bug14563\Foo::pure(). ' ,
590+ 137 ,
591+ ],
592+ [
593+ 'Impure method Bug14563\GrandchildImpureOverridesPure::pure() overrides pure method Bug14563\ChildPureOverridesPure::pure(). ' ,
594+ 148 ,
595+ ],
596+ [
597+ 'Impure method Bug14563\ImpureMultipleInterfaces::sharedMethod() overrides pure method Bug14563\PureInterfaceA::sharedMethod(). ' ,
598+ 186 ,
599+ ],
600+ [
601+ 'Impure method Bug14563\ImpureMultipleInterfaces::sharedMethod() overrides pure method Bug14563\PureInterfaceB::sharedMethod(). ' ,
602+ 186 ,
603+ ],
604+ [
605+ 'Impure method Bug14563\ChildImpureOverridesPureVoid::pureVoid() overrides pure method Bug14563\VoidFoo::pureVoid(). ' ,
606+ 211 ,
607+ ],
608+ [
609+ 'Impure method Bug14563\StaticChildImpureOverridesPure::pure() overrides pure method Bug14563\StaticFoo::pure(). ' ,
610+ 284 ,
611+ ],
612+ [
613+ 'Impure method Bug14563\StaticImpureImplementation::pureMethod() overrides pure method Bug14563\StaticPureInterface::pureMethod(). ' ,
614+ 335 ,
615+ ],
616+ ]);
617+ }
618+
619+ #[RequiresPhp('>= 8.0.0 ' )]
620+ public function testBug14563Trait (): void
621+ {
622+ $ this ->reportMaybes = true ;
623+ $ this ->reportStatic = true ;
624+ $ this ->reportMethodPurityOverride = true ;
625+ $ this ->analyse ([__DIR__ . '/data/bug-14563-trait.php ' ], [
626+ [
627+ 'Impure method Bug14563Trait\ImpureTraitUser::pureTraitMethod() overrides pure method Bug14563Trait\PureTrait::pureTraitMethod(). ' ,
628+ 19 ,
629+ ],
630+ ]);
631+ }
632+
568633}
0 commit comments