Skip to content

[‎friendsofphp/php-cs-fixer][php-cs-fixer/shim] Exclude config/reference.php from php-cs-fixer finder#1518

Merged
symfony-recipes-bot merged 1 commit intosymfony:mainfrom
likeuntomurphy:php-cs-fixer-exclude-config-reference
Mar 2, 2026
Merged

[‎friendsofphp/php-cs-fixer][php-cs-fixer/shim] Exclude config/reference.php from php-cs-fixer finder#1518
symfony-recipes-bot merged 1 commit intosymfony:mainfrom
likeuntomurphy:php-cs-fixer-exclude-config-reference

Conversation

@likeuntomurphy
Copy link
Contributor

Q A
License MIT
Doc issue/PR symfony/symfony-docs#...

See symfony/symfony#62629 (comment)

3.39 is the earliest version of PHP-CS-Fixer co-installable with Symfony 7.4, while Symfony version compatibility is not a concern with the shim package.

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 28, 2026 11:25
@github-actions
Copy link

github-actions bot commented Feb 28, 2026

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1518/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1518/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'friendsofphp/php-cs-fixer:^3.39' 'php-cs-fixer/shim:^3.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

friendsofphp/php-cs-fixer

2.2 vs 2.16
diff --git a/friendsofphp/php-cs-fixer/2.2/.php_cs.dist b/friendsofphp/php-cs-fixer/2.16/.php_cs.dist
index afe11185..2aa712cb 100644
--- a/friendsofphp/php-cs-fixer/2.2/.php_cs.dist
+++ b/friendsofphp/php-cs-fixer/2.16/.php_cs.dist
@@ -8,7 +8,6 @@ $finder = PhpCsFixer\Finder::create()
 return PhpCsFixer\Config::create()
     ->setRules([
         '@Symfony' => true,
-        'array_syntax' => ['syntax' => 'short'],
     ])
     ->setFinder($finder)
 ;
2.16 vs 2.17
diff --git a/friendsofphp/php-cs-fixer/2.16/.php_cs.dist b/friendsofphp/php-cs-fixer/2.17/.php_cs.dist
index 2aa712cb..3788194c 100644
--- a/friendsofphp/php-cs-fixer/2.16/.php_cs.dist
+++ b/friendsofphp/php-cs-fixer/2.17/.php_cs.dist
@@ -1,11 +1,11 @@
 <?php
 
-$finder = PhpCsFixer\Finder::create()
+$finder = (new PhpCsFixer\Finder())
     ->in(__DIR__)
     ->exclude('var')
 ;
 
-return PhpCsFixer\Config::create()
+return (new PhpCsFixer\Config())
     ->setRules([
         '@Symfony' => true,
     ])
2.17 vs 2.19
diff --git a/friendsofphp/php-cs-fixer/2.17/.php_cs.dist b/friendsofphp/php-cs-fixer/2.19/.php-cs-fixer.dist.php
similarity index 70%
rename from friendsofphp/php-cs-fixer/2.17/.php_cs.dist
rename to friendsofphp/php-cs-fixer/2.19/.php-cs-fixer.dist.php
index 3788194c..e63611e6 100644
--- a/friendsofphp/php-cs-fixer/2.17/.php_cs.dist
+++ b/friendsofphp/php-cs-fixer/2.19/.php-cs-fixer.dist.php
@@ -10,4 +10,5 @@ return (new PhpCsFixer\Config())
         '@Symfony' => true,
     ])
     ->setFinder($finder)
+    ->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line
 ;
diff --git a/friendsofphp/php-cs-fixer/2.17/manifest.json b/friendsofphp/php-cs-fixer/2.19/manifest.json
index 56096a3a..b24240a7 100644
--- a/friendsofphp/php-cs-fixer/2.17/manifest.json
+++ b/friendsofphp/php-cs-fixer/2.19/manifest.json
@@ -1,10 +1,10 @@
 {
     "aliases": ["cs-fixer", "php-cs-fixer"],
     "copy-from-recipe": {
-        ".php_cs.dist": ".php_cs.dist"
+        ".php-cs-fixer.dist.php": ".php-cs-fixer.dist.php"
     },
     "gitignore": [
-        "/.php_cs",
-        "/.php_cs.cache"
+        "/.php-cs-fixer.php",
+        "/.php-cs-fixer.cache"
     ]
 }
2.19 vs 3.0
diff --git a/friendsofphp/php-cs-fixer/2.19/.php-cs-fixer.dist.php b/friendsofphp/php-cs-fixer/3.0/.php-cs-fixer.dist.php
index e63611e6..3788194c 100644
--- a/friendsofphp/php-cs-fixer/2.19/.php-cs-fixer.dist.php
+++ b/friendsofphp/php-cs-fixer/3.0/.php-cs-fixer.dist.php
@@ -10,5 +10,4 @@ return (new PhpCsFixer\Config())
         '@Symfony' => true,
     ])
     ->setFinder($finder)
-    ->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line
 ;
3.0 vs 3.39
diff --git a/friendsofphp/php-cs-fixer/3.0/.php-cs-fixer.dist.php b/friendsofphp/php-cs-fixer/3.39/.php-cs-fixer.dist.php
index 3788194c..1c883f00 100644
--- a/friendsofphp/php-cs-fixer/3.0/.php-cs-fixer.dist.php
+++ b/friendsofphp/php-cs-fixer/3.39/.php-cs-fixer.dist.php
@@ -3,6 +3,10 @@
 $finder = (new PhpCsFixer\Finder())
     ->in(__DIR__)
     ->exclude('var')
+    ->notPath([
+        'config/bundles.php',
+        'config/reference.php',
+    ])
 ;
 
 return (new PhpCsFixer\Config())

@likeuntomurphy likeuntomurphy changed the title Exclude config/reference.php from php-cs-fixer finder [‎friendsofphp/php-cs-fixer][php-cs-fixer/shim] Exclude config/reference.php from php-cs-fixer finder Feb 28, 2026
nicolas-grekas
nicolas-grekas previously approved these changes Feb 28, 2026
@Kocal
Copy link
Member

Kocal commented Feb 28, 2026

Would it make sens to also skip config/bundles.php as well?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Feb 28, 2026

Would it make sens to also skip config/bundles.php as well?

It doesn't cause problems so I wouldn't without reasons.

auto-merge was automatically disabled February 28, 2026 14:01

Head branch was pushed to by a user without write access

@likeuntomurphy likeuntomurphy force-pushed the php-cs-fixer-exclude-config-reference branch from cd8e36c to c1b2937 Compare February 28, 2026 14:01
@likeuntomurphy
Copy link
Contributor Author

There is a problem with config/bundles.php — running the fixer will change the FQCNs to imports, and installing another bundle will restore the FQCNs. I had originally avoided this with // @php-cs-fixer-ignore fully_qualified_strict_types at the top of the bundles file, but testing reveals that installing another bundle will also remove this comment. So I’m in favor of it. I prefer adding an array of paths over a regex — the list is easier to understand when scanning.

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 28, 2026 14:02
@symfony-recipes-bot symfony-recipes-bot merged commit 3f11f2a into symfony:main Mar 2, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants