From 7765768fd54617616107f76489702d8bcac3d4d2 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 20 Nov 2023 11:32:39 +0100 Subject: [PATCH] Fix overriding SoapClient old-style constructor --- src/Rules/Methods/OverridingMethodRule.php | 2 ++ .../Rules/Methods/OverridingMethodRuleTest.php | 6 ++++++ tests/PHPStan/Rules/Methods/data/bug-10165.php | 13 +++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/PHPStan/Rules/Methods/data/bug-10165.php diff --git a/src/Rules/Methods/OverridingMethodRule.php b/src/Rules/Methods/OverridingMethodRule.php index bcf26d2bbe..aa22a9cab9 100644 --- a/src/Rules/Methods/OverridingMethodRule.php +++ b/src/Rules/Methods/OverridingMethodRule.php @@ -375,6 +375,8 @@ private function findPrototype(ClassReflection $classReflection, string $methodN return null; } } + } elseif (strtolower($methodName) === '__construct') { + return null; } } diff --git a/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php b/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php index 76d8456578..d34759259e 100644 --- a/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php +++ b/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php @@ -810,4 +810,10 @@ public function testBug10153(): void $this->analyse([__DIR__ . '/data/bug-10153.php'], $errors); } + public function testBug10165(): void + { + $this->phpVersionId = PHP_VERSION_ID; + $this->analyse([__DIR__ . '/data/bug-10165.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Methods/data/bug-10165.php b/tests/PHPStan/Rules/Methods/data/bug-10165.php new file mode 100644 index 0000000000..c414f64533 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-10165.php @@ -0,0 +1,13 @@ +