4 Simple Checkers for Coding Standard Haters but Clean Code Lovers

This post was updated on December 2018
Updated with EasyCodingStandard 5, Neon to YAML migration and checkers to services migration.

Do you find coding standards too annoying in telling you where to put that bracket? Is that the reason you haven't tried them yet?

Great! This post is for you. There are other ways to use coding standard and clean code is one of them.

There are some checkers in coding standard world, that don't check spaces, tabs, commas nor brackets. They actually do code-review for you.

I use a set of 4 checkers to check open-source packages to help them keeping their code clean.

In Sylius they removed 500 lines of unused code just few days ago.

Among others it removed dead constructor dependencies.

It will not only make your code cleaner, but also can speed up you container build as a side effect.

4 Simple Checkers

# ecs.yml
    # use short array []
        syntax: short

    # drop dead code
    SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff: ~

    # drop dead use namespaces
    PhpCsFixer\Fixer\Import\NoUnusedImportsFixer: ~

    # and sort them A → Z
    PhpCsFixer\Fixer\Import\OrderedImportsFixer: ~

4 Steps to Make Your Code Cleaner

  1. Install it

    composer require symplify/easy-coding-standard --dev
  2. Add checkers to ecs.yml file

  3. Check your code

    vendor/bin/ecs check src
  4. Fix the code

    vendor/bin/ecs check src --fix

Happy coding!

Found a typo? Fix it to join team of 64 people that improve content here

❤️️ Do you like what I write about? Or do you hate it but enjoy discussion? 😠
You can support my writing by throwing a couple bucks at my Patreon