Skip to content

Commit

Permalink
Finalize methods
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jul 28, 2024
1 parent 334580d commit 6b9bb1b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Rules/AbstractFixableRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -44,7 +44,7 @@ protected function addFixableWarning(
return $this->fixer;
}

protected function addFixableError(
final protected function addFixableError(
string $message,
Token $token,
?string $messageId = null
Expand Down
10 changes: 5 additions & 5 deletions src/Rules/AbstractRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/AbstractSpacingRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/Rules/Node/AbstractNodeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.');
Expand All @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions tests/FileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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())) {
Expand Down

0 comments on commit 6b9bb1b

Please sign in to comment.