mikelooper/code-style

PHP Code Style rules

0.0.2 2023-11-27 18:43 UTC

This package is auto-updated.

Last update: 2024-04-28 20:54:24 UTC


README

  1. Install the dependency
    composer require --dev mikelooper/coding-style
  2. Add it to your ecs.php file:
    use Shared\Infrastructure\CodingStyle;
    use Symplify\EasyCodingStandard\Config\ECSConfig;
    
    return function (ECSConfig $ecsConfig): void {
        $ecsConfig->paths([__DIR__ . '/src',]);
    
        $ecsConfig->sets([CodingStyle::DEFAULT]);
    
        // Or this if you prefer to have the code aligned
        // $ecsConfig->sets([CodingStyle::ALIGNED]);
    };
  3. Execute it:
    ./vendor/bin/ecs check

🤔 What it does

  • Lints PHP using PSR-12
  • Extends some config (you can see all the rules here)
  • Use tabs to indent (reason). If you want to use spaces, you can add the following line at the end of your ecs.php:
    use Symplify\EasyCodingStandard\ValueObject\Option;
    
    $ecsConfig->indentation(Option::INDENTATION_SPACES);