【问题标题】:Php Codesniffer Should ignore Capital letter and full stopPhp Codesniffer 应该忽略大写字母和句号
【发布时间】:2019-11-07 10:37:26
【问题描述】:

我正在为现有项目实施 PHPCS。 我想检查函数是否有文档块。

我目前正在使用以下规则:

    <rule ref="Squiz.Commenting.FunctionComment" />
    <rule ref="Squiz.Commenting.FunctionCommentThrowTag" />
    <rule ref="Squiz.Commenting.VariableComment" />
    <rule ref="Squiz.Commenting.DocCommentAlignment"/>
    <rule ref="Generic.Files.LineLength">
        <properties>
            <property name="absoluteLineLimit" value="120"/>
            <property name="lineLimit" value="120"/>
        </properties>
    </rule>
    <!-- Ban some functions -->
    <rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" type="array">
                <element key="print" value="echo"/>
                <element key="var_dump" value="null"/>
                <element key="dd" value="null"/>
                <element key="dump" value="null"/>
                <element key="echo" value="null"/>
                <element key="print_r" value="null"/>
                <element key="var_export" value="null"/>
            </property>
        </properties>
    </rule>

但是我有很多问题,参数注释应该以大写字母开头并以句号结尾。

我怎样才能使关于大写字母和句号的规则不那么严格

编辑:目前代码块也想对齐参数。这会在@param array$parameter 之间产生很多难看的空白。我可以在 phpcs 和 phpcbf 中删除此规则吗?

【问题讨论】:

    标签: php codesniffer phpcs phpcodesniffer


    【解决方案1】:

    使用 -s 命令行参数运行 PHPCS,这样您就可以在每条消息旁边看到错误代码。然后,您可以通过将它们的严重性设置为 0 来排除规则集中的这些特定消息。

    在这种特定情况下,您可能希望将这 4 个排除项添加到您的规则集中:

    <rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Commenting.FunctionComment.ParamCommentFullStop">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamType">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamName">
        <severity>0</severity>
    </rule>
    

    【讨论】:

      猜你喜欢
      • 2021-01-29
      • 2016-06-06
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多