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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…