diff --git a/.phpstan/ExceptionTypeResolver.php b/.phpstan/ExceptionTypeResolver.php index 38f23114..5c53133f 100644 --- a/.phpstan/ExceptionTypeResolver.php +++ b/.phpstan/ExceptionTypeResolver.php @@ -8,7 +8,7 @@ use PHPStan\Rules\Exceptions\DefaultExceptionTypeResolver; use PHPStan\Rules\Exceptions\ExceptionTypeResolver as PHPStanExceptionTypeResolver; -class ExceptionTypeResolver implements PHPStanExceptionTypeResolver +final class ExceptionTypeResolver implements PHPStanExceptionTypeResolver { public function __construct(private DefaultExceptionTypeResolver $defaultExceptionTypeResolver) { diff --git a/rector.php b/rector.php index 76252a68..a2461d73 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,9 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector; +use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector; +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -17,6 +20,11 @@ $rectorConfig->sets([ LevelSetList::UP_TO_PHP_80, ]); + $rectorConfig->rules([ + FinalizeClassesWithoutChildrenRector::class, + PrivatizeFinalClassMethodRector::class, + PrivatizeFinalClassPropertyRector::class, + ]); $rectorConfig->importNames(); }; diff --git a/src/Standard/Twig.php b/src/Standard/Twig.php index 62e73c48..0f7e5492 100644 --- a/src/Standard/Twig.php +++ b/src/Standard/Twig.php @@ -14,7 +14,7 @@ * * @see https://twig.symfony.com/doc/3.x/coding_standards.html */ -class Twig implements StandardInterface +final class Twig implements StandardInterface { public function getRules(): array { diff --git a/tests/File/FinderTest.php b/tests/File/FinderTest.php index e883ecfb..4bb8d732 100644 --- a/tests/File/FinderTest.php +++ b/tests/File/FinderTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use TwigCsFixer\File\Finder; -class FinderTest extends TestCase +final class FinderTest extends TestCase { public function testFinder(): void { diff --git a/tests/Report/ViolationIdTest.php b/tests/Report/ViolationIdTest.php index 0ad0eec4..a00bb916 100644 --- a/tests/Report/ViolationIdTest.php +++ b/tests/Report/ViolationIdTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use TwigCsFixer\Report\ViolationId; -class ViolationIdTest extends TestCase +final class ViolationIdTest extends TestCase { /** * @dataProvider toStringDataProvider diff --git a/tests/Report/ViolationTest.php b/tests/Report/ViolationTest.php index e6c14a8b..93485742 100644 --- a/tests/Report/ViolationTest.php +++ b/tests/Report/ViolationTest.php @@ -24,6 +24,19 @@ public function testGetters(): void static::assertSame($violationId, $violation->getIdentifier()); } + public function testGetterWithoutViolationId(): void + { + $violation = new Violation(Violation::LEVEL_WARNING, 'message', 'filename', 'name'); + + static::assertSame(Violation::LEVEL_WARNING, $violation->getLevel()); + static::assertSame('message', $violation->getMessage()); + static::assertSame('filename', $violation->getFilename()); + static::assertNull($violation->getLine()); + static::assertNull($violation->getLinePosition()); + static::assertSame('name', $violation->getRuleName()); + static::assertNull($violation->getIdentifier()); + } + /** * @dataProvider getLevelAsStringDataProvider */ diff --git a/tests/Rules/Fixtures/FakeRule.php b/tests/Rules/Fixtures/FakeRule.php index a2b1b0f6..f9b5c906 100644 --- a/tests/Rules/Fixtures/FakeRule.php +++ b/tests/Rules/Fixtures/FakeRule.php @@ -9,7 +9,7 @@ /** * This rule reports an error for the first token of every line. */ -class FakeRule extends AbstractRule +final class FakeRule extends AbstractRule { public function process(int $tokenPosition, array $tokens): void {