From 19f9e08f7da6ae0069f83fc4b1bd764447972314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:00:08 +0100 Subject: [PATCH 1/8] [FEATURE] Add support for Symfony v7 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b20d16e..7967cb9 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,8 @@ "php": "^8.1", "ext-json": "*", "friendsofphp/php-cs-fixer": "^3.16", - "symfony/console": "^5.4 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0" + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "composer/package-versions-deprecated": "^1.11.99.5", From 79fb259edcdb3642e335f1cfdcf1ad035df5b8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:00:28 +0100 Subject: [PATCH 2/8] [TASK] Upgrade overtrue/phplint to ^9.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7967cb9..a8cc8a4 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "keradus/cli-executor": "^1.5", "maglnet/composer-require-checker": "*", "nikic/php-parser": "^4.15.5", - "overtrue/phplint": "^3.1.1", + "overtrue/phplint": "^9.0", "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan-deprecation-rules": "^1.1.3", "phpstan/phpstan-phpunit": "^1.3.12", From a140240abd438a05561038e66d076c3607354f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:02:02 +0100 Subject: [PATCH 3/8] [TASK] Avoid using `$default*` properties in commands --- src/Console/Command/SetupCommand.php | 12 ++---------- src/Console/Command/UpdateCommand.php | 14 +++++--------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/Console/Command/SetupCommand.php b/src/Console/Command/SetupCommand.php index f8fa769..9b98a2d 100644 --- a/src/Console/Command/SetupCommand.php +++ b/src/Console/Command/SetupCommand.php @@ -29,21 +29,13 @@ */ final class SetupCommand extends Command { - /** - * @var string - */ - protected static $defaultName = 'setup'; - - /** - * @var string - */ - protected static $defaultDescription = 'Setting up the TYPO3 rule sets for an extension or a project'; - protected function configure(): void { parent::configure(); $this + ->setName('setup') + ->setDescription('Setting up the TYPO3 rule sets for an extension or a project') ->addArgument('type', InputArgument::OPTIONAL, sprintf( 'Type to setup, valid types are ["%s"]. If not set, the detection is automatic', implode('","', Setup::VALID_TYPES) diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 94c47f8..250043a 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -26,15 +26,11 @@ */ final class UpdateCommand extends Command { - /** - * @var string - */ - protected static $defaultName = 'update'; - - /** - * @var string - */ - protected static $defaultDescription = 'Update the TYPO3 rule sets'; + protected function configure(): void + { + $this->setName('update'); + $this->setDescription('Update the TYPO3 rule sets'); + } protected function execute(InputInterface $input, OutputInterface $output): int { From 323b0c523f675dc67a797f323117d5813aebd0b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:02:32 +0100 Subject: [PATCH 4/8] [TASK] Add types to SimpleStyle for Symfony v7 compatibility --- tests/Console/Style/SimpleStyle.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Console/Style/SimpleStyle.php b/tests/Console/Style/SimpleStyle.php index c2c9b62..7d4a36f 100644 --- a/tests/Console/Style/SimpleStyle.php +++ b/tests/Console/Style/SimpleStyle.php @@ -251,7 +251,7 @@ public function definitionList(...$list): void /** * @inheritDoc */ - public function ask($question, $default = null, $validator = null) + public function ask(string $question, string $default = null, callable $validator = null): mixed { $question = new Question($question, $default); $question->setValidator($validator); @@ -262,7 +262,7 @@ public function ask($question, $default = null, $validator = null) /** * @inheritDoc */ - public function askHidden($question, $validator = null) + public function askHidden(string $question, callable $validator = null): mixed { $question = new Question($question); @@ -275,7 +275,7 @@ public function askHidden($question, $validator = null) /** * @inheritDoc */ - public function confirm($question, $default = true) + public function confirm(string $question, bool $default = true): bool { return $this->askQuestion(new ConfirmationQuestion($question, $default)); } @@ -283,7 +283,7 @@ public function confirm($question, $default = true) /** * @inheritDoc */ - public function choice($question, array $choices, $default = null) + public function choice(string $question, array $choices, mixed $default = null): mixed { if ($default !== null) { $values = array_flip($choices); @@ -296,7 +296,7 @@ public function choice($question, array $choices, $default = null) /** * @inheritDoc */ - public function progressStart($max = 0): void + public function progressStart(int $max = 0): void { $this->progressBar = $this->createProgressBar($max); $this->progressBar->start(); @@ -305,7 +305,7 @@ public function progressStart($max = 0): void /** * @inheritDoc */ - public function progressAdvance($step = 1): void + public function progressAdvance(int $step = 1): void { $this->getProgressBar()->advance($step); } @@ -323,7 +323,7 @@ public function progressFinish(): void /** * @inheritDoc */ - public function createProgressBar($max = 0) + public function createProgressBar(int $max = 0): ProgressBar { $progressBar = parent::createProgressBar($max); From 2b1a4227cfd29633df676b636201a51d2a001963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:02:51 +0100 Subject: [PATCH 5/8] [TASK] Replace removed `Helper::strlenWithoutDecoration()` --- tests/Console/Style/SimpleStyle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Console/Style/SimpleStyle.php b/tests/Console/Style/SimpleStyle.php index 7d4a36f..d941ca4 100644 --- a/tests/Console/Style/SimpleStyle.php +++ b/tests/Console/Style/SimpleStyle.php @@ -448,7 +448,7 @@ private function writeBuffer(string $message, bool $newLine, int $type): void private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array { $indentLength = 0; - $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix); + $prefixLength = Helper::removeDecoration($this->getFormatter(), $prefix); $lines = []; if ($type !== null) { From bf462f5095907222edc9706a355b1a2692d7183b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Thu, 18 Jan 2024 23:03:23 +0100 Subject: [PATCH 6/8] [BUGFIX] Run console commands without ANSI colors during testing --- tests/Unit/Console/ApplicationTest.php | 2 +- tests/Unit/Smoke/AbstractCliTestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Console/ApplicationTest.php b/tests/Unit/Console/ApplicationTest.php index d4cad20..10970a1 100644 --- a/tests/Unit/Console/ApplicationTest.php +++ b/tests/Unit/Console/ApplicationTest.php @@ -34,7 +34,7 @@ public function testApplication(): void $applicationTester = new ApplicationTester($application); - self::assertSame(0, $applicationTester->run([])); + self::assertSame(0, $applicationTester->run(['--no-ansi' => true])); self::assertStringContainsString( 'TYPO3 Coding Standards ' . Application::VERSION, $applicationTester->getDisplay() diff --git a/tests/Unit/Smoke/AbstractCliTestCase.php b/tests/Unit/Smoke/AbstractCliTestCase.php index bf9c4bd..4f5343d 100644 --- a/tests/Unit/Smoke/AbstractCliTestCase.php +++ b/tests/Unit/Smoke/AbstractCliTestCase.php @@ -49,7 +49,7 @@ public function testVersion(): void { self::assertMatchesRegularExpression( '/^TYPO3 Coding Standards ' . Application::VERSION . '$/', - self::executeCliCommand('--version')->getOutput() + self::executeCliCommand('--version --no-ansi')->getOutput() ); } From 1ee8cc84266a0f9f898245f2f2f4b38da49f59b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Fri, 19 Jan 2024 08:43:08 +0100 Subject: [PATCH 7/8] [TASK] Align Symfony version constraints with TYPO3 core --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a8cc8a4..9680aea 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,8 @@ "php": "^8.1", "ext-json": "*", "friendsofphp/php-cs-fixer": "^3.16", - "symfony/console": "^5.4 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" + "symfony/console": "^5.4 || ^6.4 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { "composer/package-versions-deprecated": "^1.11.99.5", From fe6a370273e49d5452fb3e4be6ac2d787f70e8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Tue, 30 Jan 2024 21:52:05 +0100 Subject: [PATCH 8/8] [TASK] Add used classes to tests --- tests/Unit/Console/ApplicationTest.php | 2 ++ tests/Unit/Console/Command/CommandTest.php | 2 ++ tests/Unit/Console/Command/SetupCommandTest.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/Unit/Console/ApplicationTest.php b/tests/Unit/Console/ApplicationTest.php index 10970a1..6697d78 100644 --- a/tests/Unit/Console/ApplicationTest.php +++ b/tests/Unit/Console/ApplicationTest.php @@ -21,10 +21,12 @@ use Symfony\Component\Console\Tester\ApplicationTester; use TYPO3\CodingStandards\Console\Application; use TYPO3\CodingStandards\Console\Command\SetupCommand; +use TYPO3\CodingStandards\Console\Command\UpdateCommand; use TYPO3\CodingStandards\Tests\Unit\TestCase; #[\PHPUnit\Framework\Attributes\CoversClass(Application::class)] #[\PHPUnit\Framework\Attributes\UsesClass(SetupCommand::class)] +#[\PHPUnit\Framework\Attributes\UsesClass(UpdateCommand::class)] final class ApplicationTest extends TestCase { public function testApplication(): void diff --git a/tests/Unit/Console/Command/CommandTest.php b/tests/Unit/Console/Command/CommandTest.php index dbec4b8..8180ea5 100644 --- a/tests/Unit/Console/Command/CommandTest.php +++ b/tests/Unit/Console/Command/CommandTest.php @@ -21,10 +21,12 @@ use TYPO3\CodingStandards\Console\Application; use TYPO3\CodingStandards\Console\Command\Command; use TYPO3\CodingStandards\Console\Command\SetupCommand; +use TYPO3\CodingStandards\Console\Command\UpdateCommand; #[\PHPUnit\Framework\Attributes\CoversClass(Command::class)] #[\PHPUnit\Framework\Attributes\UsesClass(Application::class)] #[\PHPUnit\Framework\Attributes\UsesClass(SetupCommand::class)] +#[\PHPUnit\Framework\Attributes\UsesClass(UpdateCommand::class)] final class CommandTest extends CommandTestCase { private ?CommandTestImplementation $commandTestImplementation = null; diff --git a/tests/Unit/Console/Command/SetupCommandTest.php b/tests/Unit/Console/Command/SetupCommandTest.php index 06592b3..a01604c 100644 --- a/tests/Unit/Console/Command/SetupCommandTest.php +++ b/tests/Unit/Console/Command/SetupCommandTest.php @@ -21,9 +21,11 @@ use TYPO3\CodingStandards\Console\Application; use TYPO3\CodingStandards\Console\Command\Command; use TYPO3\CodingStandards\Console\Command\SetupCommand; +use TYPO3\CodingStandards\Console\Command\UpdateCommand; use TYPO3\CodingStandards\Setup; #[\PHPUnit\Framework\Attributes\CoversClass(SetupCommand::class)] +#[\PHPUnit\Framework\Attributes\CoversClass(UpdateCommand::class)] #[\PHPUnit\Framework\Attributes\UsesClass(Application::class)] #[\PHPUnit\Framework\Attributes\UsesClass(Command::class)] #[\PHPUnit\Framework\Attributes\UsesClass(Setup::class)]