Skip to content

Commit

Permalink
Fix: Add test case
Browse files Browse the repository at this point in the history
Related to #838.
  • Loading branch information
localheinz committed Jan 6, 2025
1 parent dfa9a07 commit 89810af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Ergebnis\PHPStan\Rules\Test\Fixture\Methods\PrivateInFinalClassRule;

final class FinalClassImplementingAbstractProtectedMethodFromTrait
{
use TraitWithAbstractProtectedMethod;

protected function method(): void
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Ergebnis\PHPStan\Rules\Test\Fixture\Methods\PrivateInFinalClassRule;

trait TraitWithAbstractProtectedMethod
{
abstract protected function method(): void;
}
7 changes: 7 additions & 0 deletions test/Integration/Methods/PrivateInFinalClassRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public function testPrivateInFinalClassRule(): void
$this->analyse(
self::phpFilesIn(__DIR__ . '/../../Fixture/Methods/PrivateInFinalClassRule'),
[
[
\sprintf(
'Method %s::method() is protected, but since the containing class is final, it can be private.',
Test\Fixture\Methods\PrivateInFinalClassRule\FinalClassImplementingAbstractProtectedMethodFromTrait::class,
),
11,
],
[
\sprintf(
'Method %s::method() is protected, but since the containing class is final, it can be private.',
Expand Down

0 comments on commit 89810af

Please sign in to comment.