Skip to content

Commit

Permalink
more precise rule name and message
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 21, 2023
1 parent 6e14549 commit c405d44
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion conf/config.level0.neon
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ rules:
- PHPStan\Rules\Keywords\ContinueBreakInLoopRule
- PHPStan\Rules\Methods\AbstractMethodInNonAbstractClassRule
- PHPStan\Rules\Methods\AbstractPrivateMethodRule
- PHPStan\Rules\Methods\AbstractProtectedMethodRule
- PHPStan\Rules\Methods\AbstractProtectedMethodInInterfaceRule
- PHPStan\Rules\Methods\CallMethodsRule
- PHPStan\Rules\Methods\CallStaticMethodsRule
- PHPStan\Rules\Methods\ConstructorReturnTypeRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function sprintf;

/** @implements Rule<InClassMethodNode> */
class AbstractProtectedMethodRule implements Rule
class AbstractProtectedMethodInInterfaceRule implements Rule
{

public function getNodeType(): string
Expand Down Expand Up @@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array

return [
RuleErrorBuilder::message(sprintf(
'Protected method %s::%s() cannot be abstract.',
'Protected method %s::%s() cannot be abstract in interface.',
$method->getDeclaringClass()->getDisplayName(),
$method->getName(),
))->nonIgnorable()->build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;

/** @extends RuleTestCase<AbstractProtectedMethodRule> */
class AbstractProtectedMethodRuleTest extends RuleTestCase
/** @extends RuleTestCase<AbstractProtectedMethodInInterfaceRule> */
class AbstractProtectedMethodInInterfaceRuleTest extends RuleTestCase
{

protected function getRule(): Rule
{
return new AbstractProtectedMethodRule();
return new AbstractProtectedMethodInInterfaceRule();
}

public function testRule(): void
{
$this->analyse([__DIR__ . '/data/abstract-methods.php'], [
[
'Protected method AbstractMethods\fooInterface::sayProtected() cannot be abstract.',
'Protected method AbstractMethods\fooInterface::sayProtected() cannot be abstract in interface.',
25,
],
]);
Expand Down

0 comments on commit c405d44

Please sign in to comment.