diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 695e48a..11d537b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -6,7 +6,7 @@ <<addRules([ - '@PER:risky' => true, - '@PHP80Migration:risky' => true, - '@PHP81Migration' => true, - 'declare_strict_types' => true, - 'fully_qualified_strict_types' => true, + '@DoctrineAnnotation' => true, + '@PER-CS3x0' => true, + // Override PER-CS3x0 default (single) to keep no space after cast operators + 'cast_spaces' => ['space' => 'none'], + 'declare_parentheses' => true, + 'dir_constant' => true, + 'function_to_constant' => [ + 'functions' => [ + 'get_called_class', + 'get_class', + 'get_class_this', + 'php_sapi_name', + 'phpversion', + 'pi', + ], + ], + 'type_declaration_spaces' => true, 'global_namespace_import' => [ - 'import_classes' => true, + 'import_classes' => false, 'import_constants' => false, 'import_functions' => false, ], - 'no_unneeded_import_alias' => true, - 'ordered_imports' => [ - 'imports_order' => ['class', 'function', 'const'], - 'sort_algorithm' => 'alpha', + 'list_syntax' => ['syntax' => 'short'], + 'modernize_strpos' => true, + 'modernize_types_casting' => true, + 'native_function_casing' => true, + 'native_function_invocation' => [ + 'include' => [], + 'scope' => 'all', + 'strict' => true, ], - 'phpdoc_align' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_indent' => true, - 'phpdoc_inline_tag_normalizer' => true, - 'phpdoc_line_span' => true, - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_order' => true, - 'phpdoc_order_by_value' => true, - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_summary' => true, - 'phpdoc_tag_casing' => true, - 'phpdoc_tag_type' => true, - 'phpdoc_to_comment' => [ - 'ignored_tags' => [ - 'phpstan-ignore-line', - 'phpstan-ignore-next-line', - 'todo', - ], + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_nullsafe_operator' => true, + // Override PER-CS3x0 default (union) to keep ?Type shorthand syntax + 'nullable_type_declaration' => [ + 'syntax' => 'question_mark', ], - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types_order' => [ - 'null_adjustment' => 'always_last', - 'sort_algorithm' => 'alpha', + 'nullable_type_declaration_for_default_null_value' => true, + 'ordered_class_elements' => ['order' => ['use_trait', 'case', 'constant', 'property']], + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => [ + 'call_type' => 'self', + 'methods' => [ + 'any' => 'this', + 'atLeast' => 'this', + 'atLeastOnce' => 'this', + 'atMost' => 'this', + 'exactly' => 'this', + 'never' => 'this', + 'onConsecutiveCalls' => 'this', + 'once' => 'this', + 'returnArgument' => 'this', + 'returnCallback' => 'this', + 'returnSelf' => 'this', + 'returnValue' => 'this', + 'returnValueMap' => 'this', + 'throwException' => 'this', + ], ], - 'phpdoc_var_annotation_correct_order' => true, - 'phpdoc_var_without_name' => true, - 'self_accessor' => true, + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'protected_to_private' => true, + 'single_quote' => true, + 'single_line_comment_style' => ['comment_types' => ['hash']], + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], ]) ->getFinder() ->exclude('templates') ->exclude('tests/Unit/Fixtures') ->in(__DIR__) - ->append(['typo3-coding-standards']) -; + ->append(['typo3-coding-standards']); return $config; diff --git a/composer.json b/composer.json index aa1ef6b..66fa5cb 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "require": { "php": "^8.1", "ext-json": "*", - "friendsofphp/php-cs-fixer": "^3.88.2", + "friendsofphp/php-cs-fixer": "^3.95.1", "symfony/console": "^6.4 || ^7.4 || ^8.0", "symfony/filesystem": "^6.4 || ^7.4 || ^8.0" }, diff --git a/rector.php b/rector.php index dba53ea..aa306d4 100644 --- a/rector.php +++ b/rector.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/src/Console/Application.php b/src/Console/Application.php index 64b6322..ab6024e 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,7 +16,6 @@ namespace TYPO3\CodingStandards\Console; -use RuntimeException; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; @@ -38,7 +37,7 @@ final class Application extends BaseApplication /** * getcwd() equivalent which always returns a string. * - * @throws RuntimeException + * @throws \RuntimeException */ private static function getCwd(bool $allowEmpty = false): string { @@ -57,7 +56,7 @@ private static function getCwd(bool $allowEmpty = false): string return ''; } - throw new RuntimeException('Could not determine the current working directory'); + throw new \RuntimeException('Could not determine the current working directory'); } // @codeCoverageIgnoreEnd @@ -71,7 +70,7 @@ public static function getProjectDir(): string } /** - * @throws RuntimeException + * @throws \RuntimeException */ public static function getTargetDir(InputInterface $input): string { @@ -87,7 +86,7 @@ public static function getTargetDir(InputInterface $input): string } if (!is_dir($targetDir)) { - throw new RuntimeException(\sprintf('Invalid target directory specified, %s does not exist.', $targetDir)); + throw new \RuntimeException(sprintf('Invalid target directory specified, %s does not exist.', $targetDir)); } return $targetDir; diff --git a/src/Console/Command/Command.php b/src/Console/Command/Command.php index c1f146c..ad0b013 100644 --- a/src/Console/Command/Command.php +++ b/src/Console/Command/Command.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/src/Console/Command/SetupCommand.php b/src/Console/Command/SetupCommand.php index e9547b9..4911cb0 100644 --- a/src/Console/Command/SetupCommand.php +++ b/src/Console/Command/SetupCommand.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,7 +16,6 @@ namespace TYPO3\CodingStandards\Console\Command; -use RuntimeException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -73,7 +72,7 @@ private function getRuleSets(InputInterface $input): array } /** - * @throws RuntimeException + * @throws \RuntimeException */ private function getType(InputInterface $input): string { @@ -84,22 +83,22 @@ private function getType(InputInterface $input): string $composerManifest = $this->getProjectDir() . '/composer.json'; if (!file_exists($composerManifest)) { - throw new RuntimeException(sprintf($composerManifestError, 'found')); + throw new \RuntimeException(sprintf($composerManifestError, 'found')); } - $composerManifest = \file_get_contents($composerManifest); + $composerManifest = file_get_contents($composerManifest); if ($composerManifest === false) { - throw new RuntimeException(sprintf($composerManifestError, 'read')); // @codeCoverageIgnore + throw new \RuntimeException(sprintf($composerManifestError, 'read')); // @codeCoverageIgnore } - $composerManifest = \json_decode($composerManifest, true); + $composerManifest = json_decode($composerManifest, true); if ($composerManifest === false || !is_array($composerManifest)) { - throw new RuntimeException(sprintf($composerManifestError, 'decoded')); + throw new \RuntimeException(sprintf($composerManifestError, 'decoded')); } if ( - ($composerManifest['type'] ?? '') === 'typo3-cms-extension' || - ($composerManifest['extra']['typo3/cms']['extension-key'] ?? '') !== '' + ($composerManifest['type'] ?? '') === 'typo3-cms-extension' + || ($composerManifest['extra']['typo3/cms']['extension-key'] ?? '') !== '' ) { $type = Setup::EXTENSION; } else { @@ -120,11 +119,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $result = true; - if (\in_array(Setup::RULE_SET_EDITORCONFIG, $ruleSets, true)) { + if (in_array(Setup::RULE_SET_EDITORCONFIG, $ruleSets, true)) { $result = $setup->copyEditorConfig($force); } - if (\in_array(Setup::RULE_SET_PHP_CS_FIXER, $ruleSets, true)) { + if (in_array(Setup::RULE_SET_PHP_CS_FIXER, $ruleSets, true)) { $result = $setup->copyPhpCsFixerConfig($force, $type) && $result; } diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 29b7e5c..7b54e1a 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/src/CsFixerConfig.php b/src/CsFixerConfig.php index 51b5eb4..b73b020 100644 --- a/src/CsFixerConfig.php +++ b/src/CsFixerConfig.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -41,20 +41,11 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface */ protected static $typo3Rules = [ '@DoctrineAnnotation' => true, - // @todo: Switch to @PER-CS2x0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247 - '@PER-CS1x0' => true, - 'array_indentation' => true, - 'array_syntax' => ['syntax' => 'short'], + '@PER-CS3x0' => true, + // Override PER-CS3x0 default (single) to keep no space after cast operators 'cast_spaces' => ['space' => 'none'], - // @todo: Can be dropped once we enable @PER-CS2x0 - 'concat_space' => ['spacing' => 'one'], - 'declare_equal_normalize' => ['space' => 'none'], 'declare_parentheses' => true, 'dir_constant' => true, - // @todo: Can be dropped once we enable @PER-CS2x0 - 'function_declaration' => [ - 'closure_fn_spacing' => 'none', - ], 'function_to_constant' => [ 'functions' => [ 'get_called_class', @@ -72,8 +63,6 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface 'import_functions' => false, ], 'list_syntax' => ['syntax' => 'short'], - // @todo: Can be dropped once we enable @PER-CS2x0 - 'method_argument_space' => true, 'modernize_strpos' => true, 'modernize_types_casting' => true, 'native_function_casing' => true, @@ -97,6 +86,7 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_nullsafe_operator' => true, + // Override PER-CS3x0 default (union) to keep ?Type shorthand syntax 'nullable_type_declaration' => [ 'syntax' => 'question_mark', ], @@ -132,12 +122,8 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface 'phpdoc_types' => true, 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'protected_to_private' => true, - 'return_type_declaration' => ['space_before' => 'none'], 'single_quote' => true, - 'single_space_around_construct' => true, 'single_line_comment_style' => ['comment_types' => ['hash']], - // @todo: Can be dropped once we enable @PER-CS2x0 - 'single_line_empty_body' => true, 'trailing_comma_in_multiline' => ['elements' => ['arrays']], 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], diff --git a/src/CsFixerConfigInterface.php b/src/CsFixerConfigInterface.php index a8a714a..2c25a66 100644 --- a/src/CsFixerConfigInterface.php +++ b/src/CsFixerConfigInterface.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/src/Setup.php b/src/Setup.php index 62cc30a..4b403f6 100644 --- a/src/Setup.php +++ b/src/Setup.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,7 +16,6 @@ namespace TYPO3\CodingStandards; -use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Style\StyleInterface; @@ -61,7 +60,7 @@ final class Setup private readonly StyleInterface $style; /** - * @throws RuntimeException + * @throws \RuntimeException */ public function __construct(string $targetDir, ?StyleInterface $style = null) { @@ -69,17 +68,17 @@ public function __construct(string $targetDir, ?StyleInterface $style = null) $targetDir = '.'; // @codeCoverageIgnore } - if (!\is_dir($targetDir)) { - throw new RuntimeException(sprintf("Target directory '%s' does not exist.", $targetDir)); + if (!is_dir($targetDir)) { + throw new \RuntimeException(sprintf("Target directory '%s' does not exist.", $targetDir)); } // Normalize separators on Windows if ('\\' === \DIRECTORY_SEPARATOR) { - $targetDir = \str_replace('\\', '/', $targetDir); // @codeCoverageIgnore + $targetDir = str_replace('\\', '/', $targetDir); // @codeCoverageIgnore } - $this->targetDir = \rtrim($targetDir, '/'); - $this->templatesPath = \dirname(__DIR__) . '/' . 'templates'; + $this->targetDir = rtrim($targetDir, '/'); + $this->templatesPath = dirname(__DIR__) . '/' . 'templates'; if (!$style instanceof StyleInterface) { $arrayInput = new ArrayInput([]); @@ -114,12 +113,12 @@ public function forExtension(bool $force): int } /** - * @throws RuntimeException + * @throws \RuntimeException */ public function copyPhpCsFixerConfig(bool $force, string $type): bool { if (!in_array($type, self::VALID_TYPES, true)) { - throw new RuntimeException(sprintf('Invalid type (%s) specified.', $type)); + throw new \RuntimeException(sprintf('Invalid type (%s) specified.', $type)); } $targetFile = '.php-cs-fixer.dist.php'; @@ -145,7 +144,7 @@ public function copyPhpCsFixerConfig(bool $force, string $type): bool } if (file_exists($targetFilepath)) { - $this->style->error(\sprintf( + $this->style->error(sprintf( 'A %s file already exists, nothing copied. Use the --force option to overwrite the file.', $targetFile )); @@ -173,7 +172,7 @@ public function copyEditorConfig(bool $force): bool $targetFilepath = $this->targetDir . '/' . $targetFile; if (!$force && file_exists($targetFilepath)) { - $this->style->error(\sprintf( + $this->style->error(sprintf( 'A %s file already exists, nothing copied. Use the update command or the --force option to overwrite the file.', $targetFile )); @@ -184,7 +183,7 @@ public function copyEditorConfig(bool $force): bool $this->templatesPath . '/editorconfig.dist', $targetFilepath ); - $this->style->success(\sprintf('%s created.', $targetFile)); + $this->style->success(sprintf('%s created.', $targetFile)); return true; } diff --git a/tests/Console/Style/SimpleStyle.php b/tests/Console/Style/SimpleStyle.php index 2be8ade..485ed09 100644 --- a/tests/Console/Style/SimpleStyle.php +++ b/tests/Console/Style/SimpleStyle.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -72,7 +72,7 @@ public function __construct(InputInterface $input, OutputInterface $output) */ public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = true): void { - $messages = \is_array($messages) ? array_values($messages) : [$messages]; + $messages = is_array($messages) ? array_values($messages) : [$messages]; $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape)); } @@ -112,7 +112,7 @@ public function listing(array $elements): void */ public function text($message): void { - $messages = \is_array($message) ? array_values($message) : [$message]; + $messages = is_array($message) ? array_values($message) : [$message]; foreach ($messages as $message) { $this->writeln(sprintf(' %s', $message)); } @@ -227,12 +227,12 @@ public function definitionList(...$list): void $row[] = $value; continue; } - if (\is_string($value)) { + if (is_string($value)) { $headers[] = new TableCell($value, ['colspan' => 2]); $row[] = null; continue; } - if (!\is_array($value)) { + if (!is_array($value)) { throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.'); } $headers[] = key($value); @@ -453,7 +453,7 @@ private function createBlock(iterable $messages, ?string $type = null, ?string $ if ($type !== null) { $type = sprintf('[%s] ', $type); - $indentLength = \strlen($type); + $indentLength = strlen($type); $lineIndentation = str_repeat(' ', $indentLength); } @@ -466,7 +466,7 @@ private function createBlock(iterable $messages, ?string $type = null, ?string $ //$lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true))); $lines = array_merge($lines, [$message]); - if (\count($messages) > 1 && $key < \count($messages) - 1) { + if (count($messages) > 1 && $key < count($messages) - 1) { $lines[] = ''; } } diff --git a/tests/Unit/Console/ApplicationTest.php b/tests/Unit/Console/ApplicationTest.php index 19d1f92..fda76f6 100644 --- a/tests/Unit/Console/ApplicationTest.php +++ b/tests/Unit/Console/ApplicationTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,7 +16,6 @@ namespace TYPO3\CodingStandards\Tests\Unit\Console; -use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Tester\ApplicationTester; use TYPO3\CodingStandards\Console\Application; @@ -51,7 +50,7 @@ public function testMajorVersion(): void public function testGetTargetDir(): void { $testPath = self::getTestPath(); - \mkdir($testPath . '/test-target'); + mkdir($testPath . '/test-target'); $input = new ArrayInput([]); self::assertSame($testPath, Application::getTargetDir($input)); @@ -65,7 +64,7 @@ public function testGetTargetDir(): void public function testGetTargetDirThrowsOnInvalidPath(): void { - self::expectException(RuntimeException::class); + self::expectException(\RuntimeException::class); self::expectExceptionMessageMatches('#Invalid target directory specified, /.*/invalid-target does not exist.#'); self::getTestPath(); diff --git a/tests/Unit/Console/Command/CommandTest.php b/tests/Unit/Console/Command/CommandTest.php index af5e6a1..6356ca0 100644 --- a/tests/Unit/Console/Command/CommandTest.php +++ b/tests/Unit/Console/Command/CommandTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -54,7 +54,7 @@ public function testGetProjectDir(): void public function testGetTargetDir(): void { $testPath = self::getTestPath(); - \mkdir($testPath . '/test-target'); + mkdir($testPath . '/test-target'); /** @var CommandTestImplementation $baseCommand */ $baseCommand = $this->getCommand(''); diff --git a/tests/Unit/Console/Command/CommandTestCase.php b/tests/Unit/Console/Command/CommandTestCase.php index 4eb43f4..8f49966 100644 --- a/tests/Unit/Console/Command/CommandTestCase.php +++ b/tests/Unit/Console/Command/CommandTestCase.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Console/Command/CommandTestImplementation.php b/tests/Unit/Console/Command/CommandTestImplementation.php index 7fe2ca4..e00d682 100644 --- a/tests/Unit/Console/Command/CommandTestImplementation.php +++ b/tests/Unit/Console/Command/CommandTestImplementation.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Console/Command/SetupCommandTest.php b/tests/Unit/Console/Command/SetupCommandTest.php index cc12456..0a2980e 100644 --- a/tests/Unit/Console/Command/SetupCommandTest.php +++ b/tests/Unit/Console/Command/SetupCommandTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,8 +16,6 @@ namespace TYPO3\CodingStandards\Tests\Unit\Console\Command; -use Generator; -use RuntimeException; use TYPO3\CodingStandards\Console\Application; use TYPO3\CodingStandards\Console\Command\Command; use TYPO3\CodingStandards\Console\Command\SetupCommand; @@ -38,9 +36,9 @@ public function testTypeArgument(string $type): void } /** - * @return Generator> + * @return \Generator> */ - public static function typeDataProvider(): Generator + public static function typeDataProvider(): \Generator { foreach (Setup::VALID_TYPES as $type) { yield $type => [ @@ -55,7 +53,7 @@ public function testMissingTypeThrows(): void $commandTester = $this->getCommandTester('setup'); - self::expectException(RuntimeException::class); + self::expectException(\RuntimeException::class); self::expectExceptionMessageMatches('#.+(type).+#'); $commandTester->execute($this->getInput($testPath)); @@ -69,7 +67,7 @@ public function testInvalidComposerManifestThrows(): void $commandTester = $this->getCommandTester('setup'); - self::expectException(RuntimeException::class); + self::expectException(\RuntimeException::class); self::expectExceptionMessageMatches('#.+(type).+#'); $commandTester->execute($this->getInput($testPath)); @@ -90,7 +88,7 @@ public function testSetup( array $expectedFiles ): void { $testPath = self::getTestPath(); - $targetPath = \rtrim($testPath . '/' . $targetDir, '/'); + $targetPath = rtrim($testPath . '/' . $targetDir, '/'); self::getFilesystem()->mkdir($targetPath); self::createFiles($testPath, $existingFiles); @@ -111,7 +109,7 @@ public function testSetup( } /** - * @return Generator, * targetDir: string, * force: bool, @@ -120,7 +118,7 @@ public function testSetup( * expectedFiles: array * }> */ - public static function setupDataProvider(): Generator + public static function setupDataProvider(): \Generator { yield 'auto-detect extension from type' => [ 'existingFiles' => [ diff --git a/tests/Unit/Console/Command/SetupCommandTestCase.php b/tests/Unit/Console/Command/SetupCommandTestCase.php index 6658a97..2f0bcf2 100644 --- a/tests/Unit/Console/Command/SetupCommandTestCase.php +++ b/tests/Unit/Console/Command/SetupCommandTestCase.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Console/Command/UpdateCommandTest.php b/tests/Unit/Console/Command/UpdateCommandTest.php index e562b08..899b13a 100644 --- a/tests/Unit/Console/Command/UpdateCommandTest.php +++ b/tests/Unit/Console/Command/UpdateCommandTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Console/Command/UpdateCommandTestCase.php b/tests/Unit/Console/Command/UpdateCommandTestCase.php index a12fc1f..044ffe6 100644 --- a/tests/Unit/Console/Command/UpdateCommandTestCase.php +++ b/tests/Unit/Console/Command/UpdateCommandTestCase.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/CsFixerConfigTest.php b/tests/Unit/CsFixerConfigTest.php index 415023c..43f4869 100644 --- a/tests/Unit/CsFixerConfigTest.php +++ b/tests/Unit/CsFixerConfigTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/SetupTest.php b/tests/Unit/SetupTest.php index 42aa87d..75e2225 100644 --- a/tests/Unit/SetupTest.php +++ b/tests/Unit/SetupTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -16,8 +16,6 @@ namespace TYPO3\CodingStandards\Tests\Unit; -use Generator; -use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use TYPO3\CodingStandards\Setup; @@ -153,7 +151,7 @@ public function testForExtensionScenarios( } /** - * @return Generator, * force: bool, * expectedResult: int, @@ -161,7 +159,7 @@ public function testForExtensionScenarios( * expectedFiles: array * }> */ - public static function scenariosProvider(): Generator + public static function scenariosProvider(): \Generator { yield 'all files are created' => [ 'existingFiles' => [], @@ -339,9 +337,9 @@ public function testCopyPhpCsFixerConfig(string $type): void } /** - * @return Generator> + * @return \Generator> */ - public static function typeDataProvider(): Generator + public static function typeDataProvider(): \Generator { foreach (Setup::VALID_TYPES as $type) { yield $type => [ @@ -354,7 +352,7 @@ public function testInvalidPathThrows(): void { $testPath = self::getTestPath() . '/invalid-path'; - self::expectException(RuntimeException::class); + self::expectException(\RuntimeException::class); self::expectExceptionMessageMatches('#.+(invalid-path).+#'); new Setup($testPath); @@ -377,7 +375,7 @@ public function testIoIsCreated(): void public function testInvalidTypeThrows(): void { - self::expectException(RuntimeException::class); + self::expectException(\RuntimeException::class); self::expectExceptionMessageMatches('#.+(type).+#'); $setup = new Setup(self::getTestPath()); diff --git a/tests/Unit/Smoke/AbstractCliTestCase.php b/tests/Unit/Smoke/AbstractCliTestCase.php index 06b4a2f..25330f4 100644 --- a/tests/Unit/Smoke/AbstractCliTestCase.php +++ b/tests/Unit/Smoke/AbstractCliTestCase.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Smoke/CliShortcutTest.php b/tests/Unit/Smoke/CliShortcutTest.php index b3920c6..074b9f3 100644 --- a/tests/Unit/Smoke/CliShortcutTest.php +++ b/tests/Unit/Smoke/CliShortcutTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Smoke/CliTest.php b/tests/Unit/Smoke/CliTest.php index 6181474..3bf5773 100644 --- a/tests/Unit/Smoke/CliTest.php +++ b/tests/Unit/Smoke/CliTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view diff --git a/tests/Unit/Smoke/InstallViaComposerTest.php b/tests/Unit/Smoke/InstallViaComposerTest.php index d1fd98d..a19ffee 100644 --- a/tests/Unit/Smoke/InstallViaComposerTest.php +++ b/tests/Unit/Smoke/InstallViaComposerTest.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -17,7 +17,6 @@ namespace TYPO3\CodingStandards\Tests\Unit\Smoke; use Keradus\CliExecutor\CommandExecutor; -use RuntimeException; use TYPO3\CodingStandards\Console\Application; use TYPO3\CodingStandards\Tests\Unit\TestCase; @@ -54,20 +53,20 @@ public static function setUpBeforeClass(): void try { CommandExecutor::create('php --version', __DIR__)->getResult(); - } catch (RuntimeException $runtimeException) { + } catch (\RuntimeException $runtimeException) { self::markTestIncomplete('Missing `php` env script. Details:' . "\n" . $runtimeException->getMessage()); } try { CommandExecutor::create('composer --version', __DIR__)->getResult(); - } catch (RuntimeException $runtimeException) { + } catch (\RuntimeException $runtimeException) { self::markTestIncomplete('Missing `composer` env script. Details:' . "\n" . $runtimeException->getMessage()); } try { CommandExecutor::create('composer check', self::getRootPath())->getResult(); - } catch (RuntimeException $runtimeException) { - if (\getenv('EXPERIMENTAL') !== 'true') { + } catch (\RuntimeException $runtimeException) { + if (getenv('EXPERIMENTAL') !== 'true') { self::markTestIncomplete('Composer check failed. Details:' . "\n" . $runtimeException->getMessage()); } } @@ -105,7 +104,7 @@ public function testInstallationViaPathIsPossible(): void public function testInstallationViaArtifactIsPossible(): void { // Composer Artifact Repository requires `zip` extension - if (!\extension_loaded('zip')) { + if (!extension_loaded('zip')) { self::markTestIncomplete('No zip extension available.'); } diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php index 5596186..34c999c 100644 --- a/tests/Unit/TestCase.php +++ b/tests/Unit/TestCase.php @@ -5,7 +5,7 @@ /* * This file is part of the TYPO3 project. * - * (c) 2019-2024 Benni Mack + * (c) 2019-2026 Benni Mack * Simon Gilli * * For the full copyright and license information, please view @@ -17,7 +17,6 @@ namespace TYPO3\CodingStandards\Tests\Unit; use PHPUnit\Framework\TestCase as BaseTestCase; -use RuntimeException; use Symfony\Component\Filesystem\Filesystem; abstract class TestCase extends BaseTestCase @@ -76,7 +75,7 @@ protected static function getFilename(string $filename, ?array $replacePairs = n return match ($prefix) { 'TPL' => self::getTemplateFilename($filename), 'FIX' => self::getFixtureFilename($filename), - default => throw new RuntimeException(sprintf('Invalid prefix (%s).', $prefix), 1_636_451_407), + default => throw new \RuntimeException(sprintf('Invalid prefix (%s).', $prefix), 1_636_451_407), }; } @@ -102,7 +101,7 @@ protected static function getTestPath(?string $subFolder = null): string $filesystem->remove($testPath); $filesystem->mkdir($testPath); - \chdir($testPath); + chdir($testPath); return $testPath; }