diff --git a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php index d2ce8d6..61309e6 100644 --- a/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -38,10 +38,10 @@ class ArrayDeclarationSniff implements Sniff */ public function register() { - return array( + return [ T_ARRAY, T_OPEN_SHORT_ARRAY, - ); + ]; } /** @@ -151,7 +151,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, // Check if there are multiple values. If so, then it has to be multiple lines // unless it is contained inside a function call or condition. $valueCount = 0; - $commas = array(); + $commas = []; for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) { // Skip bracketed statements, like function calls. if (T_OPEN_PARENTHESIS === $tokens[$i]['code']) { @@ -182,7 +182,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, if (T_WHITESPACE !== $tokens[($nextArrow - 1)]['code']) { $content = $tokens[($nextArrow - 1)]['content']; $error = 'Expected 1 space between "%s" and double arrow; 0 found'; - $data = array($content); + $data = [$content]; $fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceBeforeDoubleArrow', $data); if (true === $fix) { $phpcsFile->fixer->addContentBefore($nextArrow, ' '); @@ -192,7 +192,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, if (1 !== $spaceLength) { $content = $tokens[($nextArrow - 2)]['content']; $error = 'Expected 1 space between "%s" and double arrow; %s found'; - $data = array($content, $spaceLength); + $data = [$content, $spaceLength]; $fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data); if (true === $fix) { @@ -204,7 +204,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, if (T_WHITESPACE !== $tokens[($nextArrow + 1)]['code']) { $content = $tokens[($nextArrow + 1)]['content']; $error = 'Expected 1 space between double arrow and "%s"; 0 found'; - $data = array($content); + $data = [$content]; $fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceAfterDoubleArrow', $data); if (true === $fix) { @@ -215,7 +215,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, if (1 !== $spaceLength) { $content = $tokens[($nextArrow + 2)]['content']; $error = 'Expected 1 space between double arrow and "%s"; %s found'; - $data = array($content, $spaceLength); + $data = [$content, $spaceLength]; $fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data); if (true === $fix) { @@ -300,7 +300,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ $expected = ($currentIndent); $found = ($tokens[$arrayEnd]['column'] - 1); $error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s'; - $data = array($expected, $found); + $data = [$expected, $found]; $fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotAligned', $data); if (true === $fix) { @@ -314,7 +314,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ $keyUsed = false; $singleUsed = false; - $indices = array(); + $indices = []; $maxLength = 0; if (T_ARRAY === $tokens[$stackPtr]['code']) { @@ -340,7 +340,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ ) { // Let subsequent calls of this test handle nested arrays. if (T_DOUBLE_ARROW !== $tokens[$lastToken]['code']) { - $indices[] = array('value' => $nextToken); + $indices[] = ['value' => $nextToken]; $lastToken = $nextToken; } @@ -369,7 +369,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ continue; } - $currentEntry = array(); + $currentEntry = []; if (T_COMMA === $tokens[$nextToken]['code']) { $stackPtrCount = 0; @@ -410,10 +410,10 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ } $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( + $data = [ $content, $spaceLength, - ); + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data); if (true === $fix) { @@ -428,7 +428,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ true ); - $indices[] = array('value' => $valueContent); + $indices[] = ['value' => $valueContent]; $singleUsed = true; } @@ -540,7 +540,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ $found = ($tokens[$first]['column'] - 1); if ($found !== $expected) { $error = 'Array value not aligned correctly; expected %s spaces but found %s'; - $data = array($expected, $found); + $data = [$expected, $found]; $fix = $phpcsFile->addFixableError($error, $value['value'], 'ValueNotAligned', $data); if (true === $fix) { @@ -636,7 +636,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ $expected = ($indicesStart - 1); $found = ($tokens[$index['index']]['column'] - 1); $error = 'Array key not aligned correctly; expected %s spaces but found %s'; - $data = array($expected, $found); + $data = [$expected, $found]; $fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data); @@ -661,7 +661,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ } $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; - $data = array($expected, $found); + $data = [$expected, $found]; if ('newline' !== $found || false === $this->ignoreNewLines) { $fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data); @@ -786,7 +786,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $ $content = $tokens[($nextComma - 2)]['content']; $spaceLength = $tokens[($nextComma - 1)]['length']; $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array($content, $spaceLength); + $data = [$content, $spaceLength]; $fix = $phpcsFile->addFixableError($error, $nextComma, 'SpaceBeforeComma', $data); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php b/SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php index 04cf733..54ee507 100644 --- a/SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php +++ b/SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php @@ -14,11 +14,11 @@ class ClassDeclarationSniff */ public function register() { - return array( + return [ T_CLASS, T_INTERFACE, T_TRAIT, - ); + ]; } /** @@ -39,7 +39,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $nextElement = $phpcsFile->findNext(array(T_WHITESPACE), $openingBrace + 1, null, true); + $nextElement = $phpcsFile->findNext([T_WHITESPACE], $openingBrace + 1, null, true); if ($tokens[$openingBrace]['line'] + 1 < $tokens[$nextElement]['line']) { $fix = $phpcsFile->addFixableError( diff --git a/SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php b/SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php index 9dbf435..15380de 100644 --- a/SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php @@ -17,9 +17,9 @@ class PropertyDeclarationSniff implements Sniff */ public function register() { - return array( + return [ T_CLASS, - ); + ]; } /** @@ -46,11 +46,11 @@ public function process(File $phpcsFile, $stackPtr) $end ); - $wantedTokens = array( + $wantedTokens = [ T_PUBLIC, T_PROTECTED, T_PRIVATE, - ); + ]; while ($scope) { $scope = $phpcsFile->findNext( diff --git a/SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php b/SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php index 3c8296c..abf7fb8 100644 --- a/SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php @@ -25,61 +25,61 @@ class ClassCommentSniff extends PEARClassCommentSniff * * @var array */ - protected $tags = array( - 'category' => array( + protected $tags = [ + 'category' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'precedes @package', - ), - 'package' => array( + ], + 'package' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @category', - ), - 'subpackage' => array( + ], + 'subpackage' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @package', - ), - 'author' => array( + ], + 'author' => [ 'required' => false, 'allow_multiple' => true, 'order_text' => 'follows @subpackage (if used) or @package', - ), - 'copyright' => array( + ], + 'copyright' => [ 'required' => false, 'allow_multiple' => true, 'order_text' => 'follows @author', - ), - 'license' => array( + ], + 'license' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @copyright (if used) or @author', - ), - 'version' => array( + ], + 'version' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @license', - ), - 'link' => array( + ], + 'link' => [ 'required' => false, 'allow_multiple' => true, 'order_text' => 'follows @version', - ), - 'see' => array( + ], + 'see' => [ 'required' => false, 'allow_multiple' => true, 'order_text' => 'follows @link', - ), - 'since' => array( + ], + 'since' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @see (if used) or @link', - ), - 'deprecated' => array( + ], + 'deprecated' => [ 'required' => false, 'allow_multiple' => false, 'order_text' => 'follows @since (if used) or @see (if used) or @link', - ), - ); + ], + ]; } diff --git a/SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php b/SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php index 6ff5203..b58664d 100644 --- a/SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php @@ -15,10 +15,10 @@ class DocCommentForbiddenTagsSniff implements Sniff * * @var array */ - public $tags = array( + public $tags = [ '@package', '@subpackage', - ); + ]; /** * A list of tokenizers this sniff supports. @@ -27,9 +27,9 @@ class DocCommentForbiddenTagsSniff implements Sniff */ public function register() { - return array( + return [ T_DOC_COMMENT_TAG - ); + ]; } /** @@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr) 'The %s annotation is forbidden to use', $stackPtr, '', - array($tokens[$stackPtr]['content']) + [$tokens[$stackPtr]['content']] ); } } diff --git a/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php b/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php index e627211..ce32cfa 100644 --- a/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php @@ -15,7 +15,7 @@ class DocCommentGroupSameTypeSniff implements Sniff * * @var array */ - public $tags = array( + public $tags = [ '@api', '@author', '@category', @@ -46,7 +46,7 @@ class DocCommentGroupSameTypeSniff implements Sniff '@uses', '@var', '@version', - ); + ]; /** * A list of tokenizers this sniff supports. @@ -55,9 +55,9 @@ class DocCommentGroupSameTypeSniff implements Sniff */ public function register() { - return array( + return [ T_DOC_COMMENT_OPEN_TAG - ); + ]; } /** @@ -148,7 +148,7 @@ public function process(File $phpcsFile, $stackPtr) if ($previousLine === $commentTagLine - 1) { $firstOnLine = $phpcsFile->findFirstOnLine( - array(), + [], $commentTag, true ); diff --git a/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php b/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php index 0a0f2f6..15bc6f7 100644 --- a/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php @@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr) if (count($realParams) > 0) { foreach ($realParams as $neededParam) { $error = 'Doc comment for parameter "%s" missing'; - $data = array($neededParam['name']); + $data = [$neededParam['name']]; $phpcsFile->addError($error, $stackPtr, 'MissingParamTag', $data); } } @@ -198,7 +198,7 @@ protected function processWhitespace( $rule = 'SpacingBeforeFunction'; } - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/Commenting/VariableCommentSniff.php b/SymfonyCustom/Sniffs/Commenting/VariableCommentSniff.php index f779f0c..c59c352 100644 --- a/SymfonyCustom/Sniffs/Commenting/VariableCommentSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/VariableCommentSniff.php @@ -21,14 +21,14 @@ class VariableCommentSniff extends AbstractVariableSniff public function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $ignore = array( + $ignore = [ T_PUBLIC, T_PRIVATE, T_PROTECTED, T_VAR, T_STATIC, T_WHITESPACE, - ); + ]; $commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); if (false === $commentEnd @@ -125,7 +125,7 @@ protected function processWhitespace( $error = 'Expected 1 blank line before docblock; %s found'; $rule = 'SpacingBeforeDocblock'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/Errors/ExceptionMessageSniff.php b/SymfonyCustom/Sniffs/Errors/ExceptionMessageSniff.php index 91cf1b0..bdaae45 100644 --- a/SymfonyCustom/Sniffs/Errors/ExceptionMessageSniff.php +++ b/SymfonyCustom/Sniffs/Errors/ExceptionMessageSniff.php @@ -17,9 +17,9 @@ class ExceptionMessageSniff implements Sniff */ public function register() { - return array( + return [ T_THROW, - ); + ]; } /** diff --git a/SymfonyCustom/Sniffs/Errors/UserDeprecatedSniff.php b/SymfonyCustom/Sniffs/Errors/UserDeprecatedSniff.php index f646d2b..8dc7735 100644 --- a/SymfonyCustom/Sniffs/Errors/UserDeprecatedSniff.php +++ b/SymfonyCustom/Sniffs/Errors/UserDeprecatedSniff.php @@ -17,9 +17,9 @@ class UserDeprecatedSniff implements Sniff */ public function register() { - return array( + return [ T_STRING, - ); + ]; } /** diff --git a/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php b/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php index 2e4eb01..15b2257 100644 --- a/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php +++ b/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php @@ -20,9 +20,9 @@ class BlankLineBeforeReturnSniff implements Sniff */ public function register() { - return array( + return [ T_RETURN - ); + ]; } /** diff --git a/SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php b/SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php index 45ed409..2c86fa8 100644 --- a/SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php +++ b/SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php @@ -15,10 +15,10 @@ class StrictComparisonSniff implements Sniff * * @var array */ - public $operators = array( + public $operators = [ 'T_IS_EQUAL' => '===', 'T_IS_NOT_EQUAL' => '!==', - ); + ]; /** * A list of tokenizers this sniff supports. @@ -27,10 +27,10 @@ class StrictComparisonSniff implements Sniff */ public function register() { - return array( + return [ T_IS_EQUAL, T_IS_NOT_EQUAL, - ); + ]; } /** @@ -50,10 +50,10 @@ public function process(File $phpcsFile, $stackPtr) 'The %s comparator is not recommended, use %s instead', $stackPtr, '', - array( + [ $tokens[$stackPtr]['content'], $this->operators[$tokens[$stackPtr]['type']], - ) + ] ); } } diff --git a/SymfonyCustom/Sniffs/Formatting/YodaConditionSniff.php b/SymfonyCustom/Sniffs/Formatting/YodaConditionSniff.php index bd3f9da..22f5c42 100644 --- a/SymfonyCustom/Sniffs/Formatting/YodaConditionSniff.php +++ b/SymfonyCustom/Sniffs/Formatting/YodaConditionSniff.php @@ -18,12 +18,12 @@ class YodaConditionSniff implements Sniff */ public function register() { - return array( + return [ T_IS_EQUAL, T_IS_NOT_EQUAL, T_IS_IDENTICAL, T_IS_NOT_IDENTICAL, - ); + ]; } /** @@ -62,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr) // If this is a function call or something, we are OK. if (in_array( $tokens[$i]['code'], - array(T_CONSTANT_ENCAPSED_STRING, T_CLOSE_PARENTHESIS, T_OPEN_PARENTHESIS, T_RETURN), + [T_CONSTANT_ENCAPSED_STRING, T_CLOSE_PARENTHESIS, T_OPEN_PARENTHESIS, T_RETURN], true ) ) { @@ -86,9 +86,9 @@ public function process(File $phpcsFile, $stackPtr) ); } - if (in_array($tokens[$nextNonEmpty]['code'], array(T_SELF, T_PARENT, T_STATIC), true)) { + if (in_array($tokens[$nextNonEmpty]['code'], [T_SELF, T_PARENT, T_STATIC], true)) { $nextNonEmpty = $phpcsFile->findNext( - array_merge(Tokens::$emptyTokens, array(T_DOUBLE_COLON)), + array_merge(Tokens::$emptyTokens, [T_DOUBLE_COLON]), ($nextNonEmpty + 1), null, true diff --git a/SymfonyCustom/Sniffs/Functions/ScopeOrderSniff.php b/SymfonyCustom/Sniffs/Functions/ScopeOrderSniff.php index 3291c2a..ccfd7a1 100644 --- a/SymfonyCustom/Sniffs/Functions/ScopeOrderSniff.php +++ b/SymfonyCustom/Sniffs/Functions/ScopeOrderSniff.php @@ -15,11 +15,11 @@ class ScopeOrderSniff implements Sniff * * @var array */ - public $whitelisted = array( + public $whitelisted = [ '__construct', 'setUp', 'tearDown', - ); + ]; /** * Returns an array of tokens this test wants to listen for. @@ -28,10 +28,10 @@ class ScopeOrderSniff implements Sniff */ public function register() { - return array( + return [ T_CLASS, T_INTERFACE, - ); + ]; } /** @@ -47,11 +47,11 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $function = $stackPtr; - $scopes = array( + $scopes = [ 0 => T_PUBLIC, 1 => T_PROTECTED, 2 => T_PRIVATE, - ); + ]; while ($function) { $end = null; diff --git a/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php b/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php index e731831..bdd6d63 100644 --- a/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php +++ b/SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php @@ -22,7 +22,7 @@ class AlphabeticallySortedUseSniff implements Sniff */ public function register() { - return array(T_USE); + return [T_USE]; } /** @@ -84,7 +84,7 @@ private function shouldIgnoreUse(File $phpcsFile, $stackPtr) } // Ignore USE keywords inside class and trait - if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true) { + if ($phpcsFile->hasCondition($stackPtr, [T_CLASS, T_TRAIT]) === true) { return true; } diff --git a/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php b/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php index 323949f..e0ca5ad 100644 --- a/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php +++ b/SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php @@ -18,7 +18,7 @@ class UnusedUseSniff implements Sniff */ public function register() { - return array(T_USE); + return [T_USE]; } /** diff --git a/SymfonyCustom/Sniffs/NamingConventions/ValidClassNameSniff.php b/SymfonyCustom/Sniffs/NamingConventions/ValidClassNameSniff.php index f1965fa..1ecb1f1 100644 --- a/SymfonyCustom/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/SymfonyCustom/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -17,12 +17,12 @@ class ValidClassNameSniff implements Sniff */ public function register() { - return array( + return [ T_INTERFACE, T_TRAIT, T_EXTENDS, T_ABSTRACT, - ); + ]; } /** diff --git a/SymfonyCustom/Sniffs/NamingConventions/ValidFileNameSniff.php b/SymfonyCustom/Sniffs/NamingConventions/ValidFileNameSniff.php index 0d70810..aa1aca4 100644 --- a/SymfonyCustom/Sniffs/NamingConventions/ValidFileNameSniff.php +++ b/SymfonyCustom/Sniffs/NamingConventions/ValidFileNameSniff.php @@ -17,7 +17,7 @@ class ValidFileNameSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } /** diff --git a/SymfonyCustom/Sniffs/NamingConventions/ValidScalarTypeNameSniff.php b/SymfonyCustom/Sniffs/NamingConventions/ValidScalarTypeNameSniff.php index 3f9cca4..739056a 100644 --- a/SymfonyCustom/Sniffs/NamingConventions/ValidScalarTypeNameSniff.php +++ b/SymfonyCustom/Sniffs/NamingConventions/ValidScalarTypeNameSniff.php @@ -16,12 +16,12 @@ class ValidScalarTypeNameSniff implements Sniff * * @var array */ - public $types = array( + public $types = [ 'boolean' => 'bool', 'double' => 'float', 'integer' => 'int', 'real' => 'float', - ); + ]; /** * A list of tokenizers this sniff supports. @@ -69,7 +69,7 @@ protected function validateDocComment(File $phpcsFile, $stackPtr) foreach ($tokens[$stackPtr]['comment_tags'] as $commentTag) { if (in_array( $tokens[$commentTag]['content'], - array('@param', '@return', '@var') + ['@param', '@return', '@var'] ) ) { $docString = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $commentTag); @@ -120,7 +120,7 @@ protected function validateTypeName( 'For type-hinting in PHPDocs and casting, use %s instead of %s', $stackPtr, '', - array($validTypeName, $typeName) + [$validTypeName, $typeName] ); if ($needFix) { $tokens = $phpcsFile->getTokens(); diff --git a/SymfonyCustom/Sniffs/Objects/ObjectInstantiationSniff.php b/SymfonyCustom/Sniffs/Objects/ObjectInstantiationSniff.php index d3266f4..6dd9bd1 100644 --- a/SymfonyCustom/Sniffs/Objects/ObjectInstantiationSniff.php +++ b/SymfonyCustom/Sniffs/Objects/ObjectInstantiationSniff.php @@ -17,9 +17,9 @@ class ObjectInstantiationSniff implements Sniff */ public function register() { - return array( + return [ T_NEW, - ); + ]; } /** @@ -33,13 +33,13 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $allowed = array( + $allowed = [ T_STRING, T_NS_SEPARATOR, T_VARIABLE, T_STATIC, T_SELF, - ); + ]; $object = $stackPtr; $line = $tokens[$object]['line']; diff --git a/SymfonyCustom/Sniffs/Scope/MethodScopeSniff.php b/SymfonyCustom/Sniffs/Scope/MethodScopeSniff.php index b66b4ba..75017a3 100644 --- a/SymfonyCustom/Sniffs/Scope/MethodScopeSniff.php +++ b/SymfonyCustom/Sniffs/Scope/MethodScopeSniff.php @@ -16,7 +16,7 @@ class MethodScopeSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS), array(T_FUNCTION)); + parent::__construct([T_CLASS], [T_FUNCTION]); } /** @@ -50,7 +50,7 @@ protected function processTokenWithinScope( || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line']) ) { $error = 'No scope modifier specified for function "%s"'; - $data = array($methodName); + $data = [$methodName]; $phpcsFile->addError($error, $stackPtr, 'Missing', $data); } } diff --git a/SymfonyCustom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php index f742a49..3d79a31 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php @@ -19,10 +19,11 @@ class CloseBracketSpacingSniff implements Sniff */ public function register() { - return array( + return [ T_CLOSE_CURLY_BRACKET, T_CLOSE_PARENTHESIS, - ); + T_CLOSE_SHORT_ARRAY, + ]; } /** @@ -49,7 +50,7 @@ public function process(File $phpcsFile, $stackPtr) $error, ($stackPtr - 1), 'ClosingWhitespace', - array($tokens[$stackPtr]['content']) + [$tokens[$stackPtr]['content']] ); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php index 0de9bb9..dc4655e 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/DocCommentTagSpacingSniff.php @@ -15,7 +15,7 @@ class DocCommentTagSpacingSniff implements Sniff * * @var array */ - public $tags = array( + public $tags = [ '@api', '@author', '@category', @@ -46,7 +46,7 @@ class DocCommentTagSpacingSniff implements Sniff '@uses', '@var', '@version', - ); + ]; /** * Returns an array of tokens this test wants to listen for. @@ -55,9 +55,9 @@ class DocCommentTagSpacingSniff implements Sniff */ public function register() { - return array( + return [ T_DOC_COMMENT_TAG - ); + ]; } /** @@ -117,7 +117,7 @@ public function process(File $phpcsFile, $stackPtr) $error, ($stackPtr + 1), 'DocCommentTagSpacing', - array($tokens[$stackPtr]['content']) + [$tokens[$stackPtr]['content']] ); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/WhiteSpace/EmptyLinesSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/EmptyLinesSniff.php index 29306f5..256a7cc 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/EmptyLinesSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/EmptyLinesSniff.php @@ -17,9 +17,9 @@ class EmptyLinesSniff implements Sniff */ public function register() { - return array( + return [ T_WHITESPACE - ); + ]; } /** diff --git a/SymfonyCustom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php index af7e112..b50d325 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php @@ -18,10 +18,11 @@ class OpenBracketSpacingSniff implements Sniff */ public function register() { - return array( + return [ T_OPEN_CURLY_BRACKET, T_OPEN_PARENTHESIS, - ); + T_OPEN_SHORT_ARRAY, + ]; } /** @@ -45,7 +46,7 @@ public function process(File $phpcsFile, $stackPtr) $error, ($stackPtr + 1), 'OpeningWhitespace', - array($tokens[$stackPtr]['content']) + [$tokens[$stackPtr]['content']] ); if (true === $fix) { diff --git a/SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php b/SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php index 4e7b1e2..d718366 100644 --- a/SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php +++ b/SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php @@ -18,13 +18,13 @@ class UnaryOperatorSpacingSniff implements Sniff */ public function register() { - return array( + return [ T_DEC, T_INC, T_MINUS, T_PLUS, T_BOOLEAN_NOT, - ); + ]; } /** @@ -81,7 +81,7 @@ public function process(File $phpcsFile, $stackPtr) // Find the last syntax item to determine if this is an unary operator. $lastSyntaxItem = $phpcsFile->findPrevious( - array(T_WHITESPACE), + [T_WHITESPACE], $stackPtr - 1, ($tokens[$stackPtr]['column']) * -1, true, @@ -90,7 +90,7 @@ public function process(File $phpcsFile, $stackPtr) ); $operatorSuffixAllowed = in_array( $tokens[$lastSyntaxItem]['code'], - array( + [ T_LNUMBER, T_DNUMBER, T_CLOSE_PARENTHESIS, @@ -98,7 +98,7 @@ public function process(File $phpcsFile, $stackPtr) T_CLOSE_SQUARE_BRACKET, T_VARIABLE, T_STRING, - ) + ] ); // Check plus / minus value assignments or comparisons. diff --git a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php index 157d8a8..96d088a 100644 --- a/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -21,7 +21,7 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 7 => 2, 9 => 1, 22 => 1, @@ -47,7 +47,7 @@ public function getErrorList() 67 => 1, 68 => 1, 70 => 1, - ); + ]; } /** @@ -60,6 +60,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Classes/ClassDeclarationUnitTest.php b/SymfonyCustom/Tests/Classes/ClassDeclarationUnitTest.php index 44a6f18..91ae809 100644 --- a/SymfonyCustom/Tests/Classes/ClassDeclarationUnitTest.php +++ b/SymfonyCustom/Tests/Classes/ClassDeclarationUnitTest.php @@ -21,10 +21,10 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 4 => 1, 13 => 1, - ); + ]; } /** @@ -37,6 +37,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Classes/PropertyDeclarationUnitTest.php b/SymfonyCustom/Tests/Classes/PropertyDeclarationUnitTest.php index c6c6d45..8b27bcb 100644 --- a/SymfonyCustom/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/SymfonyCustom/Tests/Classes/PropertyDeclarationUnitTest.php @@ -21,9 +21,9 @@ class PropertyDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 9 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Commenting/ClassCommentUnitTest.php b/SymfonyCustom/Tests/Commenting/ClassCommentUnitTest.php index 4c57e5b..a4589f4 100644 --- a/SymfonyCustom/Tests/Commenting/ClassCommentUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/ClassCommentUnitTest.php @@ -21,9 +21,9 @@ class ClassCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 3 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Commenting/DocCommentForbiddenTagsUnitTest.php b/SymfonyCustom/Tests/Commenting/DocCommentForbiddenTagsUnitTest.php index b7c5245..b4e962f 100644 --- a/SymfonyCustom/Tests/Commenting/DocCommentForbiddenTagsUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/DocCommentForbiddenTagsUnitTest.php @@ -21,14 +21,14 @@ class DocCommentForbiddenTagsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 6 => 1, 7 => 1, 11 => 1, 15 => 1, 20 => 1, 21 => 1, - ); + ]; } /** @@ -41,6 +41,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Commenting/DocCommentGroupSameTypeUnitTest.php b/SymfonyCustom/Tests/Commenting/DocCommentGroupSameTypeUnitTest.php index 8dab03b..f5efc9a 100644 --- a/SymfonyCustom/Tests/Commenting/DocCommentGroupSameTypeUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/DocCommentGroupSameTypeUnitTest.php @@ -21,7 +21,7 @@ class DocCommentGroupSameTypeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 5 => 1, 7 => 1, 8 => 1, @@ -33,7 +33,7 @@ public function getErrorList() 29 => 1, 33 => 1, 67 => 1, - ); + ]; } /** @@ -46,6 +46,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php index 9982df8..b195110 100644 --- a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php @@ -21,7 +21,7 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 5 => 1, 10 => 2, 43 => 1, @@ -30,7 +30,7 @@ public function getErrorList() 83 => 1, 93 => 1, 102 => 1, - ); + ]; } /** @@ -43,6 +43,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Commenting/VariableCommentUnitTest.php b/SymfonyCustom/Tests/Commenting/VariableCommentUnitTest.php index eeb7c01..8f8890c 100644 --- a/SymfonyCustom/Tests/Commenting/VariableCommentUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/VariableCommentUnitTest.php @@ -21,7 +21,7 @@ class VariableCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 21 => 1, 24 => 1, 56 => 1, @@ -30,7 +30,7 @@ public function getErrorList() 84 => 1, 122 => 1, 124 => 1, - ); + ]; } /** @@ -43,6 +43,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Errors/ExceptionMessageUnitTest.php b/SymfonyCustom/Tests/Errors/ExceptionMessageUnitTest.php index d9d486b..887ba4b 100644 --- a/SymfonyCustom/Tests/Errors/ExceptionMessageUnitTest.php +++ b/SymfonyCustom/Tests/Errors/ExceptionMessageUnitTest.php @@ -21,9 +21,9 @@ class ExceptionMessageUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 17 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Errors/UserDeprecatedUnitTest.php b/SymfonyCustom/Tests/Errors/UserDeprecatedUnitTest.php index 3aebaff..612b35d 100644 --- a/SymfonyCustom/Tests/Errors/UserDeprecatedUnitTest.php +++ b/SymfonyCustom/Tests/Errors/UserDeprecatedUnitTest.php @@ -21,9 +21,9 @@ class UserDeprecatedUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 30 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php index 4298243..da0b570 100644 --- a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php +++ b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php @@ -21,11 +21,11 @@ class BlankLineBeforeReturnUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 60 => 1, 67 => 1, 76 => 1, - ); + ]; } /** @@ -38,6 +38,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Formatting/ConditionalReturnOrThrowUnitTest.php b/SymfonyCustom/Tests/Formatting/ConditionalReturnOrThrowUnitTest.php index 2ece88d..0c6c2ec 100644 --- a/SymfonyCustom/Tests/Formatting/ConditionalReturnOrThrowUnitTest.php +++ b/SymfonyCustom/Tests/Formatting/ConditionalReturnOrThrowUnitTest.php @@ -21,11 +21,11 @@ class ConditionalReturnOrThrowUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 22 => 1, 37 => 1, 44 => 1, - ); + ]; } /** @@ -38,6 +38,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php b/SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php index 23b0c63..4a6e929 100644 --- a/SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php +++ b/SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php @@ -18,7 +18,7 @@ class StrictComparisonUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; } /** @@ -28,9 +28,9 @@ public function getErrorList() */ public function getWarningList() { - return array( + return [ 3 => 1, 5 => 1, - ); + ]; } } diff --git a/SymfonyCustom/Tests/Formatting/YodaConditionUnitTest.php b/SymfonyCustom/Tests/Formatting/YodaConditionUnitTest.php index 1527a51..9d45648 100644 --- a/SymfonyCustom/Tests/Formatting/YodaConditionUnitTest.php +++ b/SymfonyCustom/Tests/Formatting/YodaConditionUnitTest.php @@ -18,7 +18,7 @@ class YodaConditionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 2 => 2, 4 => 2, 11 => 1, @@ -32,7 +32,7 @@ public function getErrorList() 87 => 1, 92 => 1, 95 => 1, - ); + ]; } /** @@ -42,6 +42,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Functions/ScopeOrderUnitTest.php b/SymfonyCustom/Tests/Functions/ScopeOrderUnitTest.php index 0bb832f..a019159 100644 --- a/SymfonyCustom/Tests/Functions/ScopeOrderUnitTest.php +++ b/SymfonyCustom/Tests/Functions/ScopeOrderUnitTest.php @@ -21,10 +21,10 @@ class ScopeOrderUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 9 => 1, 20 => 1, - ); + ]; } /** @@ -37,6 +37,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Namespaces/AlphabeticallySortedUseUnitTest.php b/SymfonyCustom/Tests/Namespaces/AlphabeticallySortedUseUnitTest.php index b527937..f323199 100644 --- a/SymfonyCustom/Tests/Namespaces/AlphabeticallySortedUseUnitTest.php +++ b/SymfonyCustom/Tests/Namespaces/AlphabeticallySortedUseUnitTest.php @@ -21,10 +21,10 @@ class AlphabeticallySortedUseUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 8 => 1, 22 => 1, - ); + ]; } /** @@ -37,6 +37,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php b/SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php index dba62b0..54d38cb 100644 --- a/SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php +++ b/SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php @@ -21,9 +21,9 @@ class UnusedUseUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 11 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/NamingConventions/ValidClassNameUnitTest.php b/SymfonyCustom/Tests/NamingConventions/ValidClassNameUnitTest.php index 6ed33fb..52e3a0e 100644 --- a/SymfonyCustom/Tests/NamingConventions/ValidClassNameUnitTest.php +++ b/SymfonyCustom/Tests/NamingConventions/ValidClassNameUnitTest.php @@ -21,14 +21,14 @@ class ValidClassNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 3 => 1, 11 => 1, 19 => 1, 23 => 1, 31 => 1, 35 => 1, - ); + ]; } /** @@ -41,6 +41,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php b/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php index 177e905..e263920 100644 --- a/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php +++ b/SymfonyCustom/Tests/NamingConventions/ValidFileNameUnitTest.php @@ -45,6 +45,6 @@ public function getErrorList($filename = '') */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/NamingConventions/ValidScalarTypeNameUnitTest.php b/SymfonyCustom/Tests/NamingConventions/ValidScalarTypeNameUnitTest.php index 31ea97f..206bc8f 100644 --- a/SymfonyCustom/Tests/NamingConventions/ValidScalarTypeNameUnitTest.php +++ b/SymfonyCustom/Tests/NamingConventions/ValidScalarTypeNameUnitTest.php @@ -21,7 +21,7 @@ class ValidScalarTypeNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 26 => 1, 27 => 1, 28 => 1, @@ -43,7 +43,7 @@ public function getErrorList() 49 => 1, 50 => 1, 51 => 1, - ); + ]; } /** @@ -56,6 +56,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.php b/SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.php index 3fb2327..2a618ca 100644 --- a/SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.php +++ b/SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.php @@ -21,7 +21,7 @@ class ObjectInstantiationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 4 => 1, 5 => 1, 6 => 1, @@ -29,7 +29,7 @@ public function getErrorList() 8 => 1, 9 => 1, 10 => 1, - ); + ]; } /** @@ -42,6 +42,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/Scope/MethodScopeUnitTest.php b/SymfonyCustom/Tests/Scope/MethodScopeUnitTest.php index 736b67d..23ec3e3 100644 --- a/SymfonyCustom/Tests/Scope/MethodScopeUnitTest.php +++ b/SymfonyCustom/Tests/Scope/MethodScopeUnitTest.php @@ -21,9 +21,9 @@ class MethodScopeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 5 => 1, - ); + ]; } /** @@ -36,6 +36,6 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc index 0bb861c..187ed40 100644 --- a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc +++ b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc @@ -5,3 +5,5 @@ testFunction( args1, args2 ); function f( ) { }; $array = array( 1, 2 ); + +$array = [ 1, 2 ]; diff --git a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc.fixed b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc.fixed index 985388f..75f5684 100644 --- a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc.fixed +++ b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc.fixed @@ -5,3 +5,5 @@ testFunction( args1, args2); function f() {}; $array = array( 1, 2); + +$array = [ 1, 2]; diff --git a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.php b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.php index fc978ca..56fc4a5 100644 --- a/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.php +++ b/SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.php @@ -21,11 +21,12 @@ class CloseBracketSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 3 => 1, 5 => 2, 7 => 1, - ); + 9 => 1, + ]; } /** @@ -38,6 +39,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/WhiteSpace/DocCommentTagSpacingUnitTest.php b/SymfonyCustom/Tests/WhiteSpace/DocCommentTagSpacingUnitTest.php index 52f91b5..cff1fee 100644 --- a/SymfonyCustom/Tests/WhiteSpace/DocCommentTagSpacingUnitTest.php +++ b/SymfonyCustom/Tests/WhiteSpace/DocCommentTagSpacingUnitTest.php @@ -21,7 +21,7 @@ class DocCommentTagSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 11 => 1, 13 => 1, 14 => 1, @@ -29,7 +29,7 @@ public function getErrorList() 40 => 1, 42 => 1, 46 => 1, - ); + ]; } /** @@ -42,6 +42,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/WhiteSpace/EmptyLinesUnitTest.php b/SymfonyCustom/Tests/WhiteSpace/EmptyLinesUnitTest.php index d99dae4..77a8198 100644 --- a/SymfonyCustom/Tests/WhiteSpace/EmptyLinesUnitTest.php +++ b/SymfonyCustom/Tests/WhiteSpace/EmptyLinesUnitTest.php @@ -21,11 +21,11 @@ class EmptyLinesUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 3 => 1, 6 => 1, 7 => 1, - ); + ]; } /** @@ -38,6 +38,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc index 0bb861c..187ed40 100644 --- a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc +++ b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc @@ -5,3 +5,5 @@ testFunction( args1, args2 ); function f( ) { }; $array = array( 1, 2 ); + +$array = [ 1, 2 ]; diff --git a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc.fixed b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc.fixed index f15025a..5833068 100644 --- a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc.fixed +++ b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc.fixed @@ -5,3 +5,5 @@ testFunction(args1, args2 ); function f() {}; $array = array(1, 2 ); + +$array = [1, 2 ]; diff --git a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.php b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.php index 92bc848..4d26b97 100644 --- a/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.php +++ b/SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.php @@ -21,11 +21,12 @@ class OpenBracketSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 3 => 1, 5 => 2, 7 => 1, - ); + 9 => 1, + ]; } /** @@ -38,6 +39,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.php b/SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.php index 4f4dc1f..8ecc1d5 100644 --- a/SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.php +++ b/SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.php @@ -21,7 +21,7 @@ class UnaryOperatorSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( + return [ 4 => 1, 7 => 1, 9 => 1, @@ -29,7 +29,7 @@ public function getErrorList() 14 => 1, 17 => 1, 18 => 1, - ); + ]; } /** @@ -42,6 +42,6 @@ public function getErrorList() */ protected function getWarningList() { - return array(); + return []; } } diff --git a/SymfonyCustom/ruleset.xml b/SymfonyCustom/ruleset.xml index 3ff279c..da946ff 100755 --- a/SymfonyCustom/ruleset.xml +++ b/SymfonyCustom/ruleset.xml @@ -3,22 +3,14 @@ The SymfonyCustom coding standard. - - */app/* - */bin/* - */var/* - */vendor/* - */web/* - - - */Resources/* - - - + + + + @@ -79,5 +71,20 @@ + + + + + + + + + + + + + + + diff --git a/build.properties b/build.properties index 4684a2d..3e0c1be 100644 --- a/build.properties +++ b/build.properties @@ -7,6 +7,7 @@ phpunit.bin = ${basedir}/vendor/bin/phpunit # PHP Code Sniffer ## Paths +phpcbf.bin = ${basedir}/vendor/bin/phpcbf phpcs.bin = ${basedir}/vendor/bin/phpcs phpcs.dir = ${basedir}/vendor/squizlabs/php_codesniffer phpcs.symlink.path = ${basedir}/vendor/squizlabs/php_codesniffer/src/Standards/SymfonyCustom diff --git a/build.xml b/build.xml index af07980..1c07975 100644 --- a/build.xml +++ b/build.xml @@ -44,6 +44,15 @@ + + + + + + + + + diff --git a/docs/standards.md b/docs/standards.md index acad49f..6c04f18 100644 --- a/docs/standards.md +++ b/docs/standards.md @@ -3,6 +3,12 @@ We imported the [PSR2 Standard](./standards/psr2.md) with these overrides: +- There is not line length limit + +``` + +``` + - There MUST NOT be trailing whitespace at the end of blank lines ``` @@ -41,7 +47,7 @@ we do not respect this rule: ## Others ### Imported -- Do not use ` @@ -53,6 +59,12 @@ we do not respect this rule: ``` +- Do not use space inside type casting + +``` + +``` + - Use lowercase for PHP functions ``` @@ -98,6 +110,44 @@ we do not respect this rule: ``` +- Use short array syntax + +``` + +``` + +- Do not use empty PHP statement + +``` + +``` + +- Add a single space around logical operator (`&&`, `||`, `...`) + +``` + +``` + +- Do not use space around object operators (`->`) + +``` + + + + + +``` + +- Do not use unnecessary concat operator + +``` + + + + + +``` + ### Custom - Some others checks are made about array (`=>` alignments and indentation) @@ -105,7 +155,7 @@ we do not respect this rule: ``` -- Do not use spaces after `(` or `{` and before `)` or `}` +- Do not use spaces after `(`, `{` or `[` and before `)`, `}` or `]` ``` diff --git a/docs/standards/psr2.md b/docs/standards/psr2.md index 024fcfd..46c5921 100644 --- a/docs/standards/psr2.md +++ b/docs/standards/psr2.md @@ -71,24 +71,12 @@ ``` -- The soft limit on line length MUST be 120 characters; - automated style checkers MUST warn but MUST NOT error at the soft limit. - -``` - - - - - - -``` - - There MUST NOT be trailing whitespace at the end of non-blank lines. ``` - + diff --git a/docs/standards/symfony.md b/docs/standards/symfony.md index cd2bd91..290f4da 100644 --- a/docs/standards/symfony.md +++ b/docs/standards/symfony.md @@ -12,7 +12,12 @@ From [symfony standard](http://symfony.com/doc/current/contributing/code/standar with the exception of the concatenation (`.`) operator ``` - + + + + + +