From 7e453409f6ecd70dddab7dab24a81c69bf3b10f6 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 10 Oct 2024 20:03:12 +0200 Subject: [PATCH] Fix cs (#318) --- src/Cache/Manager/FileCacheManager.php | 2 +- src/Cache/Signature.php | 2 +- src/Report/Reporter/CheckstyleReporter.php | 2 +- src/Report/Reporter/GithubReporter.php | 2 +- src/Report/Reporter/JUnitReporter.php | 2 +- src/Report/Reporter/NullReporter.php | 2 +- src/Report/Reporter/ReporterInterface.php | 2 +- src/Report/Reporter/TextReporter.php | 2 +- src/Report/ReporterFactory.php | 2 +- src/Rules/AbstractFixableRule.php | 6 +++--- src/Rules/RuleTrait.php | 2 +- src/Runner/Linter.php | 2 +- src/Test/AbstractRuleTestCase.php | 6 ++++-- src/Token/Token.php | 2 +- tests/Binary/Fixtures/.twig-cs-fixer.php | 2 +- tests/Config/ConfigResolverTest.php | 2 +- tests/Report/ReporterFactoryTest.php | 2 +- tests/Runner/LinterTest.php | 2 +- 18 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/Cache/Manager/FileCacheManager.php b/src/Cache/Manager/FileCacheManager.php index 6777d225..36e170d6 100644 --- a/src/Cache/Manager/FileCacheManager.php +++ b/src/Cache/Manager/FileCacheManager.php @@ -30,7 +30,7 @@ final class FileCacheManager implements CacheManagerInterface public function __construct( private CacheFileHandlerInterface $handler, - private Signature $signature + private Signature $signature, ) { $this->cacheDirectory = \dirname($handler->getFile()); diff --git a/src/Cache/Signature.php b/src/Cache/Signature.php index a5fa871d..ad6b4430 100644 --- a/src/Cache/Signature.php +++ b/src/Cache/Signature.php @@ -15,7 +15,7 @@ final class Signature public function __construct( private string $phpVersion, private string $fixerVersion, - private array $rules + private array $rules, ) { } diff --git a/src/Report/Reporter/CheckstyleReporter.php b/src/Report/Reporter/CheckstyleReporter.php index 4b8d0e03..83d1292f 100644 --- a/src/Report/Reporter/CheckstyleReporter.php +++ b/src/Report/Reporter/CheckstyleReporter.php @@ -21,7 +21,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { $text = ''.\PHP_EOL; diff --git a/src/Report/Reporter/GithubReporter.php b/src/Report/Reporter/GithubReporter.php index 35d65c73..2a675459 100644 --- a/src/Report/Reporter/GithubReporter.php +++ b/src/Report/Reporter/GithubReporter.php @@ -26,7 +26,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { $violations = $report->getViolations($level); foreach ($violations as $violation) { diff --git a/src/Report/Reporter/JUnitReporter.php b/src/Report/Reporter/JUnitReporter.php index 171c433f..a7b200e9 100644 --- a/src/Report/Reporter/JUnitReporter.php +++ b/src/Report/Reporter/JUnitReporter.php @@ -21,7 +21,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { $violations = $report->getViolations($level); $count = \count($violations); diff --git a/src/Report/Reporter/NullReporter.php b/src/Report/Reporter/NullReporter.php index d19e48bc..a6358012 100644 --- a/src/Report/Reporter/NullReporter.php +++ b/src/Report/Reporter/NullReporter.php @@ -23,7 +23,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { } } diff --git a/src/Report/Reporter/ReporterInterface.php b/src/Report/Reporter/ReporterInterface.php index 684cfc22..00512e42 100644 --- a/src/Report/Reporter/ReporterInterface.php +++ b/src/Report/Reporter/ReporterInterface.php @@ -13,7 +13,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void; public function getName(): string; diff --git a/src/Report/Reporter/TextReporter.php b/src/Report/Reporter/TextReporter.php index 7b579f43..b9e4653d 100644 --- a/src/Report/Reporter/TextReporter.php +++ b/src/Report/Reporter/TextReporter.php @@ -32,7 +32,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { $io = new SymfonyStyle(new ArrayInput([]), $output); diff --git a/src/Report/ReporterFactory.php b/src/Report/ReporterFactory.php index 75e90c10..74d42d06 100644 --- a/src/Report/ReporterFactory.php +++ b/src/Report/ReporterFactory.php @@ -17,7 +17,7 @@ final class ReporterFactory * @param list $customReporters */ public function __construct( - private array $customReporters = [] + private array $customReporters = [], ) { } diff --git a/src/Rules/AbstractFixableRule.php b/src/Rules/AbstractFixableRule.php index 656df4e3..e56bfa1c 100644 --- a/src/Rules/AbstractFixableRule.php +++ b/src/Rules/AbstractFixableRule.php @@ -16,7 +16,7 @@ abstract class AbstractFixableRule extends AbstractRule implements FixableRuleIn final protected function init( ?Report $report, array $ignoredViolations = [], - ?FixerInterface $fixer = null + ?FixerInterface $fixer = null, ): void { parent::init($report, $ignoredViolations); $this->fixer = $fixer; @@ -34,7 +34,7 @@ final public function fixFile(Tokens $tokens, FixerInterface $fixer): void final protected function addFixableWarning( string $message, Token $token, - ?string $messageId = null + ?string $messageId = null, ): ?FixerInterface { $added = $this->addWarning($message, $token, $messageId); if (!$added) { @@ -47,7 +47,7 @@ final protected function addFixableWarning( final protected function addFixableError( string $message, Token $token, - ?string $messageId = null + ?string $messageId = null, ): ?FixerInterface { $added = $this->addError($message, $token, $messageId); if (!$added) { diff --git a/src/Rules/RuleTrait.php b/src/Rules/RuleTrait.php index ce1a60ed..1b09f530 100644 --- a/src/Rules/RuleTrait.php +++ b/src/Rules/RuleTrait.php @@ -35,7 +35,7 @@ private function addMessage( string $fileName, ?int $line = null, ?int $linePosition = null, - ?string $messageId = null + ?string $messageId = null, ): bool { $id = new ViolationId( $this->getShortName(), diff --git a/src/Runner/Linter.php b/src/Runner/Linter.php index d80da7b4..51c79abf 100644 --- a/src/Runner/Linter.php +++ b/src/Runner/Linter.php @@ -31,7 +31,7 @@ final class Linter public function __construct( private Environment $env, private TokenizerInterface $tokenizer, - ?CacheManagerInterface $cacheManager = null + ?CacheManagerInterface $cacheManager = null, ) { $this->cacheManager = $cacheManager ?? new NullCacheManager(); } diff --git a/src/Test/AbstractRuleTestCase.php b/src/Test/AbstractRuleTestCase.php index 20b5a7ac..3274efb2 100644 --- a/src/Test/AbstractRuleTestCase.php +++ b/src/Test/AbstractRuleTestCase.php @@ -6,6 +6,8 @@ use PHPUnit\Framework\TestCase; use TwigCsFixer\Environment\StubbedEnvironment; +use TwigCsFixer\Exception\CannotFixFileException; +use TwigCsFixer\Exception\CannotTokenizeException; use TwigCsFixer\Report\Violation; use TwigCsFixer\Rules\Node\NodeRuleInterface; use TwigCsFixer\Rules\RuleInterface; @@ -20,8 +22,8 @@ abstract class AbstractRuleTestCase extends TestCase * @param RuleInterface|NodeRuleInterface|array $rules * @param array $expects * - * @throws \TwigCsFixer\Exception\CannotFixFileException - * @throws \TwigCsFixer\Exception\CannotTokenizeException + * @throws CannotFixFileException + * @throws CannotTokenizeException */ protected function checkRule( RuleInterface|NodeRuleInterface|array $rules, diff --git a/src/Token/Token.php b/src/Token/Token.php index aed0033a..64448483 100644 --- a/src/Token/Token.php +++ b/src/Token/Token.php @@ -73,7 +73,7 @@ public function __construct( private int $linePosition, private string $filename, private string $value = '', - private ?self $relatedToken = null + private ?self $relatedToken = null, ) { } diff --git a/tests/Binary/Fixtures/.twig-cs-fixer.php b/tests/Binary/Fixtures/.twig-cs-fixer.php index a5532061..9604f1d9 100644 --- a/tests/Binary/Fixtures/.twig-cs-fixer.php +++ b/tests/Binary/Fixtures/.twig-cs-fixer.php @@ -45,7 +45,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { } diff --git a/tests/Config/ConfigResolverTest.php b/tests/Config/ConfigResolverTest.php index 66184515..c7c5ec40 100644 --- a/tests/Config/ConfigResolverTest.php +++ b/tests/Config/ConfigResolverTest.php @@ -123,7 +123,7 @@ public function testResolveCacheManager( ?string $configPath, bool $disableCache, ?string $expectedCacheFile, - ?string $expectedCacheManager + ?string $expectedCacheManager, ): void { if (null !== $configPath) { $configPath = $this->getTmpPath($configPath); diff --git a/tests/Report/ReporterFactoryTest.php b/tests/Report/ReporterFactoryTest.php index d5ab6e37..da88b84d 100644 --- a/tests/Report/ReporterFactoryTest.php +++ b/tests/Report/ReporterFactoryTest.php @@ -49,7 +49,7 @@ public function display( OutputInterface $output, Report $report, ?string $level, - bool $debug + bool $debug, ): void { } }; diff --git a/tests/Runner/LinterTest.php b/tests/Runner/LinterTest.php index be751b08..d77f3516 100644 --- a/tests/Runner/LinterTest.php +++ b/tests/Runner/LinterTest.php @@ -164,7 +164,7 @@ public function testFileIsModifiedWhenFixed(): void */ public function testBuggyFixesAreReported( CannotFixFileException|CannotTokenizeException $exception, - string $expectedMessage + string $expectedMessage, ): void { $filePath = $this->getTmpPath(__DIR__.'/Fixtures/Linter/file.twig'); $filePath2 = $this->getTmpPath(__DIR__.'/Fixtures/Linter/file2.twig');