我目前在我的几个项目的CI中运行php vendor/bin/phpcs --standard=PSR12 src。
它们已经失败了6+几个月,因为我的代码的组织方式如下:
<?php declare(strict_types=1);
/**
* This file is part of SimpleDTO, a PHP Experts, Inc., Project.
*
* Copyright © 2019 PHP Experts, Inc.
* Author: Theodore R. Smith <theodore@phpexperts.pro>
* GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
* https://www.phpexperts.pro/
* https://github.com/phpexpertsinc/SimpleDTO
*
* This file is licensed under the MIT License.
*/
namespace PHPExperts\SimpleDTO;它目前生成了几个PHPCS警告:
--------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------
1 | ERROR | [x] Header blocks must be separated by a single blank line
1 | ERROR | [x] Opening PHP tag must be on a line by itself
3 | ERROR | [ ] The file-level docblock must follow the opening PHP tag in the file header
--------------------------------------------------------------------------------------------有没有办法保留其余的PSR-12检查,但不是那些?
发布于 2020-04-08 16:33:11
你有两个选择:
--exclude命令行参数,它允许您指定不想担心的嗅探。使用您的例子,它将是php vendor/bin/phpcs --standard=PSR12 --exclude=PSR12.Files.FileHeader,PSR12.Files.OpenTag srcphpcs.xml文件:<?xml version="1.0"?>
<ruleset name="Custom Standard" namespace="MyProject\CS\Standard">
<rule ref="PSR12">
<exclude name="PSR12.Files.FileHeader" />
<exclude name="PSR12.Files.OpenTag" />
</rule>
</ruleset>如果使用该名称[ phpcs.xml ],则会自动获取phpcs.xml(或phpcs.xml.dist)文件,否则将使用--standard参数指向其文件位置。在使用该文件时,还可以更准确地指定不能使用PSR12.Files.OpenTag.NotAlone命令行选项的嗅探器(例如,--exclude )。
https://stackoverflow.com/questions/61105282
复制相似问题