From 7d679a77598431087ac88493a12a1f7b342e585a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 15 Jun 2026 16:19:13 +0200 Subject: [PATCH 1/3] update tempalte iwth levels --- templates/ecs.php.dist | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/ecs.php.dist b/templates/ecs.php.dist index f6f57eb6d5..a479fe7bed 100644 --- a/templates/ecs.php.dist +++ b/templates/ecs.php.dist @@ -9,6 +9,8 @@ return ECSConfig::configure() ->withPaths([ __PATHS__ ]) + // include *.php files in the root directory + ->withRootFiles() // add a single rule ->withRules([ @@ -18,4 +20,9 @@ __PATHS__ // add sets - group of rules, from easiest to more complex ones // uncomment one, apply one, commit, PR, merge and repeat __PREPARED_SETS__ - ; + + // ...but first: take it step by step + ->withSpacesLevel(0) + ->withArrayLevel(0) + ->withControlStructuresLevel(0) + ->withDocblockLevel(0); From d4ca3a578cde9c69f51ddfe0059b423b4d8d1981 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 15 Jun 2026 16:19:31 +0200 Subject: [PATCH 2/3] deprecate ECS config --- composer.json | 4 ++-- src/DependencyInjection/ServiceContainerFactory.php | 13 +++++++++++++ .../deprecated-closure-config.php | 8 ++++++++ tests/DependencyInjection/ConfigurationFileTest.php | 9 +++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/DependencyInjection/ConfigurationFileSource/deprecated-closure-config.php diff --git a/composer.json b/composer.json index e5aa1c444c..e11839c850 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=8.4", - "composer/pcre": "^3.3.2", + "composer/pcre": "^3.4", "composer/xdebug-handler": "^3.0.5", "entropy/entropy": "^0.4", "friendsofphp/php-cs-fixer": "^3.95.5", @@ -37,7 +37,7 @@ "symplify/phpstan-rules": "^14.11", "symplify/vendor-patches": "^11.5", "tomasvotruba/class-leak": "^2.1.7", - "tomasvotruba/type-coverage": "^2.1", + "tomasvotruba/type-coverage": "^2.2", "tomasvotruba/unused-public": "^2.2", "tracy/tracy": "^2.12" }, diff --git a/src/DependencyInjection/ServiceContainerFactory.php b/src/DependencyInjection/ServiceContainerFactory.php index 3286a8822b..78ceed4369 100644 --- a/src/DependencyInjection/ServiceContainerFactory.php +++ b/src/DependencyInjection/ServiceContainerFactory.php @@ -4,6 +4,7 @@ namespace Symplify\EasyCodingStandard\DependencyInjection; +use Closure; use Entropy\Container\Container; use PHP_CodeSniffer\Util\Tokens; use PhpCsFixer\Differ\DifferInterface; @@ -68,6 +69,18 @@ static function (Container $container): EasyCodingStandardStyle { $configClosure = require $configFile; Assert::isCallable($configClosure); + if ($configClosure instanceof Closure) { + /** @var SymfonyStyle $symfonyStyle */ + $symfonyStyle = $ecsConfig->make(SymfonyStyle::class); + $symfonyStyle->warning(sprintf( + 'The "return function (ECSConfig $ecsConfig): void {}" config format is deprecated. Use "return ECSConfig::configure()" fluent API instead in "%s".', + $configFile + )); + + // give the user a moment to notice the deprecation warning + sleep(5); + } + $configClosure($ecsConfig); } diff --git a/tests/DependencyInjection/ConfigurationFileSource/deprecated-closure-config.php b/tests/DependencyInjection/ConfigurationFileSource/deprecated-closure-config.php new file mode 100644 index 0000000000..9500565ce3 --- /dev/null +++ b/tests/DependencyInjection/ConfigurationFileSource/deprecated-closure-config.php @@ -0,0 +1,8 @@ +make(SniffFileProcessor::class); $this->assertCount(1, $sniffFileProcessor->getCheckers()); } + + public function testDeprecatedClosureConfig(): void + { + // the old closure config format is deprecated, but still loads + $this->createContainerWithConfigs([__DIR__ . '/ConfigurationFileSource/deprecated-closure-config.php']); + + $fixerFileProcessor = $this->make(FixerFileProcessor::class); + $this->assertCount(0, $fixerFileProcessor->getCheckers()); + } } From 3c8f5960cd058f4c9f73abe94373cf4dab352477 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 15 Jun 2026 23:34:21 +0200 Subject: [PATCH 3/3] nested --- phpstan.neon | 3 ++- src/DependencyInjection/ServiceContainerFactory.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index ace8e7cdc5..917a25e542 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,8 @@ parameters: checkMissingCallableSignature: true # symplify - see https://github.com/symplify/phpstan-rules#usage - pathStrings: true + symplify: + pathStrings: true paths: - packages diff --git a/src/DependencyInjection/ServiceContainerFactory.php b/src/DependencyInjection/ServiceContainerFactory.php index 78ceed4369..606431bb8e 100644 --- a/src/DependencyInjection/ServiceContainerFactory.php +++ b/src/DependencyInjection/ServiceContainerFactory.php @@ -69,7 +69,7 @@ static function (Container $container): EasyCodingStandardStyle { $configClosure = require $configFile; Assert::isCallable($configClosure); - if ($configClosure instanceof Closure) { + if ($configClosure instanceof Closure && ! defined('PHPUNIT_COMPOSER_INSTALL')) { /** @var SymfonyStyle $symfonyStyle */ $symfonyStyle = $ecsConfig->make(SymfonyStyle::class); $symfonyStyle->warning(sprintf(