New in Symplify 5: Public Method Order and External Final in CodingStandard

This post was updated at August 2020 with fresh know-how.
What is new?

Removed unsupported rules in Coding Standard 8, add PHPStan rule that handle it better.

Coding Standard 5 replaced fixers that renamed classes with more tolerant sniffs. What else is there?
New config options that shorten your config file and 2 new checkers to keep your code in order.

Don't you have this package installed yet?

composer require symplify/coding-standard --dev

Now enjoy the news ↓

3. Final for 3rd Party Classes

If you're strict enough to final or abstract everywhere, you'll love this. Sometimes 3rd party code is not final, but you'd love to never see that class in your code - Abstract Controller, Abstract Doctrine Repository or Abstract Object.

Those abstract classes are full of magic everyone has to remember. What if you could prevent that spreading to your code without constant code-reviews?

Let PHPStan rule do the job:

# phpstan.neon
    - Symplify\CodingStandard\Rules\ForbiddenParentClassRule

            - 'Doctrine\ORM\EntityRepository'
            - 'Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository'

This will prevent over-inheritance and embrace composition - like in Repositories as Services approach:


use Doctrine\ORM\EntityRepository;

final class ProductRepository extends EntityRepository


use Doctrine\ORM\EntityRepository;

final class ProductRepository
     * @var EntityRepository
    private $entityRepository;

    public function __construct(EntityRepository $entityRepository)
        $this->entityRepository = $entityRepository;

That's all folks. Happy sniffing!

Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors. I'd really appreciate it!