project-nos/spryker-twig-code-sniffer

此包旨在为spryker中的twig模板提供类似于phpcs对php的功能。它检查您的代码库中是否存在违反编码标准的问题。

v1.1.1 2024-02-12 17:06 UTC

README

NOS spryker twig code sniffer

mit license github workflow tests packagist version

此包旨在为spryker中的twig模板提供类似于phpcs对php的功能。它检查您的代码库中是否存在违反编码标准的问题。

安装

composer require --dev project-nos/spryker-twig-code-sniffer

设置

要使用提供的控制台命令,您需要在config/Shared/config_default.php中注册命名空间Nos

$config[KernelConstants::CORE_NAMESPACES] = [
    // add 'Nos' as a core namespace
    'Nos',
];

src/Pyz/Yves/Console/ConsoleDependencyProvider.php中,您需要为部署任务注册控制台命令插件。

use Nos\Yves\TwigCodeSniffer\Plugin\Console\TwigCodeSnifferConsole;

    protected function getConsoleCommands(Container $container): array
    {
        $commands = [
            // other registered console plugins ...
            new TwigCodeSnifferConsole(),
        ];

然后,您应该可以在code部分看到一个新的命令

code
   ...
   code:sniff:twig  Sniff and fix twig code style
   ...

定义

Description:
  Sniff and fix twig code style

Usage:
  code:sniff:twig [options] [--] [<paths>...]

Arguments:
  paths                 Paths of files and folders to parse

Options:
      --level=LEVEL     Allowed values are notice, warning or error [default: "NOTICE"]
      --report=REPORT   Report format [default: "text"]
      --fix             Automatically fix all the fixable violations
      --no-cache        Disable cache while running the fixer

编码标准

此包试图模仿以下官方编码标准,但有以下例外

  • 在|(管道)操作符前后各有一个(且仅有一个)空格。

许可证

版权(c)Andreas Penz。在MIT许可证下发布。