From 6e7481e5df76b6f693356a811d8e6287c5d51a5d Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Tue, 12 Dec 2023 10:55:31 +0100 Subject: [PATCH 1/4] [BUGFIX] Skip system/settings.php The config/system/settings.php is commonly updated through the TYPO3 backend and exported accordingly. Thus coding style standards can and should not be applied here. --- src/CsFixerConfig.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CsFixerConfig.php b/src/CsFixerConfig.php index 13bdac6..ca7b67f 100644 --- a/src/CsFixerConfig.php +++ b/src/CsFixerConfig.php @@ -107,6 +107,9 @@ public static function create(): static 'var', 'vendor', ]) + ->notPath([ + 'config/system/settings.php', + ]) ; return $static; From 0ed05704f3e745ebb4c771d3eb27dc7385101c53 Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Fri, 15 Dec 2023 09:42:20 +0100 Subject: [PATCH 2/4] [TASK] Reformat default extension PHP-CS-Fixer configuration Improve Git diff with newlines and have an empty line before "return". --- templates/extension_php-cs-fixer.dist.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/extension_php-cs-fixer.dist.php b/templates/extension_php-cs-fixer.dist.php index cc0061d..ebb9c20 100644 --- a/templates/extension_php-cs-fixer.dist.php +++ b/templates/extension_php-cs-fixer.dist.php @@ -1,5 +1,8 @@ getFinder()->in(__DIR__); +$config->getFinder() + ->in(__DIR__) +; + return $config; From bdb2aad7cf8fc639f0a34741949abf934d47d078 Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Fri, 15 Dec 2023 09:43:06 +0100 Subject: [PATCH 3/4] [TASK] Reformat default project PHP-CS-Fixer configuration Improve Git diff with newlines and have an empty line before "return". --- templates/project_php-cs-fixer.dist.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/project_php-cs-fixer.dist.php b/templates/project_php-cs-fixer.dist.php index 13430c8..e0be316 100644 --- a/templates/project_php-cs-fixer.dist.php +++ b/templates/project_php-cs-fixer.dist.php @@ -1,5 +1,8 @@ getFinder()->in(__DIR__ . '/src'); +$config->getFinder() + ->in(__DIR__ . '/src') +; + return $config; From 1f580d032c567b93e1eb47569230bf9c0773c919 Mon Sep 17 00:00:00 2001 From: Jochen Date: Sun, 28 Jan 2024 19:10:54 +0100 Subject: [PATCH 4/4] [TASK] Update CI --- composer.json | 4 ++-- rector.php | 2 +- src/CsFixerConfig.php | 9 +++++++++ tests/Unit/Console/Command/CommandTestImplementation.php | 4 +--- tests/Unit/CsFixerConfigTest.php | 2 +- typo3-coding-standards | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index b20d16e..32c94c2 100644 --- a/composer.json +++ b/composer.json @@ -31,13 +31,13 @@ "require": { "php": "^8.1", "ext-json": "*", - "friendsofphp/php-cs-fixer": "^3.16", + "friendsofphp/php-cs-fixer": "^3.30", "symfony/console": "^5.4 || ^6.0", "symfony/filesystem": "^5.4 || ^6.0" }, "require-dev": { "composer/package-versions-deprecated": "^1.11.99.5", - "ergebnis/composer-normalize": "*", + "ergebnis/composer-normalize": "^2.28", "keradus/cli-executor": "^1.5", "maglnet/composer-require-checker": "*", "nikic/php-parser": "^4.15.5", diff --git a/rector.php b/rector.php index 7b6c9c1..e9e7296 100644 --- a/rector.php +++ b/rector.php @@ -24,7 +24,7 @@ use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (RectorConfig $rectorConfig): void { +return static function(RectorConfig $rectorConfig): void { $rectorConfig->paths([ __DIR__ . '/src', __DIR__ . '/tests', diff --git a/src/CsFixerConfig.php b/src/CsFixerConfig.php index ca7b67f..642bd70 100644 --- a/src/CsFixerConfig.php +++ b/src/CsFixerConfig.php @@ -45,11 +45,20 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface 'array_syntax' => ['syntax' => 'short'], 'cast_spaces' => ['space' => 'none'], 'concat_space' => ['spacing' => 'one'], + 'curly_braces_position' => ['allow_single_line_empty_anonymous_classes' => true], 'declare_equal_normalize' => ['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']], 'function_typehint_space' => true, + 'function_declaration' => [ + 'closure_function_spacing' => 'none', + ], + 'single_line_throw' => false, + 'php_unit_internal_class' => false, + 'braces' => [ + 'allow_single_line_closure' => true, + ], 'modernize_strpos' => true, 'modernize_types_casting' => true, 'native_function_casing' => true, diff --git a/tests/Unit/Console/Command/CommandTestImplementation.php b/tests/Unit/Console/Command/CommandTestImplementation.php index 65a25c2..58f2b20 100644 --- a/tests/Unit/Console/Command/CommandTestImplementation.php +++ b/tests/Unit/Console/Command/CommandTestImplementation.php @@ -21,6 +21,4 @@ /** * @internal for testing only */ -final class CommandTestImplementation extends Command -{ -} +final class CommandTestImplementation extends Command {} diff --git a/tests/Unit/CsFixerConfigTest.php b/tests/Unit/CsFixerConfigTest.php index 300d7e4..219464e 100644 --- a/tests/Unit/CsFixerConfigTest.php +++ b/tests/Unit/CsFixerConfigTest.php @@ -27,7 +27,7 @@ public function testCreateReturnsCorrectClass(): void $csFixerConfig = CsFixerConfig::create(); self::assertInstanceOf(CsFixerConfig::class, $csFixerConfig); self::assertTrue($csFixerConfig->getRiskyAllowed()); - self::assertCount(46, $csFixerConfig->getRules()); + self::assertCount(51, $csFixerConfig->getRules()); } public function testAddRules(): void diff --git a/typo3-coding-standards b/typo3-coding-standards index 02cfefe..8b7fc94 100755 --- a/typo3-coding-standards +++ b/typo3-coding-standards @@ -16,7 +16,7 @@ /** * Loads Composer's autoload.php. */ -(static function (): void { +(static function(): void { $possibleAutoloaders = [ __DIR__ . '/../../autoload.php', __DIR__ . '/../autoload.php', @@ -32,7 +32,7 @@ } if ($autoloader === null) { - throw new \RuntimeException(sprintf('Unable to locate autoload.php file from %s.', __FILE__)); + throw new RuntimeException(sprintf('Unable to locate autoload.php file from %s.', __FILE__)); } require_once $autoloader;