Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for Symfony v7 components #119

Merged
merged 9 commits into from
Jan 31, 2024
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
"php": "^8.1",
"ext-json": "*",
"friendsofphp/php-cs-fixer": "^3.30",
"symfony/console": "^5.4 || ^6.0",
"symfony/filesystem": "^5.4 || ^6.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",
"ergebnis/composer-normalize": "^2.28",
"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",
Expand Down
12 changes: 2 additions & 10 deletions src/Console/Command/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <comment>["%s"]</comment>. If not set, the detection is automatic',
implode('","', Setup::VALID_TYPES)
Expand Down
14 changes: 5 additions & 9 deletions src/Console/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 8 additions & 8 deletions tests/Console/Style/SimpleStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -275,15 +275,15 @@ 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));
}

/**
* @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);
Expand All @@ -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();
Expand All @@ -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);
}
Expand All @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +36,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()
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Console/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Console/Command/SetupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Smoke/AbstractCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

Expand Down
Loading