sebbaum / generator-laravel-5

Scaffold Laravel 5.7 applications with ease.
Other
18 stars 0 forks source link

Include a coding standard #6

Closed azdanov closed 6 years ago

azdanov commented 6 years ago

What I am thinking is to either to include PHP_CodeSniffer and/or PHP-CS-Fixer with a default set of rules.

For PHP-CS-Fixer I use this config. And for PHP_CodeSniffer I use doctrine/coding-standard.

It would be cool to create something similar for a Laravel project which works out of the box.

sebbaum commented 6 years ago

Hi @azdanov, thanks for your idea. I also think that code quality is important. I worked with PHP_CodeSniffer in the past. I'll evaluate your idea a little further.

Also feel free to send a PR.

Cheers Sebastian

azdanov commented 6 years ago

I am wondering which coding-standard rulesets would fit.

There are antonioribeiro/laravelcs, which hasn't been updated for a while, and stechstudio/Laravel-PHP-CS-Fixer which looks quite ok.

sebbaum commented 6 years ago

I am wondering which coding-standard rulesets would fit.

Well, that's a good question. You're right, antonioribeiro/laravelcs is too old. The other one looks promising. I also like the fact that it can be run with an artisan command. Maybe I can give it a try on Monday on one of my projects.

azdanov commented 6 years ago

Another interesting alternative is symplify/easyCodingStandard.

EDIT:

I found this config working well for me:

imports:
  - { resource: "vendor/symplify/easy-coding-standard/config/clean-code.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/common.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/psr12.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/php71.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/symfony.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/symfony-risky.yml" }
  - { resource: "vendor/symplify/easy-coding-standard/config/symplify.yml" }
parameters:
    exclude_checkers:
        - 'PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer'
        - 'SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff'
        - 'SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff'

Might be a little too strict for a default though.

sebbaum commented 6 years ago

Nice, thanks. I'll take it into consideration.

sebbaum commented 6 years ago

Hi @azdanov, I found some time to check your suggestion of ECS. I like it and I'll integrate it in the next release 1.5.0.

Concerning the default checks, I'll choose a less strict check. Developers can then select their preferred config.

Thanks again for pointing me at this tool.

Cheers Sebastian