mikelooper/code-style

PHP 代码风格规则

0.0.2 2023-11-27 18:43 UTC

This package is auto-updated.

Last update: 2024-09-28 21:51:43 UTC


README

  1. 安装依赖项
    composer require --dev mikelooper/coding-style
  2. 将其添加到您的 ecs.php 文件中
    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. 执行它
    ./vendor/bin/ecs check

🤔 它的作用

  • 使用 PSR-12 检查 PHP 代码的格式
  • 扩展一些配置(您可以在此处查看所有规则 here
  • 使用制表符进行缩进(原因)。如果您想使用空格,您可以在您的 ecs.php 文件末尾添加以下行
    use Symplify\EasyCodingStandard\ValueObject\Option;
    
    $ecsConfig->indentation(Option::INDENTATION_SPACES);