PHPCS 为 WordPress 重写函数语法

问题描述

我正在为 WordPress 使用 phpcs,并想使用 Generic.Functions.OpeningFunctionBraceBsdAllman 编写函数,就像这样

private function create_templates( string $modelName,string $postType = '' )
{ <-- bracket on a next line with no spaces

然而 WordPress 不使用这种语法,嗅探器给了我这个错误 - Expected exactly one space between closing parenthesis and opening control structure; "\n" found. WordPress.WhiteSpace.ControlStructureSpacing 禁用它,但它也禁用 if 语句等的相同语法。我想对函数应用这样的语法ONLY

我的 phpcs.xml 看起来像这样(仅限规则)

    <!-- Best practices beyond core WordPress Coding Standards -->
    <rule ref="WordPress-Extra">
        <!-- Disable rules for filename -->
        <exclude name="WordPress.Files.FileName"></exclude>

        <!-- Open brace on a next line -->
        <exclude name="Generic.Classes.OpeningBraceSameLine"></exclude>

        <!-- Allow short array syntax -->
        <exclude name="Generic.Arrays.DisallowShortArraySyntax"></exclude>

        <!-- Function syntax -->
        <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"></exclude>

        <!-- Allow varaibles to be named in camelCase -->
        <exclude name="WordPress.NamingConventions.ValidVariableName"></exclude>
    </rule>

    <!-- WordPress Coding Standards for Inline Documentation and Comments -->
    <rule ref="WordPress-Docs">
        <exclude name="Squiz.Commenting.ClassComment"></exclude>
    </rule>

我应该添加、删除或同时删除哪些规则?

解决方法

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

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

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...