diff --git a/src/Rules/AbstractFixableRule.php b/src/Rules/AbstractFixableRule.php index ea7dc298..656df4e3 100644 --- a/src/Rules/AbstractFixableRule.php +++ b/src/Rules/AbstractFixableRule.php @@ -13,7 +13,7 @@ abstract class AbstractFixableRule extends AbstractRule implements FixableRuleIn { private ?FixerInterface $fixer = null; - protected function init( + final protected function init( ?Report $report, array $ignoredViolations = [], ?FixerInterface $fixer = null @@ -22,7 +22,7 @@ protected function init( $this->fixer = $fixer; } - public function fixFile(Tokens $tokens, FixerInterface $fixer): void + final public function fixFile(Tokens $tokens, FixerInterface $fixer): void { $this->init(null, $tokens->getIgnoredViolations(), $fixer); @@ -31,7 +31,7 @@ public function fixFile(Tokens $tokens, FixerInterface $fixer): void } } - protected function addFixableWarning( + final protected function addFixableWarning( string $message, Token $token, ?string $messageId = null @@ -44,7 +44,7 @@ protected function addFixableWarning( return $this->fixer; } - protected function addFixableError( + final protected function addFixableError( string $message, Token $token, ?string $messageId = null diff --git a/src/Rules/AbstractRule.php b/src/Rules/AbstractRule.php index 1d2c2af5..e69c8036 100644 --- a/src/Rules/AbstractRule.php +++ b/src/Rules/AbstractRule.php @@ -14,7 +14,7 @@ abstract class AbstractRule implements RuleInterface { use RuleTrait; - public function lintFile(Tokens $tokens, Report $report): void + final public function lintFile(Tokens $tokens, Report $report): void { $this->init($report, $tokens->getIgnoredViolations()); @@ -34,7 +34,7 @@ protected function init(?Report $report, array $ignoredViolations = []): void abstract protected function process(int $tokenIndex, Tokens $tokens): void; - protected function addWarning(string $message, Token $token, ?string $messageId = null): bool + final protected function addWarning(string $message, Token $token, ?string $messageId = null): bool { return $this->addMessage( Violation::LEVEL_WARNING, @@ -46,7 +46,7 @@ protected function addWarning(string $message, Token $token, ?string $messageId ); } - protected function addFileWarning(string $message, Token $token, ?string $messageId = null): bool + final protected function addFileWarning(string $message, Token $token, ?string $messageId = null): bool { return $this->addMessage( Violation::LEVEL_WARNING, @@ -58,7 +58,7 @@ protected function addFileWarning(string $message, Token $token, ?string $messag ); } - protected function addError(string $message, Token $token, ?string $messageId = null): bool + final protected function addError(string $message, Token $token, ?string $messageId = null): bool { return $this->addMessage( Violation::LEVEL_ERROR, @@ -70,7 +70,7 @@ protected function addError(string $message, Token $token, ?string $messageId = ); } - protected function addFileError(string $message, Token $token, ?string $messageId = null): bool + final protected function addFileError(string $message, Token $token, ?string $messageId = null): bool { return $this->addMessage( Violation::LEVEL_ERROR, diff --git a/src/Rules/AbstractSpacingRule.php b/src/Rules/AbstractSpacingRule.php index 9f96e63d..63235f5c 100644 --- a/src/Rules/AbstractSpacingRule.php +++ b/src/Rules/AbstractSpacingRule.php @@ -14,7 +14,7 @@ abstract class AbstractSpacingRule extends AbstractFixableRule { protected bool $skipIfNewLine = true; - protected function process(int $tokenIndex, Tokens $tokens): void + final protected function process(int $tokenIndex, Tokens $tokens): void { $spaceAfter = $this->getSpaceAfter($tokenIndex, $tokens); $spaceBefore = $this->getSpaceBefore($tokenIndex, $tokens); diff --git a/src/Rules/Node/AbstractNodeRule.php b/src/Rules/Node/AbstractNodeRule.php index 99325c70..cddec8a8 100644 --- a/src/Rules/Node/AbstractNodeRule.php +++ b/src/Rules/Node/AbstractNodeRule.php @@ -15,7 +15,7 @@ abstract class AbstractNodeRule implements NodeRuleInterface { use RuleTrait; - public function setReport(Report $report, array $ignoredViolations = []): void + final public function setReport(Report $report, array $ignoredViolations = []): void { $this->report = $report; $this->ignoredViolations = $ignoredViolations; @@ -36,7 +36,7 @@ public function getPriority(): int return 0; } - protected function addWarning(string $message, Node $node, ?string $messageId = null): bool + final protected function addWarning(string $message, Node $node, ?string $messageId = null): bool { $templateName = $node->getTemplateName(); Assert::notNull($templateName, 'Parsed node should always have a source context.'); @@ -51,7 +51,7 @@ protected function addWarning(string $message, Node $node, ?string $messageId = ); } - protected function addError(string $message, Node $node, ?string $messageId = null): bool + final protected function addError(string $message, Node $node, ?string $messageId = null): bool { $templateName = $node->getTemplateName(); Assert::notNull($templateName, 'Parsed node should always have a source context.'); diff --git a/tests/FileTestCase.php b/tests/FileTestCase.php index 753f856e..7d82faa8 100644 --- a/tests/FileTestCase.php +++ b/tests/FileTestCase.php @@ -52,7 +52,7 @@ protected function tearDown(): void chdir($this->cwd); } - protected function getFilesystem(): Filesystem + final protected function getFilesystem(): Filesystem { if (null === $this->filesystem) { $this->filesystem = new Filesystem(); @@ -61,7 +61,7 @@ protected function getFilesystem(): Filesystem return $this->filesystem; } - protected function getTmpPath(string $path): string + final protected function getTmpPath(string $path): string { $path = TestHelper::getOsPath($path); if (!str_starts_with($path, $this->getDir())) {