From 5e815eaa296a431421de8a60a42b26592afc0c9e Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Tue, 25 Feb 2025 11:47:31 +0100 Subject: [PATCH 01/25] chore: update README.md to list php8.4 (#262) ~ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa706a15a4..ae23da3b9d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Killer Features -- Install on **any PHP 7.2-PHP 8.3** project with any dependencies +- Install on **any PHP 7.2-PHP 8.4** project with any dependencies - Blazing fast with parallel run out of the box - Use [PHP_CodeSniffer or PHP-CS-Fixer](https://tomasvotruba.com/blog/2017/05/03/combine-power-of-php-code-sniffer-and-php-cs-fixer-in-3-lines/) - anything you like - Use **prepared sets** and [PHP CS Fixer sets](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/ruleSets/index.rst) to save time From 262e23f3914c2e369bffe6fa895f82836a912fd9 Mon Sep 17 00:00:00 2001 From: Peter Fox Date: Sun, 9 Mar 2025 21:19:14 +0000 Subject: [PATCH 02/25] Adds PHP 84 migration set (#263) --- src/Configuration/ECSConfigBuilder.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index 0272d4dd04..4a2b85cd20 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -307,6 +307,7 @@ public function withPhpCsFixerSets( bool $php81Migration = false, bool $php82Migration = false, bool $php83Migration = false, + bool $php84Migration = false, bool $phpunit30MigrationRisky = false, bool $phpunit32MigrationRisky = false, bool $phpunit35MigrationRisky = false, @@ -423,6 +424,10 @@ public function withPhpCsFixerSets( $this->dynamicSets[] = '@PHP83Migration'; } + if ($php84Migration) { + $this->dynamicSets[] = '@PHP84Migration'; + } + if ($phpunit30MigrationRisky) { $this->dynamicSets[] = '@PHPUnit30Migration:risky'; } From 9f32559d684d6901f24ba99fb74502fa6789f44a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 17 Mar 2025 16:27:26 +0100 Subject: [PATCH 03/25] bump deps --- phpstan.neon | 1 - 1 file changed, 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 078787d9fd..d7a242a337 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -56,7 +56,6 @@ parameters: - tests/Skipper/Skipper/Skipper/SkipperTest.php - tests/Skipper/Skipper/Skip/SkipSkipperTest.php - tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php - - tests/FixerRunner/Application/FileProcessorTest.ph - src/Testing/PHPUnit/AbstractCheckerTestCase.php # optional From 2bbcbb90398b4bbd60f58496300d726d5136be83 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 25 Mar 2025 10:21:53 +0100 Subject: [PATCH 04/25] remove linter, too detailed + bump symplify cs --- .github/workflows/code_analysis.yaml | 4 ---- composer.json | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index b549c41cf8..49b1a0ce71 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -32,10 +32,6 @@ jobs: name: 'Tests' run: vendor/bin/phpunit - - - name: 'PHP Linter' - run: vendor/bin/parallel-lint src tests - - name: 'Check Active Classes' run: vendor/bin/class-leak check bin src --ansi diff --git a/composer.json b/composer.json index 6710fa79f9..24dbffbf27 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,11 @@ "squizlabs/php_codesniffer": "^3.11.3", "symfony/console": "^6.4.17", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.2.3", + "symplify/coding-standard": "^12.3.1", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0.3", @@ -36,7 +35,7 @@ "rector/rector": "^2.0.7", "rector/type-perfect": "^2.0.1", "symplify/phpstan-extensions": "^12.0", - "symplify/vendor-patches": "^11.3.7", + "symplify/vendor-patches": "^11.4", "tomasvotruba/class-leak": "^2.0", "tomasvotruba/type-coverage": "^2.0.1", "tomasvotruba/unused-public": "^2.0", From b103664a1c891093784eeb16e3269dbef225bc5e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 25 Mar 2025 10:30:27 +0100 Subject: [PATCH 05/25] bump to container 12 (#268) --- composer.json | 10 +++++----- phpstan.neon | 1 - src/Config/ECSConfig.php | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 24dbffbf27..cd904b992c 100644 --- a/composer.json +++ b/composer.json @@ -15,21 +15,21 @@ "php": ">=8.2", "composer/pcre": "^3.3.2", "composer/xdebug-handler": "^3.0.5", - "friendsofphp/php-cs-fixer": "^3.68.5", - "illuminate/container": "^11.40", + "friendsofphp/php-cs-fixer": "^3.73.1", + "illuminate/container": "^12.0", "nette/utils": "^4.0.5", "sebastian/diff": "^6.0.2", - "squizlabs/php_codesniffer": "^3.11.3", + "squizlabs/php_codesniffer": "^3.12", "symfony/console": "^6.4.17", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.3.1", + "symplify/coding-standard": "^12.3.2", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, "require-dev": { "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^2.1", - "phpstan/phpstan-phpunit": "^2.0.3", + "phpstan/phpstan-phpunit": "^2.0.5", "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^11.5.2", "rector/rector": "^2.0.7", diff --git a/phpstan.neon b/phpstan.neon index d7a242a337..42bf39da69 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,7 +13,6 @@ parameters: - rector.php excludePaths: - # deprecated, to be removed - scoper.php # tests diff --git a/src/Config/ECSConfig.php b/src/Config/ECSConfig.php index 80b7fdcd4e..6bd1e9d4bc 100644 --- a/src/Config/ECSConfig.php +++ b/src/Config/ECSConfig.php @@ -19,7 +19,6 @@ use Symplify\EasyCodingStandard\DependencyInjection\CompilerPass\RemoveMutualCheckersCompilerPass; use Symplify\EasyCodingStandard\DependencyInjection\SimpleParameterProvider; use Symplify\EasyCodingStandard\ValueObject\Option; -use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface; use Webmozart\Assert\Assert; use Webmozart\Assert\InvalidArgumentException; @@ -105,7 +104,7 @@ public function ruleWithConfiguration(string $checkerClass, array $configuration $this->autowireWhitespaceAwareFixer($checkerClass); if (is_a($checkerClass, FixerInterface::class, true)) { - Assert::isAnyOf($checkerClass, [ConfigurableFixerInterface::class, ConfigurableRuleInterface::class]); + Assert::isAOf($checkerClass, ConfigurableFixerInterface::class); $this->extend($checkerClass, static function (ConfigurableFixerInterface $configurableFixer) use ( $configuration ): ConfigurableFixerInterface { From a6baec0f5d29011822f21c98dda2b396cc0c28e4 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 25 Mar 2025 10:31:05 +0100 Subject: [PATCH 06/25] Bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd904b992c..294a519029 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "composer/pcre": "^3.3.2", "composer/xdebug-handler": "^3.0.5", "friendsofphp/php-cs-fixer": "^3.73.1", - "illuminate/container": "^12.0", + "illuminate/container": "^12.3", "nette/utils": "^4.0.5", "sebastian/diff": "^6.0.2", "squizlabs/php_codesniffer": "^3.12", From 42188f9b510eb0333001a510d90997a1fb252964 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 25 Mar 2025 10:58:51 +0100 Subject: [PATCH 07/25] cleanup preload --- build/target-repository/preload.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/target-repository/preload.php b/build/target-repository/preload.php index 43788e8d78..acd074b428 100644 --- a/build/target-repository/preload.php +++ b/build/target-repository/preload.php @@ -7,7 +7,5 @@ require_once __DIR__ . '/vendor/psr/container/src/ContainerExceptionInterface.php'; require_once __DIR__ . '/vendor/psr/container/src/NotFoundExceptionInterface.php'; require_once __DIR__ . '/vendor/psr/container/src/ContainerInterface.php'; -require_once __DIR__ . '/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/RuleDefinition.php'; -require_once __DIR__ . '/vendor/symplify/rule-doc-generator-contracts/src/Contract/DocumentedRuleInterface.php'; require_once __DIR__ . '/vendor/react/promise/src/functions.php'; require_once __DIR__ . '/vendor/symfony/deprecation-contracts/function.php'; From b07e6d8fdbea28ba68a8558887a0e0bbb631dca9 Mon Sep 17 00:00:00 2001 From: Matteo Trubini <7964032+matteotrubini@users.noreply.github.com> Date: Tue, 1 Apr 2025 05:37:30 +0200 Subject: [PATCH 08/25] [FIX] Psr12Test (#270) Ref https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/8459 First appeared in v3.74.0 Bump Composer to require v3.75.0 --- composer.json | 2 +- tests/Set/Psr12/Fixture/fixture.php.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 294a519029..0c5c2101e4 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=8.2", "composer/pcre": "^3.3.2", "composer/xdebug-handler": "^3.0.5", - "friendsofphp/php-cs-fixer": "^3.73.1", + "friendsofphp/php-cs-fixer": "^3.75.0", "illuminate/container": "^12.3", "nette/utils": "^4.0.5", "sebastian/diff": "^6.0.2", diff --git a/tests/Set/Psr12/Fixture/fixture.php.inc b/tests/Set/Psr12/Fixture/fixture.php.inc index 1a8a5d979a..a8afa19c41 100644 --- a/tests/Set/Psr12/Fixture/fixture.php.inc +++ b/tests/Set/Psr12/Fixture/fixture.php.inc @@ -142,8 +142,8 @@ factoryFunction($arg1, $arg2, [ declare(strict_types=1); namespace Vendor\Package; -use Vendor\Package\SomeNamespace\ClassD as D; use Vendor\Package\{ClassA as A, ClassB, ClassC as C}; +use Vendor\Package\SomeNamespace\ClassD as D; use function Vendor\Package\{functionA, functionB, functionC}; use const Vendor\Package\{ConstantA, ConstantB, ConstantC}; From f1fab01561a736ddc5fbf7dc354f9493d31917ed Mon Sep 17 00:00:00 2001 From: Matteo Trubini <7964032+matteotrubini@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:05:37 +0200 Subject: [PATCH 09/25] [IMP] SuperfluousConfigurationException message for the "common" set (#269) The error message lists all sets that should be removed, as they are already included, providing clearer guidance to the user. --- src/Configuration/ECSConfigBuilder.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index 4a2b85cd20..fc5189bf5e 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -229,9 +229,20 @@ public function withPreparedSets( // include all "common" sets $this->sets[] = SetList::COMMON; - if ($arrays || $spaces || $namespaces || $docblocks || $controlStructures || $phpunit || $comments) { + if (($alreadyIncludedSets = array_keys(array_filter([ + 'arrays' => $arrays, + 'spaces' => $spaces, + 'namespaces' => $namespaces, + 'docblocks' => $docblocks, + 'controlStructures' => $controlStructures, + 'phpunit' => $phpunit, + 'comments' => $comments, + ]))) !== []) { throw new SuperfluousConfigurationException( - 'This set is already included in the "common" set. You can remove it' + sprintf( + 'The following sets are already included in the "common" set: %s. Please remove them.', + implode(', ', $alreadyIncludedSets) + ) ); } } else { From 282a8b56bf7e5ffb3f052808181dd90190b1dcfc Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 23 Apr 2025 13:19:52 +0200 Subject: [PATCH 10/25] bump --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 0c5c2101e4..2bca73cdf5 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,11 @@ "composer/pcre": "^3.3.2", "composer/xdebug-handler": "^3.0.5", "friendsofphp/php-cs-fixer": "^3.75.0", - "illuminate/container": "^12.3", + "illuminate/container": "^12.10", "nette/utils": "^4.0.5", "sebastian/diff": "^6.0.2", - "squizlabs/php_codesniffer": "^3.12", - "symfony/console": "^6.4.17", + "squizlabs/php_codesniffer": "^3.12.2", + "symfony/console": "^6.4.20", "symfony/finder": "^7.2.2", "symplify/coding-standard": "^12.3.2", "symplify/easy-parallel": "^11.2.2", @@ -29,15 +29,15 @@ "require-dev": { "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^2.1", - "phpstan/phpstan-phpunit": "^2.0.5", + "phpstan/phpstan-phpunit": "^2.0.6", "phpstan/phpstan-webmozart-assert": "^2.0", - "phpunit/phpunit": "^11.5.2", - "rector/rector": "^2.0.7", - "rector/type-perfect": "^2.0.1", + "phpunit/phpunit": "^11.5", + "rector/rector": "^2.0.12", + "rector/type-perfect": "^2.0.2", "symplify/phpstan-extensions": "^12.0", "symplify/vendor-patches": "^11.4", "tomasvotruba/class-leak": "^2.0", - "tomasvotruba/type-coverage": "^2.0.1", + "tomasvotruba/type-coverage": "^2.0.2", "tomasvotruba/unused-public": "^2.0", "tracy/tracy": "^2.10.9" }, From 4e1d3a1e67302697f756987eda78cc4a9b9b8be6 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 28 Apr 2025 00:48:08 +0200 Subject: [PATCH 11/25] bump symplify cs (#275) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2bca73cdf5..c53c3ed66e 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "squizlabs/php_codesniffer": "^3.12.2", "symfony/console": "^6.4.20", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.3.2", + "symplify/coding-standard": "^12.3.3", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, From 5b5548f2d1c492b6a92067acf68b129efc1215bb Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 28 Apr 2025 01:30:53 +0200 Subject: [PATCH 12/25] cs --- config/set/symplify.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/set/symplify.php b/config/set/symplify.php index 36a27ddb07..0c6a7ab165 100644 --- a/config/set/symplify.php +++ b/config/set/symplify.php @@ -4,6 +4,7 @@ use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemoveSetterGetterDocblockFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer; @@ -21,6 +22,7 @@ RemovePHPStormAnnotationFixer::class, ParamReturnAndVarTagMalformsFixer::class, RemoveUselessDefaultCommentFixer::class, + RemoveSetterGetterDocblockFixer::class, // arrays ArrayListItemNewlineFixer::class, From f36d7f6cac9e24135a223cad55700da365ddd6f8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 28 Apr 2025 08:56:47 +0200 Subject: [PATCH 13/25] Bump rector config syntax downgrade --- build/rector-downgrade-php-72.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/build/rector-downgrade-php-72.php b/build/rector-downgrade-php-72.php index 0f32817a5a..e80b098913 100644 --- a/build/rector-downgrade-php-72.php +++ b/build/rector-downgrade-php-72.php @@ -3,15 +3,11 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Set\ValueObject\DowngradeLevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->parallel(); - $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); - - $rectorConfig->skip([ +return RectorConfig::configure() + ->withDowngradeSets(php72: true) + ->withSkip([ '*/Tests/*', '*/tests/*', '*/Fixtures/DirectoryExpansion/.hiddenAbove/*' ]); -}; From f223a1b97f47bbcf50a6269a29fe9eb19a584cce Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 28 Apr 2025 08:58:16 +0200 Subject: [PATCH 14/25] add rector as dev --- full_ecs_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/full_ecs_build.sh b/full_ecs_build.sh index 4b23a8f572..495208ea29 100644 --- a/full_ecs_build.sh +++ b/full_ecs_build.sh @@ -11,7 +11,7 @@ rm -rf tests vendor/phpcsstandards/php_codesniffer/tests vendor/phpcsstandards/p # downgrade with rector mkdir rector-local -composer require rector/rector --working-dir rector-local +composer require rector/rector --working-dir rector-local --dev rector-local/vendor/bin/rector process bin config/config.php src vendor --config build/rector-downgrade-php-72.php --ansi # prefix From 49cf8dffd0117dc7b5db8c234b60649c8a52adb3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 13 May 2025 15:04:15 +0200 Subject: [PATCH 15/25] bump, add new fixers --- composer.json | 4 ++-- config/set/symplify.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index c53c3ed66e..10cbb0688a 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,10 @@ "illuminate/container": "^12.10", "nette/utils": "^4.0.5", "sebastian/diff": "^6.0.2", - "squizlabs/php_codesniffer": "^3.12.2", + "squizlabs/php_codesniffer": "^3.13", "symfony/console": "^6.4.20", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.3.3", + "symplify/coding-standard": "^12.4", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, diff --git a/config/set/symplify.php b/config/set/symplify.php index 0c6a7ab165..bcb3c98c61 100644 --- a/config/set/symplify.php +++ b/config/set/symplify.php @@ -4,7 +4,8 @@ use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; -use Symplify\CodingStandard\Fixer\Annotation\RemoveSetterGetterDocblockFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemoveMethodNameDuplicateDescriptionFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemovePropertyVariableNameDescriptionFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer; @@ -22,7 +23,8 @@ RemovePHPStormAnnotationFixer::class, ParamReturnAndVarTagMalformsFixer::class, RemoveUselessDefaultCommentFixer::class, - RemoveSetterGetterDocblockFixer::class, + RemoveMethodNameDuplicateDescriptionFixer::class, + RemovePropertyVariableNameDescriptionFixer::class, // arrays ArrayListItemNewlineFixer::class, From e5b22f3ceba50d4c0695cbc499c9abd0658322b6 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 13 May 2025 15:12:35 +0200 Subject: [PATCH 16/25] bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 10cbb0688a..90cb4df041 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "squizlabs/php_codesniffer": "^3.13", "symfony/console": "^6.4.20", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.4", + "symplify/coding-standard": "^12.4.1", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, From 6d98357f342ffa49fbe19a3ea473b1bb104cb41d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 13 May 2025 15:12:56 +0200 Subject: [PATCH 17/25] cs --- config/set/symplify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/set/symplify.php b/config/set/symplify.php index bcb3c98c61..3d7efbfc0a 100644 --- a/config/set/symplify.php +++ b/config/set/symplify.php @@ -3,8 +3,8 @@ declare(strict_types=1); use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; -use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; use Symplify\CodingStandard\Fixer\Annotation\RemoveMethodNameDuplicateDescriptionFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; use Symplify\CodingStandard\Fixer\Annotation\RemovePropertyVariableNameDescriptionFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; From a0a5a7bcd110a85d62b2b84944f49aac54a8eb1c Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 14 May 2025 11:14:21 +0200 Subject: [PATCH 18/25] already included in smyplify set --- ecs.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/ecs.php b/ecs.php index a86e80b472..06b91faf50 100644 --- a/ecs.php +++ b/ecs.php @@ -2,13 +2,11 @@ declare(strict_types=1); -use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; return ECSConfig::configure() ->withPaths([__DIR__ . '/bin', __DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests']) ->withEditorConfig() - ->withRules([LineLengthFixer::class]) ->withRootFiles() ->withSkip(['*/Source/*', '*/Fixture/*']) ->withPreparedSets(symplify: true, psr12: true, common: true); From 9f984214dcbf7a93bfce9a2b9adb8e701f3cd5b4 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 14 May 2025 11:27:52 +0200 Subject: [PATCH 19/25] fix prepared sets config for PHP 7.4 and bellow --- src/Configuration/ConfigInitializer.php | 30 +++++++++++++++---- templates/ecs.php.dist | 14 +++------ templates/include/prepared_sets_php74.php.inc | 7 +++++ templates/include/prepared_sets_php80.php.inc | 7 +++++ 4 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 templates/include/prepared_sets_php74.php.inc create mode 100644 templates/include/prepared_sets_php80.php.inc diff --git a/src/Configuration/ConfigInitializer.php b/src/Configuration/ConfigInitializer.php index 0818716c82..5d96edad3b 100644 --- a/src/Configuration/ConfigInitializer.php +++ b/src/Configuration/ConfigInitializer.php @@ -37,7 +37,7 @@ public function createConfig(string $projectDirectory): void // config already exists, nothing to add if ($doesConfigExist) { $this->symfonyStyle->warning( - 'We found ecs.php config, but with no rules in it. Register some rules or sets there first' + 'We found ecs.php config, but no rules in it. Register some rules or sets there first' ); return; } @@ -52,10 +52,8 @@ public function createConfig(string $projectDirectory): void $templateFileContents = FileSystem::read(__DIR__ . '/../../templates/ecs.php.dist'); - $projectPhpDirectories = $this->initPathsResolver->resolve($projectDirectory); - $projectPhpDirectoriesContents = $this->createPathsString($projectPhpDirectories); - - $templateFileContents = str_replace('__PATHS__', $projectPhpDirectoriesContents, $templateFileContents); + $templateFileContents = $this->fillPaths($projectDirectory, $templateFileContents); + $templateFileContents = $this->fillPreparedSets($projectDirectory, $templateFileContents); // create the ecs.php file FileSystem::write(getcwd() . '/ecs.php', $templateFileContents, null); @@ -63,6 +61,14 @@ public function createConfig(string $projectDirectory): void $this->symfonyStyle->success('The ecs.php config was generated! Re-run the command to tidy your code'); } + private function fillPaths(string $projectDirectory, string $templateFileContents): string + { + $projectPhpDirectories = $this->initPathsResolver->resolve($projectDirectory); + $projectPhpDirectoriesContents = $this->createPathsString($projectPhpDirectories); + + return str_replace('__PATHS__', $projectPhpDirectoriesContents, $templateFileContents); + } + /** * @param string[] $projectPhpDirectories */ @@ -75,4 +81,18 @@ private function createPathsString(array $projectPhpDirectories): string return rtrim($projectPhpDirectoriesContents); } + + private function fillPreparedSets(string $projectDirectory, string $templateFileContents): string|array + { + $templateFileContents = $this->fillPaths($projectDirectory, $templateFileContents); + + if (PHP_VERSION_ID < 80000) { + $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/includes/prepared_sets_php74.php.inc'); + } else { + // PHP 8.0+ uses named arguments + $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/includes/prepared_sets_php80.php.inc'); + } + + return str_replace('__PREPARED_SETS__', $preparedSetTemplate, $templateFileContents); + } } diff --git a/templates/ecs.php.dist b/templates/ecs.php.dist index 3631ce5ba1..320b1c94e3 100644 --- a/templates/ecs.php.dist +++ b/templates/ecs.php.dist @@ -15,13 +15,7 @@ __PATHS__ NoUnusedImportsFixer::class, ]) - // add sets - group of rules - // ->withPreparedSets( - // arrays: true, - // namespaces: true, - // spaces: true, - // docblocks: true, - // comments: true, - // ) - - ; + // add sets - group of rules, from easiest to more complex ones + // uncomment one, apply one, commit, PR, merge and repeat + __PREPARED_SETS__ + ; diff --git a/templates/include/prepared_sets_php74.php.inc b/templates/include/prepared_sets_php74.php.inc new file mode 100644 index 0000000000..7fa96b1b13 --- /dev/null +++ b/templates/include/prepared_sets_php74.php.inc @@ -0,0 +1,7 @@ +// ->withSets( + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::SPACES, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::NAMESPACES, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::DOCBLOCKS, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::ARRAYS, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::COMMENTS, +// ) diff --git a/templates/include/prepared_sets_php80.php.inc b/templates/include/prepared_sets_php80.php.inc new file mode 100644 index 0000000000..2c0069edd6 --- /dev/null +++ b/templates/include/prepared_sets_php80.php.inc @@ -0,0 +1,7 @@ +// ->withPreparedSets( + // spaces: true, + // namespaces: true, + // docblocks: true, + // arrays: true, + // comments: true, +// ) From 2e3230c1c598a42c82dd792c234e1a04fee9123f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 14 May 2025 11:35:09 +0200 Subject: [PATCH 20/25] [config] add PHP 7.4 or 8.0 syntax for init config of ecs.php --- src/Configuration/ConfigInitializer.php | 6 +++--- src/Configuration/ECSConfigBuilder.php | 7 +++++++ templates/ecs.php.dist | 2 +- templates/include/prepared_sets_php74.php.inc | 14 +++++++------- templates/include/prepared_sets_php80.php.inc | 14 +++++++------- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Configuration/ConfigInitializer.php b/src/Configuration/ConfigInitializer.php index 5d96edad3b..d012c345dc 100644 --- a/src/Configuration/ConfigInitializer.php +++ b/src/Configuration/ConfigInitializer.php @@ -87,12 +87,12 @@ private function fillPreparedSets(string $projectDirectory, string $templateFile $templateFileContents = $this->fillPaths($projectDirectory, $templateFileContents); if (PHP_VERSION_ID < 80000) { - $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/includes/prepared_sets_php74.php.inc'); + $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/include/prepared_sets_php74.php.inc'); } else { // PHP 8.0+ uses named arguments - $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/includes/prepared_sets_php80.php.inc'); + $preparedSetTemplate = FileSystem::read(__DIR__ . '/../../templates/include/prepared_sets_php80.php.inc'); } - return str_replace('__PREPARED_SETS__', $preparedSetTemplate, $templateFileContents); + return str_replace('__PREPARED_SETS__', rtrim($preparedSetTemplate), $templateFileContents); } } diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index fc5189bf5e..79f913cb4f 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -21,6 +21,7 @@ use Symplify\EasyCodingStandard\Configuration\EditorConfig\EndOfLine; use Symplify\EasyCodingStandard\Configuration\EditorConfig\IndentStyle; use Symplify\EasyCodingStandard\Configuration\EditorConfig\QuoteType; +use Symplify\EasyCodingStandard\Exception\Configuration\InitializationException; use Symplify\EasyCodingStandard\Exception\Configuration\SuperfluousConfigurationException; use Symplify\EasyCodingStandard\ValueObject\Option; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; @@ -221,6 +222,12 @@ public function withPreparedSets( /** @see SetList::CLEAN_CODE */ bool $cleanCode = false, ): self { + if (func_get_args() === []) { + throw new InitializationException( + 'Pick at least one set in "->withPreparedSets()" in your ecs.php using named arguments, e.g. "->withPreparedSets(spaces: true)"' + ); + } + if ($psr12) { $this->sets[] = SetList::PSR_12; } diff --git a/templates/ecs.php.dist b/templates/ecs.php.dist index 320b1c94e3..f6f57eb6d5 100644 --- a/templates/ecs.php.dist +++ b/templates/ecs.php.dist @@ -17,5 +17,5 @@ __PATHS__ // add sets - group of rules, from easiest to more complex ones // uncomment one, apply one, commit, PR, merge and repeat - __PREPARED_SETS__ +__PREPARED_SETS__ ; diff --git a/templates/include/prepared_sets_php74.php.inc b/templates/include/prepared_sets_php74.php.inc index 7fa96b1b13..e10f788f40 100644 --- a/templates/include/prepared_sets_php74.php.inc +++ b/templates/include/prepared_sets_php74.php.inc @@ -1,7 +1,7 @@ -// ->withSets( - // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::SPACES, - // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::NAMESPACES, - // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::DOCBLOCKS, - // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::ARRAYS, - // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::COMMENTS, -// ) + ->withSets( + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::SPACES, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::NAMESPACES, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::DOCBLOCKS, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::ARRAYS, + // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::COMMENTS, + ) diff --git a/templates/include/prepared_sets_php80.php.inc b/templates/include/prepared_sets_php80.php.inc index 2c0069edd6..18023261e9 100644 --- a/templates/include/prepared_sets_php80.php.inc +++ b/templates/include/prepared_sets_php80.php.inc @@ -1,7 +1,7 @@ -// ->withPreparedSets( - // spaces: true, - // namespaces: true, - // docblocks: true, - // arrays: true, - // comments: true, -// ) + ->withPreparedSets( + // spaces: true, + // namespaces: true, + // docblocks: true, + // arrays: true, + // comments: true, + ) From 075c9f7827406536ae470d3d1b7d5cf278f9e058 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 23 May 2025 10:05:46 +0200 Subject: [PATCH 21/25] cs fixes --- phpstan.neon | 7 ++++++- src/Configuration/ConfigInitializer.php | 2 +- templates/include/prepared_sets_php74.php.inc | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 42bf39da69..468e0e2e92 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: level: 8 - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false # requires exact closure types checkMissingCallableSignature: true @@ -76,3 +76,8 @@ parameters: # hack to autoload contants - '#Call to new PHP_CodeSniffer\\Util\\Tokens\(\) on a separate line has no effect#' + + # php version condition + - + identifier: smaller.alwaysFalse + path: src/Configuration/ConfigInitializer.php diff --git a/src/Configuration/ConfigInitializer.php b/src/Configuration/ConfigInitializer.php index d012c345dc..cfdb7d6001 100644 --- a/src/Configuration/ConfigInitializer.php +++ b/src/Configuration/ConfigInitializer.php @@ -82,7 +82,7 @@ private function createPathsString(array $projectPhpDirectories): string return rtrim($projectPhpDirectoriesContents); } - private function fillPreparedSets(string $projectDirectory, string $templateFileContents): string|array + private function fillPreparedSets(string $projectDirectory, string $templateFileContents): string { $templateFileContents = $this->fillPaths($projectDirectory, $templateFileContents); diff --git a/templates/include/prepared_sets_php74.php.inc b/templates/include/prepared_sets_php74.php.inc index e10f788f40..2f86f7b0bc 100644 --- a/templates/include/prepared_sets_php74.php.inc +++ b/templates/include/prepared_sets_php74.php.inc @@ -1,7 +1,7 @@ - ->withSets( + ->withSets([ // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::SPACES, // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::NAMESPACES, // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::DOCBLOCKS, // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::ARRAYS, // \Symplify\EasyCodingStandard\ValueObject\Set\SetList::COMMENTS, - ) + ]) From cf33b9e97e3ad74005b5adedc1d91b9cda2bb23e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 23 May 2025 10:09:14 +0200 Subject: [PATCH 22/25] cs --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index 4056f8a2f5..9527944dab 100644 --- a/rector.php +++ b/rector.php @@ -24,4 +24,7 @@ '*/Fixture/*', __DIR__ . '/src/SniffRunner/ValueObject/File.php', __DIR__ . '/scoper.php', + + // conditional checks + \Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector::class, ]); From 4e4cb1c7893133141a5f9b0540e26f3d2ebed86b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 30 May 2025 18:26:14 +0700 Subject: [PATCH 23/25] Bump to symplify/coding-standard:^12.4.3 (#279) --- composer.json | 2 +- rector.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 90cb4df041..c00de95ddc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "squizlabs/php_codesniffer": "^3.13", "symfony/console": "^6.4.20", "symfony/finder": "^7.2.2", - "symplify/coding-standard": "^12.4.1", + "symplify/coding-standard": "^12.4.3", "symplify/easy-parallel": "^11.2.2", "webmozart/assert": "^1.11" }, diff --git a/rector.php b/rector.php index 9527944dab..bb35d35b9c 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector; return RectorConfig::configure() ->withPhpSets() @@ -26,5 +27,5 @@ __DIR__ . '/scoper.php', // conditional checks - \Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector::class, + RemovePhpVersionIdCheckRector::class, ]); From 383b3fa8431f02c67cc19d62172f7914a267e7d1 Mon Sep 17 00:00:00 2001 From: Wietse Warendorff Date: Fri, 30 May 2025 13:27:30 +0200 Subject: [PATCH 24/25] escalate TodoSniff warning (#274) --- src/SniffRunner/Application/SniffFileProcessor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SniffRunner/Application/SniffFileProcessor.php b/src/SniffRunner/Application/SniffFileProcessor.php index fac85ad767..f261744eec 100644 --- a/src/SniffRunner/Application/SniffFileProcessor.php +++ b/src/SniffRunner/Application/SniffFileProcessor.php @@ -9,6 +9,7 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff; use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnusedFunctionParameterSniff; +use PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff; use PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff; use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff; use PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff; @@ -44,6 +45,7 @@ final class SniffFileProcessor implements FileProcessorInterface MethodDeclarationSniff::class, CommentedOutCodeSniff::class, UnusedFunctionParameterSniff::class, + TodoSniff::class, ]; /** From 1ccc7807c2526f4fdf203dbf71f12c90f4be4d01 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 30 May 2025 18:38:55 +0700 Subject: [PATCH 25/25] Hotfix trailing comma (#280) --- src/Configuration/EditorConfig/EditorConfigFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration/EditorConfig/EditorConfigFactory.php b/src/Configuration/EditorConfig/EditorConfigFactory.php index 0a21d4fb54..353c86ac72 100644 --- a/src/Configuration/EditorConfig/EditorConfigFactory.php +++ b/src/Configuration/EditorConfig/EditorConfigFactory.php @@ -44,7 +44,7 @@ public function parse(string $editorConfigFileContents): EditorConfig trimTrailingWhitespace: $this->field($config, 'trim_trailing_whitespace', $this->id(...)), insertFinalNewline: $this->field($config, 'insert_final_newline', $this->id(...)), maxLineLength: $this->field($config, 'max_line_length', $this->id(...)), - quoteType: $config['quote_type'] ?? null, + quoteType: $config['quote_type'] ?? null ); }