Corpus Coding Standard for PHP_CodeSniffer.
Install the latest version with:
composer require --dev 'corpus/coding-standard'
Sniff: Corpus.ControlStructures.ClosingBraceNewline
Ensure that all closing curly brackets are followed by a blank line.
Example:
if( $foo ) {
echo $bar;
}
echo $baz;
Becomes:
if( $foo ) {
echo $bar;
}
echo $baz;
Sniff: Corpus.ControlStructures.OpeningOneTrueBrace
Ensure that the "One True Brace" style is used.
Example:
class Foo
{
public function bar()
{
echo "bbq";
}
}
Becomes:
class Foo {
public function bar() {
echo "bbq";
}
}
Sniff: Corpus.General.BinaryOperationNewline
Ensure that in multiline logical statements && and || lead lines rather than trail.
Example:
if(
$foo &&
$bar &&
$baz
)}
Becomes:
if(
$foo
&& $bar
&& $baz
)}
Sniff: Corpus.General.ReturnTrailingNewline
Ensure that no blank lines separate return statements and following curly braces.
Example:
if( $foo == true ){
return 1;
}
Becomes:
if( $foo == true ){
return 1;
}
Sniff: Corpus.Methods.ClosureSpacing
Force whitespace between function/fn keyword and opening paren on closures.
Example:
$foo = function ( string $foo ) { echo $foo; };
$bar = fn ( int $bar ) => $bar + 1;
Becomes:
$foo = function( string $foo ) { echo $foo; };
$bar = fn( int $bar ) => $bar + 1;
Sniff: Corpus.Methods.MethodParameterFormatting
Set a maximum length for function arguments. Fix by breaking into multiple lines.
Example:
function Foo( ClosingBraceNewlineSniffTest $closingBraceNewlineSniffTest, OpeningOneTrueBraceSniffTest $openingOneTrueBraceSniffTest ) { }
Becomes:
function Foo(
ClosingBraceNewlineSniffTest $closingBraceNewlineSniffTest,
OpeningOneTrueBraceSniffTest $openingOneTrueBraceSniffTest
) { }
<?php
namespace Corpus\Sniffs\Methods;
class MethodParameterFormattingSniff {
/**
* Maximum line character length after which to break function arguments into newlines
*/
public $maxLength = 130;
}
How can I help you explore Laravel packages today?