Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

PHPCS rewrite function syntax for WordPress

I'm using phpcs for WordPress and want to write functions using Generic.Functions.OpeningFunctionBraceBsdAllman like this

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

However WordPress doesn't use this syntax and sniffer gives me this error - Expected exactly one space between closing parenthesis and opening control structure; " " found. . WordPress.WhiteSpace.ControlStructureSpacing disables it but it's also disable same syntax for if-statement and so on. I want to apply such syntax ONLY for functions

My phpcs.xml is looking like this (rules only)

    <!-- 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>

What rules should I add, remove or both?

question from:https://stackoverflow.com/questions/65645512/phpcs-rewrite-function-syntax-for-wordpress

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...