Skip to content

Commit

Permalink
do not throw error is method is marked as #[Before]
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Nov 17, 2024
1 parent 74ea27c commit 0ec48cc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Methods/PrivateInFinalClassRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
use PHPStan\Rules;
use PHPStan\ShouldNotHappenException;


final class PrivateInFinalClassRule implements Rules\Rule
{
private static $attributesThatIndicateProtectedIsOk = [
\PHPUnit\Framework\Attributes\Before::class
];

public function getNodeType(): string
{
return Node\Stmt\ClassMethod::class;
Expand Down Expand Up @@ -53,6 +58,15 @@ public function processNode(
return [];
}

// Check attributes
foreach($node->attrGroups as $attrGroup) {
foreach($attrGroup->attrs as $attr) {
if (in_array($attr->name->toString(), self::$attributesThatIndicateProtectedIsOk)) {
return [];
}
}
}

$methodName = $node->name->toString();

$parentClass = $containingClass->getNativeReflection()->getParentClass();
Expand Down

0 comments on commit 0ec48cc

Please sign in to comment.