PHPCS 向规则集添加 php 语法错误检查

问题描述

更新

我有太多的格式错误,以至于一个解析/语法错误都丢失了。

有没有办法突出显示语法错误,以便立即看到?


原创

我制定了这个到目前为止有效的规则集。当试图让 PHPcs 检查简单的 PHP 语法错误时,我将 <rule ref="Generic.PHP.Syntax"/> 添加到规则集。我还在其中一个文件添加一个语法错误,但没有报告任何内容

我使用 Github Action 来运行 linter:

wearerequired/lint-action@v1

配置如下:

  - name: Run linters
    uses: wearerequired/lint-action@v1
    with:
      PHP_codesniffer: true
      PHP_codesniffer_args: "-n"

我需要添加不同的语法规则吗?

<ruleset name="MyStandard">
    <description>My custom coding standard.</description>
    <exclude-pattern>*/libraries/*</exclude-pattern>
    <rule ref="PEAR">
        <exclude name="PEAR.NamingConventions.ValidFunctionName"/>
        <exclude name="PEAR.NamingConventions.ValidVariableName"/>
        <exclude name="PEAR.Commenting.ClassComment"/>
        <exclude name="Generic.Commenting.DocComment.MissingShort"/>
        <exclude name="PEAR.Commenting.ClassComment.Missing"/>
        <exclude name="PEAR.Commenting.FileComment.Missing"/>
        <exclude name="PEAR.Commenting.FunctionComment.Missing"/>
        <exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
        <exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
        <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
        <exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
        <exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
        <exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
        <exclude name="PEAR.Commenting.FileComment.MissingVersion"/>
        <exclude name="PEAR.Commenting.InlineComment"/>
        <exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact"/>
        <exclude name="Generic.WhiteSpace.disallowTabIndent.TabsUsed"/>
    </rule>
    <rule ref="Generic.PHP.Syntax"/>
</ruleset>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)