Skip to content

Commit c8e4f8b

Browse files
committed
CallToStaticMethodStamentWithoutSideEffectsRule - skip parent::__construct()
1 parent 3714a73 commit c8e4f8b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Rules/Methods/CallToStaticMethodStamentWithoutSideEffectsRule.php

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ static function (Type $type) use ($methodName): bool {
7979
}
8080

8181
$method = $calledOnType->getMethod($methodName, $scope);
82+
if (
83+
(
84+
strtolower($method->getName()) === '__construct'
85+
|| strtolower($method->getName()) === strtolower($method->getDeclaringClass()->getName())
86+
)
87+
) {
88+
return [];
89+
}
90+
8291
if ($method->hasSideEffects()->no()) {
8392
return [
8493
RuleErrorBuilder::message(sprintf(

tests/PHPStan/Rules/Methods/data/static-method-call-statement-no-side-effects.php

+10
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ public function doFoo()
2525
}
2626

2727
}
28+
29+
class FooException extends \Exception
30+
{
31+
32+
public function __construct()
33+
{
34+
parent::__construct();
35+
}
36+
37+
}

0 commit comments

Comments
 (0)