Skip to content

Fix fatal error when configuring a PHP-CS-Fixer fixer - #62

Merged
TomasVotruba merged 2 commits into
mainfrom
reproduce-configured-fixer-fatal
Aug 24, 2026
Merged

Fix fatal error when configuring a PHP-CS-Fixer fixer#62
TomasVotruba merged 2 commits into
mainfrom
reproduce-configured-fixer-fatal

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 7, 2026

Copy link
Copy Markdown
Member

Fixes #44.

Cause

ECS replaces symfony/console, so Symfony\Component\Console\Application is never installed.

Configuring a php-cs-fixer fixer with a deprecated option runs ConfigurableFixerTrait::configure(), which calls PhpCsFixer\Console\Application::getMajorVersion(). That class extends the missing Symfony Application, so PHP fatals resolving the parent:

PHP Fatal error: Uncaught Error: Class "Symfony\Component\Console\Application" not found

Fix

Ship a declaration-only stub in /stubs, autoloaded via classmap. ECS never runs the php-cs-fixer console, so only the class declaration is needed. php-scoper prefixes the stub with everything else, so the release build gets the prefixed name php-cs-fixer's Application extends there. stubs is added to the downgrade and scoping build steps.

CI

New Configured Fixer workflow runs bin/ecs check with a configured fixer and asserts output instead of a fatal.

before:

PHP Fatal error: Uncaught Error: Class "Symfony\Component\Console\Application" not found

after:

1) build/nested/some_file.php
@@ -1 +1,3 @@
-<?php  $x=1;
+<?php
+
+$x = 1;

@TomasVotruba TomasVotruba changed the title Add CI reproducer for configured PHP-CS-Fixer fixer fatal error Fix fatal error when configuring a PHP-CS-Fixer fixer Aug 7, 2026
@elementaire

Copy link
Copy Markdown

I have exactly the same issue with the same file NullableTypeDeclarationForDefaultNullValueFixer. I'll wait until the fix is merged and stay on 13.1.*

@TomasVotruba
TomasVotruba force-pushed the reproduce-configured-fixer-fatal branch from c599c7a to 2e7d2e5 Compare August 24, 2026 14:42
Ship a declaration-only Symfony console Application stub so configured
php-cs-fixer fixers do not fatal, plus a CI reproducer for issue #44.
phpstan 2.2.9 infers the return type correctly, so the ignore pattern
is never matched and reportUnmatched fails the run.
@TomasVotruba
TomasVotruba force-pushed the reproduce-configured-fixer-fatal branch from 2905f9a to 3216285 Compare August 24, 2026 16:57
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 24, 2026 16:58
@TomasVotruba
TomasVotruba merged commit 3aee0ac into main Aug 24, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the reproduce-configured-fixer-fatal branch August 24, 2026 16:58
@TomasVotruba

Copy link
Copy Markdown
Member Author

Just released https://github.com/ecsphp/ecs/releases/tag/13.2.19

Can you verify this works for you?

@elementaire

Copy link
Copy Markdown

Yes, it works for me, thanks!

@TomasVotruba

Copy link
Copy Markdown
Member Author

Awesome :) great to hear that

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.

Class "ECSPrefix202607\Symfony\Component\Console\Application" not found

2 participants