inspirecz / coding-standard-sniffs
INSPIRE Coding Standard Sniffs
Installs: 19 488
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- squizlabs/php_codesniffer: ^3.2
README
Sniffs for INSPIRE Coding Standard.
List of sniffs
Inspire.ControlStructures.DisallowHashComments 🔧
Reports and fixes hash comments in the code.
❌ $correct = false; # This is (invalid) hash comment
👍 $correct = true; // This is a valid comment
Inspire.ControlStructures.InlineCommentSpacing 🔧
Reports and fixes invalid spaces count before and after inline comment start
❌ //wrong inline comment // wrong inline comment $a = 1; //wrong inline comment (missing space after "//") $b = 2;// also wrong inline comment (missing space before "//")
👍 // correct inline comment with exactly one space after "//" $a = 1; // correct inline comment $b = 2; // correct inline comment
Inspire.ControlStructures.ControlStructureSpacing 🔧
Reports and fixes for correct spaces after control structures (exactly one space is expected, no more, no less).
❌ if($foo) { //... }
👍 if ($foo) { //... }
Inspire.ControlStructures.ClosingParenthesisOpeningCurlyBracketSameLineOnMultilineIf 🔧
Reports when closing parenthesis is not on the same line as opening curly bracket of if
with multiline condition.
❌ if ( $foo && $bar ) { //...
👍 if ( $foo && $bar ) { //...
Inspire.Methods.ClosingParenthesisOpeningCurlyBracketSameLineOnMultilineMethods 🔧
Reports when closing parenthesis is not on the same line as opening curly bracket on functions and methods with multiline arguments.
❌ public function foo( int $foo, string $bar, ) { //...
👍 public function foo( int $foo, string $bar, ) { //...
Inspire.Methods.MultilineMethodArgumentsParenthesisPosition
Checks whether there is no comma immediately preceding closing parenthesis of function or method argument list.
❌ public function foo( int $foo, string $bar, ) { //...
👍 public function foo( int $foo, string $bar, ) { //...
❌ public function foo(User $user,) { //...
👍 public function foo(User $user) { //...
Inspire.Sniffs.ControlStructures.BlankLinesSniff 🔧
Forces single blank line before control structures (DO, FOR, FOREACH, IF, SWITCH, WHILE), unless they are the first statement after block opening. Contains fixer.
Inspire.Sniffs.Methods.BlankLinesBeforeReturnSniff 🔧
Forces single blank line before return
statement, unless it is the first statement after block opening. Contains fixer.
Inspire.Sniffs.Methods.DisallowTracyDumpMethodsSniff
Disallows debug statements in the code.
Inspire.Sniffs.Classes.EmptyInterfaceSniff
Disallows interfaces with no methods.