Skip to content

Commit

Permalink
CallToStaticMethodStamentWithoutSideEffectsRule - skip parent::__cons…
Browse files Browse the repository at this point in the history
…truct()
  • Loading branch information
ondrejmirtes committed Nov 1, 2020
1 parent 3714a73 commit c8e4f8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ static function (Type $type) use ($methodName): bool {
}

$method = $calledOnType->getMethod($methodName, $scope);
if (
(
strtolower($method->getName()) === '__construct'
|| strtolower($method->getName()) === strtolower($method->getDeclaringClass()->getName())
)
) {
return [];
}

if ($method->hasSideEffects()->no()) {
return [
RuleErrorBuilder::message(sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ public function doFoo()
}

}

class FooException extends \Exception
{

public function __construct()
{
parent::__construct();
}

}

2 comments on commit c8e4f8b

@dktapps
Copy link
Contributor

@dktapps dktapps commented on c8e4f8b Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not completely related, but shouldn't this rule be named CallToStaticMethodStatementWithoutSideEffectsRule?

@ondrejmirtes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be, in next major.

Please sign in to comment.