Do you want to use ECS but still stuck on an older coding standard tool? I wrote a post how to migrate from PHP_CodeSniffer and from PHP-CS-Fixer.
But who has time to read the step-by-step manual and do manual work? Nobody. That's why today, we'll look at a tool that will handle the migration to ECS for you.
More and more projects I worked with wanted to try ECS, but they didn't want to look at every rule in XML and write them in PHP. I helped the first 3 to do manually and guide them on differences in configuration and rule naming. It was daunting work.
Are you interested in what way is ECS better? Check the mentioned posts:
When I was about to migrate 4th
phpcs.xml, I didn't want to repeat copy-pasting, adding fully qualified names from dots, and so on. Some of you know from GitHub Stars profile, that this physically hurts me more than most people.
Luckily, I had to go the toilet. Suddenly I realized:
"If I can do it, so can PHP tool"
That's how Sniffer/Fixer to ECS Converter was born. The tool does what its name says.
composer require symplify/sniffer-fixer-to-ecs-converter --dev
Migrate PHP_CodeSniffer config
vendor/bin/sniffer-fixer-to-ecs-converter convert phpcs.xml
Migrate PHP-CS-Fixer config
vendor/bin/sniffer-fixer-to-ecs-converter convert .php_cs.dist
In both cases, a new config
converted-ecs.php was created.
Now you can verify the config by running ECS.
composer require symplify/easy-coding-standard --dev vendor/bin/ecs check --config converted-ecs.php
If all is good, rename this config to
ecs.php and remove your old config + tool from
composer.json. Then you're ready to go.