Skip to content

Commit

Permalink
Update PrivateInFinalClassRule.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech authored Nov 17, 2024
1 parent 74ea27c commit dda2560
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Methods/PrivateInFinalClassRule.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -19,8 +17,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 +56,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 dda2560

Please sign in to comment.