0

我正在使用该包"squizlabs/php_codesniffer": "^3.6"在 Laravel 8 项目中构建我的代码嗅探器。

但是我的 phpcs.xml.dist 文件忽略了我的 php_cs.dist 文件(配置文件)。这两个文件都在项目根路径中。

./phpcs.xml.dist

<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <arg name="basepath" value="."/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>
    <arg name="extensions" value="php"/>
    <rule ref="PSR1"/>
    <rule ref="PSR2">
        <exclude name="PSR1.Methods.CamelCapsMethodName"/>
    </rule>
    <file>app/</file>
    <file>tests/</file>
    <exclude-pattern>vendor/</exclude-pattern>
    <exclude-pattern>database/</exclude-pattern>
    <exclude-pattern>storage/</exclude-pattern>
    <exclude-pattern>tests/TestCase.php</exclude-pattern>
</ruleset>

./php_cs.dist

<?php

$path = __DIR__ . DIRECTORY_SEPARATOR;

$finder = PhpCsFixer\Finder::create()
    ->in($path . 'application')
    ->exclude($path . 'application' . DIRECTORY_SEPARATOR . 'views')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

$rules = [
    'align_multiline_comment' => true,
    ...
];

return PhpCsFixer\Config::create()
    ->setRiskyAllowed(true)
    ->setFinder($finder)
    ->setRules($rules)
    ->setHideProgress(true)
    ->setUsingCache(true);

我正在使用此命令运行:php vendor/bin/phpcsphp vendor/bin/phpcbf

4

0 回答 0