diff --git a/autoload.php b/autoload.php index f918a1b92e..e4d21ace08 100644 --- a/autoload.php +++ b/autoload.php @@ -32,14 +32,14 @@ class Autoload * * @var array */ - private static $loadedClasses = array(); + private static $loadedClasses = []; /** * A mapping of class names to file names. * * @var array */ - private static $loadedFiles = array(); + private static $loadedFiles = []; /** * A list of additional directories to search during autoloading. @@ -48,7 +48,7 @@ class Autoload * * @var string[] */ - private static $searchPaths = array(); + private static $searchPaths = []; /** diff --git a/package.xml b/package.xml index 64cdcf061d..76131db7db 100644 --- a/package.xml +++ b/package.xml @@ -68,10 +68,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- Previously, STDIN files using fake file paths were excluded from checking - Ignore patterns are now checked on symlink target paths instead of symlink source paths -- Restores previous behaviour of this feature - - The Squiz standard now ensures array keys are indented 4 spaces from the main statement - -- Previously, this standard aligned keys 1 space from the start of the array keyword - - The Squiz standard now ensures array end braces are aligned with the main statement - -- Previously, this standard aligned the close brace with the start of the array keyword - Added AbstractArraySniff to make it easier to create sniffs that check array formatting -- Allows for checking of single and multi line arrays easily -- Provides a parsed structure of the array including positions of keys, values, and double arrows @@ -90,6 +86,12 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- Default remains at 1 -- Thanks to Nikola Kovacs for the patch - PEAR.Functions.FunctionCallSignature now requires the function keyword to be indented to an exact tab stop + - The Squiz standard now ensures array keys are indented 4 spaces from the main statement + -- Previously, this standard aligned keys 1 space from the start of the array keyword + - The Squiz standard now ensures array end braces are aligned with the main statement + -- Previously, this standard aligned the close brace with the start of the array keyword + - The standrd for PHP_CodeSniffer itself now enforces short array syntax + - The standrd for PHP_CodeSniffer itself now uses the Generic.Arrays/ArrayIndent sniff rules - Fixed bug #1462 : Error processing cyrillic strings in Tokenizer - Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function - Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 068b1cfc30..cea560f2c5 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -53,6 +53,7 @@ + @@ -66,6 +67,21 @@ + + + + 0 + + + 0 + + + 0 + + + 0 + + diff --git a/src/Config.php b/src/Config.php index f8229fd179..b49defb180 100644 --- a/src/Config.php +++ b/src/Config.php @@ -97,43 +97,43 @@ class Config * * @var array */ - private $settings = array( - 'files' => null, - 'standards' => null, - 'verbosity' => null, - 'interactive' => null, - 'parallel' => null, - 'cache' => null, - 'cacheFile' => null, - 'colors' => null, - 'explain' => null, - 'local' => null, - 'showSources' => null, - 'showProgress' => null, - 'quiet' => null, - 'annotations' => null, - 'tabWidth' => null, - 'encoding' => null, - 'extensions' => null, - 'sniffs' => null, - 'exclude' => null, - 'ignored' => null, - 'reportFile' => null, - 'generator' => null, - 'filter' => null, - 'bootstrap' => null, - 'reports' => null, - 'basepath' => null, - 'reportWidth' => null, - 'errorSeverity' => null, - 'warningSeverity' => null, - 'recordErrors' => null, - 'suffix' => null, - 'stdin' => null, - 'stdinContent' => null, - 'stdinPath' => null, - 'unknown' => null, - ); + private $settings = [ + 'files' => null, + 'standards' => null, + 'verbosity' => null, + 'interactive' => null, + 'parallel' => null, + 'cache' => null, + 'cacheFile' => null, + 'colors' => null, + 'explain' => null, + 'local' => null, + 'showSources' => null, + 'showProgress' => null, + 'quiet' => null, + 'annotations' => null, + 'tabWidth' => null, + 'encoding' => null, + 'extensions' => null, + 'sniffs' => null, + 'exclude' => null, + 'ignored' => null, + 'reportFile' => null, + 'generator' => null, + 'filter' => null, + 'bootstrap' => null, + 'reports' => null, + 'basepath' => null, + 'reportWidth' => null, + 'errorSeverity' => null, + 'warningSeverity' => null, + 'recordErrors' => null, + 'suffix' => null, + 'stdin' => null, + 'stdinContent' => null, + 'stdinPath' => null, + 'unknown' => null, + ]; /** * Whether or not to kill the process when an unknown command line arg is found. @@ -151,14 +151,14 @@ class Config * * @var string[] */ - private $cliArgs = array(); + private $cliArgs = []; /** * Command line values that the user has supplied directly. * * @var array */ - private $overriddenDefaults = array(); + private $overriddenDefaults = []; /** * Config file data that has been loaded for the run. @@ -179,7 +179,7 @@ class Config * * @var array */ - private static $executablePaths = array(); + private static $executablePaths = []; /** @@ -226,7 +226,7 @@ public function __set($name, $value) } break; case 'standards' : - $cleaned = array(); + $cleaned = []; // Check if the standard name is valid, or if the case is invalid. $installedStandards = Util\Standards::getInstalledStandards(); @@ -316,7 +316,7 @@ public function setSettings($settings) * * @return void */ - public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true) + public function __construct(array $cliArgs=[], $dieOnUnknownArg=true) { if (defined('PHP_CODESNIFFER_IN_TESTS') === true) { // Let everything through during testing so that we can @@ -341,18 +341,18 @@ public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true) // Look for a default ruleset in the current directory or higher. $currentDir = getcwd(); - $defaultFiles = array( - '.phpcs.xml', - 'phpcs.xml', - '.phpcs.xml.dist', - 'phpcs.xml.dist', - ); + $defaultFiles = [ + '.phpcs.xml', + 'phpcs.xml', + '.phpcs.xml.dist', + 'phpcs.xml.dist', + ]; do { foreach ($defaultFiles as $defaultFilename) { $default = $currentDir.DIRECTORY_SEPARATOR.$defaultFilename; if (is_file($default) === true) { - $this->standards = array($default); + $this->standards = [$default]; break(2); } } @@ -444,8 +444,8 @@ public function setCommandLineValues($args) */ public function restoreDefaults() { - $this->files = array(); - $this->standards = array('PEAR'); + $this->files = []; + $this->standards = ['PEAR']; $this->verbosity = 0; $this->interactive = false; $this->cache = false; @@ -460,21 +460,21 @@ public function restoreDefaults() $this->parallel = 1; $this->tabWidth = 0; $this->encoding = 'utf-8'; - $this->extensions = array( - 'php' => 'PHP', - 'inc' => 'PHP', - 'js' => 'JS', - 'css' => 'CSS', - ); - $this->sniffs = array(); - $this->exclude = array(); - $this->ignored = array(); + $this->extensions = [ + 'php' => 'PHP', + 'inc' => 'PHP', + 'js' => 'JS', + 'css' => 'CSS', + ]; + $this->sniffs = []; + $this->exclude = []; + $this->ignored = []; $this->reportFile = null; $this->generator = null; $this->filter = null; - $this->bootstrap = array(); + $this->bootstrap = []; $this->basepath = null; - $this->reports = array('full' => null); + $this->reports = ['full' => null]; $this->reportWidth = 'auto'; $this->errorSeverity = 5; $this->warningSeverity = 5; @@ -483,7 +483,7 @@ public function restoreDefaults() $this->stdin = false; $this->stdinContent = null; $this->stdinPath = null; - $this->unknown = array(); + $this->unknown = []; $standard = self::getConfigData('default_standard'); if ($standard !== null) { @@ -492,7 +492,7 @@ public function restoreDefaults() $reportFormat = self::getConfigData('report_format'); if ($reportFormat !== null) { - $this->reports = array($reportFormat => null); + $this->reports = [$reportFormat => null]; } $tabWidth = self::getConfigData('tab_width'); @@ -891,7 +891,7 @@ public function processLongArgument($arg, $pos) } } else if (substr($arg, 0, 10) === 'bootstrap=') { $files = explode(',', substr($arg, 10)); - $bootstrap = array(); + $bootstrap = []; foreach ($files as $file) { $path = Util\Common::realpath($file); if ($path === false) { @@ -1008,7 +1008,7 @@ public function processLongArgument($arg, $pos) throw new DeepExitException($error, 3); } } else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) { - $reports = array(); + $reports = []; if ($arg[6] === '-') { // This is a report with file output. @@ -1083,7 +1083,7 @@ public function processLongArgument($arg, $pos) } $extensions = explode(',', substr($arg, 11)); - $newExtensions = array(); + $newExtensions = []; foreach ($extensions as $ext) { $slash = strpos($ext, '/'); if ($slash !== false) { @@ -1152,7 +1152,7 @@ public function processLongArgument($arg, $pos) substr($arg, 7) ); - $ignored = array(); + $ignored = []; foreach ($patterns as $pattern) { $pattern = trim($pattern); if ($pattern === '') { @@ -1619,8 +1619,8 @@ public static function getAllConfigData() } if (is_file($configFile) === false) { - self::$configData = array(); - return array(); + self::$configData = []; + return []; } if (is_readable($configFile) === false) { diff --git a/src/Files/File.php b/src/Files/File.php index e11c0bcccc..fbb3ff1d75 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -99,7 +99,7 @@ class File * * @var array */ - protected $tokens = array(); + protected $tokens = []; /** * The errors raised from sniffs. @@ -107,7 +107,7 @@ class File * @var array * @see getErrors() */ - protected $errors = array(); + protected $errors = []; /** * The warnings raised from sniffs. @@ -115,7 +115,7 @@ class File * @var array * @see getWarnings() */ - protected $warnings = array(); + protected $warnings = []; /** * The metrics recorded by sniffs. @@ -123,7 +123,7 @@ class File * @var array * @see getMetrics() */ - protected $metrics = array(); + protected $metrics = []; /** * The total number of errors raised. @@ -158,21 +158,21 @@ class File * * @var array */ - protected $ignoredListeners = array(); + protected $ignoredListeners = []; /** * An array of message codes that are being ignored. * * @var array */ - protected $ignoredCodes = array(); + protected $ignoredCodes = []; /** * An array of sniffs listening to this file's processing. * * @var \PHP_CodeSniffer\Sniffs\Sniff[] */ - protected $listeners = array(); + protected $listeners = []; /** * The class name of the sniff currently processing the file. @@ -186,7 +186,7 @@ class File * * @var array */ - protected $listenerTimes = array(); + protected $listenerTimes = []; /** * A cache of often used config settings to improve performance. @@ -195,7 +195,7 @@ class File * * @var array */ - protected $configCache = array(); + protected $configCache = []; /** @@ -246,7 +246,7 @@ public function __construct($path, Ruleset $ruleset, Config $config) public function setContent($content) { $this->content = $content; - $this->tokens = array(); + $this->tokens = []; try { $this->eolChar = Util\Common::detectLineEndings($content); @@ -295,8 +295,8 @@ public function process() return; } - $this->errors = array(); - $this->warnings = array(); + $this->errors = []; + $this->warnings = []; $this->errorCount = 0; $this->warningCount = 0; $this->fixableCount = 0; @@ -310,7 +310,7 @@ public function process() } $foundCode = false; - $listenerIgnoreTo = array(); + $listenerIgnoreTo = []; $inTests = defined('PHP_CODESNIFFER_IN_TESTS'); $checkAnnotations = $this->config->annotations; @@ -331,8 +331,8 @@ public function process() if (strpos($commentText, '@codingStandards') !== false) { if (strpos($commentText, '@codingStandardsIgnoreFile') !== false) { // Ignoring the whole file, just a little late. - $this->errors = array(); - $this->warnings = array(); + $this->errors = []; + $this->warnings = []; $this->errorCount = 0; $this->warningCount = 0; $this->fixableCount = 0; @@ -358,8 +358,8 @@ public function process() }//end if } else if (substr($commentTextLower, 0, 16) === 'phpcs:ignorefile') { // Ignoring the whole file, just a little late. - $this->errors = array(); - $this->warnings = array(); + $this->errors = []; + $this->warnings = []; $this->errorCount = 0; $this->warningCount = 0; $this->fixableCount = 0; @@ -626,7 +626,7 @@ public function addError( $error, $stackPtr, $code, - $data=array(), + $data=[], $severity=0, $fixable=false ) { @@ -660,7 +660,7 @@ public function addWarning( $warning, $stackPtr, $code, - $data=array(), + $data=[], $severity=0, $fixable=false ) { @@ -693,7 +693,7 @@ public function addErrorOnLine( $error, $line, $code, - $data=array(), + $data=[], $severity=0 ) { return $this->addMessage(true, $error, $line, 1, $code, $data, $severity, false); @@ -717,7 +717,7 @@ public function addWarningOnLine( $warning, $line, $code, - $data=array(), + $data=[], $severity=0 ) { return $this->addMessage(false, $warning, $line, 1, $code, $data, $severity, false); @@ -743,7 +743,7 @@ public function addFixableError( $error, $stackPtr, $code, - $data=array(), + $data=[], $severity=0 ) { $recorded = $this->addError($error, $stackPtr, $code, $data, $severity, true); @@ -774,7 +774,7 @@ public function addFixableWarning( $warning, $stackPtr, $code, - $data=array(), + $data=[], $severity=0 ) { $recorded = $this->addWarning($warning, $stackPtr, $code, $data, $severity, true); @@ -815,7 +815,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s // An internal message. $listenerCode = Util\Common::getSniffCode($this->activeListener); $sniffCode = $code; - $checkCodes = array($sniffCode); + $checkCodes = [$sniffCode]; } else { if ($parts[0] !== $code) { // The full message code has been passed in. @@ -827,12 +827,12 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s $parts = explode('.', $sniffCode); } - $checkCodes = array( - $sniffCode, - $parts[0].'.'.$parts[1].'.'.$parts[2], - $parts[0].'.'.$parts[1], - $parts[0], - ); + $checkCodes = [ + $sniffCode, + $parts[0].'.'.$parts[1].'.'.$parts[2], + $parts[0].'.'.$parts[1], + $parts[0], + ]; }//end if // Check if this line is ignoring this specific message. @@ -923,10 +923,10 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s foreach ($this->configCache['ignorePatterns'][$checkCode] as $pattern => $type) { // While there is support for a type of each pattern // (absolute or relative) we don't actually support it here. - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); + $replacements = [ + '\\,' => ',', + '*' => '.*', + ]; // We assume a / directory separator, as do the exclude rules // most developers write, so we need a special case for any system @@ -964,20 +964,20 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s } if (isset($messages[$line]) === false) { - $messages[$line] = array(); + $messages[$line] = []; } if (isset($messages[$line][$column]) === false) { - $messages[$line][$column] = array(); + $messages[$line][$column] = []; } - $messages[$line][$column][] = array( - 'message' => $message, - 'source' => $sniffCode, - 'listener' => $this->activeListener, - 'severity' => $severity, - 'fixable' => $fixable, - ); + $messages[$line][$column][] = [ + 'message' => $message, + 'source' => $sniffCode, + 'listener' => $this->activeListener, + 'severity' => $severity, + 'fixable' => $fixable, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1 && $this->fixer->enabled === true @@ -1005,7 +1005,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s public function recordMetric($stackPtr, $metric, $value) { if (isset($this->metrics[$metric]) === false) { - $this->metrics[$metric] = array('values' => array($value => 1)); + $this->metrics[$metric] = ['values' => [$value => 1]]; } else { if (isset($this->metrics[$metric]['values'][$value]) === false) { $this->metrics[$metric]['values'][$value] = 1; @@ -1226,7 +1226,7 @@ public function getMethodParameters($stackPtr) $opener = $this->tokens[$stackPtr]['parenthesis_opener']; $closer = $this->tokens[$stackPtr]['parenthesis_closer']; - $vars = array(); + $vars = []; $currVar = null; $paramStart = ($opener + 1); $defaultStart = null; @@ -1328,7 +1328,7 @@ public function getMethodParameters($stackPtr) continue; } - $vars[$paramCount] = array(); + $vars[$paramCount] = []; $vars[$paramCount]['token'] = $currVar; $vars[$paramCount]['name'] = $this->tokens[$currVar]['content']; $vars[$paramCount]['content'] = trim($this->getTokensAsString($paramStart, ($i - $paramStart))); @@ -1393,24 +1393,24 @@ public function getMethodProperties($stackPtr) } if ($this->tokens[$stackPtr]['code'] === T_FUNCTION) { - $valid = array( - T_PUBLIC => T_PUBLIC, - T_PRIVATE => T_PRIVATE, - T_PROTECTED => T_PROTECTED, - T_STATIC => T_STATIC, - T_FINAL => T_FINAL, - T_ABSTRACT => T_ABSTRACT, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - ); + $valid = [ + T_PUBLIC => T_PUBLIC, + T_PRIVATE => T_PRIVATE, + T_PROTECTED => T_PROTECTED, + T_STATIC => T_STATIC, + T_FINAL => T_FINAL, + T_ABSTRACT => T_ABSTRACT, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + ]; } else { - $valid = array( - T_STATIC => T_STATIC, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - ); + $valid = [ + T_STATIC => T_STATIC, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + ]; } $scope = 'public'; @@ -1449,13 +1449,13 @@ public function getMethodProperties($stackPtr) }//end switch }//end for - return array( - 'scope' => $scope, - 'scope_specified' => $scopeSpecified, - 'is_abstract' => $isAbstract, - 'is_final' => $isFinal, - 'is_static' => $isStatic, - ); + return [ + 'scope' => $scope, + 'scope_specified' => $scopeSpecified, + 'is_abstract' => $isAbstract, + 'is_final' => $isFinal, + 'is_static' => $isStatic, + ]; }//end getMethodProperties() @@ -1506,24 +1506,24 @@ public function getMemberProperties($stackPtr) ) { $error = 'Possible parse error: interfaces may not include member vars'; $this->addWarning($error, $stackPtr, 'Internal.ParseError.InterfaceHasMemberVar'); - return array(); + return []; } } else { throw new TokenizerException('$stackPtr is not a class member var'); } } - $valid = array( - T_PUBLIC => T_PUBLIC, - T_PRIVATE => T_PRIVATE, - T_PROTECTED => T_PROTECTED, - T_STATIC => T_STATIC, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - T_VARIABLE => T_VARIABLE, - T_COMMA => T_COMMA, - ); + $valid = [ + T_PUBLIC => T_PUBLIC, + T_PRIVATE => T_PRIVATE, + T_PROTECTED => T_PROTECTED, + T_STATIC => T_STATIC, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + T_VARIABLE => T_VARIABLE, + T_COMMA => T_COMMA, + ]; $scope = 'public'; $scopeSpecified = false; @@ -1553,11 +1553,11 @@ public function getMemberProperties($stackPtr) } }//end for - return array( - 'scope' => $scope, - 'scope_specified' => $scopeSpecified, - 'is_static' => $isStatic, - ); + return [ + 'scope' => $scope, + 'scope_specified' => $scopeSpecified, + 'is_static' => $isStatic, + ]; }//end getMemberProperties() @@ -1586,13 +1586,13 @@ public function getClassProperties($stackPtr) throw new TokenizerException('$stackPtr must be of type T_CLASS'); } - $valid = array( - T_FINAL => T_FINAL, - T_ABSTRACT => T_ABSTRACT, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - ); + $valid = [ + T_FINAL => T_FINAL, + T_ABSTRACT => T_ABSTRACT, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + ]; $isAbstract = false; $isFinal = false; @@ -1613,10 +1613,10 @@ public function getClassProperties($stackPtr) } }//end for - return array( - 'is_abstract' => $isAbstract, - 'is_final' => $isFinal, - ); + return [ + 'is_abstract' => $isAbstract, + 'is_final' => $isFinal, + ]; }//end getClassProperties() @@ -1689,7 +1689,7 @@ public function isReference($stackPtr) $varToken = $tokenAfter; if ($param['variable_length'] === true) { $varToken = $this->findNext( - (Util\Tokens::$emptyTokens + array(T_ELLIPSIS)), + (Util\Tokens::$emptyTokens + [T_ELLIPSIS]), ($stackPtr + 1), null, true @@ -2003,18 +2003,18 @@ public function findStartOfStatement($start, $ignore=null) */ public function findEndOfStatement($start, $ignore=null) { - $endTokens = array( - T_COLON => true, - T_COMMA => true, - T_DOUBLE_ARROW => true, - T_SEMICOLON => true, - T_CLOSE_PARENTHESIS => true, - T_CLOSE_SQUARE_BRACKET => true, - T_CLOSE_CURLY_BRACKET => true, - T_CLOSE_SHORT_ARRAY => true, - T_OPEN_TAG => true, - T_CLOSE_TAG => true, - ); + $endTokens = [ + T_COLON => true, + T_COMMA => true, + T_DOUBLE_ARROW => true, + T_SEMICOLON => true, + T_CLOSE_PARENTHESIS => true, + T_CLOSE_SQUARE_BRACKET => true, + T_CLOSE_CURLY_BRACKET => true, + T_CLOSE_SHORT_ARRAY => true, + T_OPEN_TAG => true, + T_CLOSE_TAG => true, + ]; if ($ignore !== null) { $ignore = (array) $ignore; @@ -2089,7 +2089,7 @@ public function findEndOfStatement($start, $ignore=null) public function findFirstOnLine($types, $start, $exclude=false, $value=null) { if (is_array($types) === false) { - $types = array($types); + $types = [$types]; } $foundToken = false; @@ -2231,11 +2231,11 @@ public function findExtendedClassName($stackPtr) return false; } - $find = array( - T_NS_SEPARATOR, - T_STRING, - T_WHITESPACE, - ); + $find = [ + T_NS_SEPARATOR, + T_STRING, + T_WHITESPACE, + ]; $end = $this->findNext($find, ($extendsIndex + 1), $classCloserIndex, true); $name = $this->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1)); @@ -2282,12 +2282,12 @@ public function findImplementedInterfaceNames($stackPtr) return false; } - $find = array( - T_NS_SEPARATOR, - T_STRING, - T_WHITESPACE, - T_COMMA, - ); + $find = [ + T_NS_SEPARATOR, + T_STRING, + T_WHITESPACE, + T_COMMA, + ]; $end = $this->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true); $name = $this->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1)); diff --git a/src/Files/FileList.php b/src/Files/FileList.php index c6b7d2bcd2..69526c7a61 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -24,7 +24,7 @@ class FileList implements \Iterator, \Countable * * @var array */ - private $files = array(); + private $files = []; /** * The number of files in the list. @@ -52,7 +52,7 @@ class FileList implements \Iterator, \Countable * * @var array */ - protected $ignorePatterns = array(); + protected $ignorePatterns = []; /** @@ -119,7 +119,7 @@ public function addFile($path, $file=null) $filterClass = $this->getFilterClass(); - $di = new \RecursiveArrayIterator(array($path)); + $di = new \RecursiveArrayIterator([$path]); $filter = new $filterClass($di, $path, $this->config, $this->ruleset); $iterator = new \RecursiveIteratorIterator($filter); diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index 02f0fbc88f..0df71512f5 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -32,7 +32,7 @@ public function __construct($path, Ruleset $ruleset, Config $config) if (is_readable($this->path) === false) { parent::__construct($this->path, $ruleset, $config); $error = 'Error opening file; file no longer exists or you do not have access to read the file'; - $this->addMessage(true, $error, 1, 1, 'Internal.LocalFile', array(), 5, false); + $this->addMessage(true, $error, 1, 1, 'Internal.LocalFile', [], 5, false); $this->ignored = true; return; } @@ -126,16 +126,16 @@ public function process() parent::process(); - $cache = array( - 'hash' => $hash, - 'errors' => $this->errors, - 'warnings' => $this->warnings, - 'metrics' => $this->metrics, - 'errorCount' => $this->errorCount, - 'warningCount' => $this->warningCount, - 'fixableCount' => $this->fixableCount, - 'numTokens' => $this->numTokens, - ); + $cache = [ + 'hash' => $hash, + 'errors' => $this->errors, + 'warnings' => $this->warnings, + 'metrics' => $this->metrics, + 'errorCount' => $this->errorCount, + 'warningCount' => $this->warningCount, + 'fixableCount' => $this->fixableCount, + 'numTokens' => $this->numTokens, + ]; Cache::set($this->path, $cache); @@ -164,8 +164,8 @@ public function process() */ private function replayErrors($errors, $warnings) { - $this->errors = array(); - $this->warnings = array(); + $this->errors = []; + $this->warnings = []; $this->errorCount = 0; $this->warningCount = 0; $this->fixableCount = 0; @@ -180,7 +180,7 @@ private function replayErrors($errors, $warnings) $line, $column, $error['source'], - array(), + [], $error['severity'], $error['fixable'] ); @@ -198,7 +198,7 @@ private function replayErrors($errors, $warnings) $line, $column, $error['source'], - array(), + [], $error['severity'], $error['fixable'] ); diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index 79900d7990..c053c06b58 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -147,7 +147,7 @@ protected function shouldProcessFile($path) // Checking multi-part file extensions, so need to create a // complete extension list and make sure one is allowed. - $extensions = array(); + $extensions = []; array_shift($fileParts); foreach ($fileParts as $part) { $extensions[implode('.', $fileParts)] = 1; @@ -174,8 +174,8 @@ protected function shouldProcessFile($path) protected function shouldIgnorePath($path) { if ($this->ignoreFilePatterns === null) { - $this->ignoreDirPatterns = array(); - $this->ignoreFilePatterns = array(); + $this->ignoreDirPatterns = []; + $this->ignoreFilePatterns = []; $ignorePatterns = array_merge($this->config->ignored, $this->ruleset->getIgnorePatterns()); foreach ($ignorePatterns as $pattern => $type) { @@ -213,10 +213,10 @@ protected function shouldIgnorePath($path) $type = 'absolute'; } - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); + $replacements = [ + '\\,' => ',', + '*' => '.*', + ]; // We assume a / directory separator, as do the exclude rules // most developers write, so we need a special case for any system diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index 86512e2236..51af7095f0 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -22,7 +22,7 @@ class GitModified extends ExactMatch */ protected function getBlacklist() { - return array(); + return []; }//end getBlacklist() @@ -34,10 +34,10 @@ protected function getBlacklist() */ protected function getWhitelist() { - $modified = array(); + $modified = []; $cmd = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir); - $output = array(); + $output = []; exec($cmd, $output); $basedir = $this->basedir; diff --git a/src/Fixer.php b/src/Fixer.php index e16dc5f4c5..af87d5cb54 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -52,7 +52,7 @@ class Fixer * * @var array */ - private $tokens = array(); + private $tokens = []; /** * A list of tokens that have already been fixed. @@ -62,7 +62,7 @@ class Fixer * * @var int[] */ - private $fixedTokens = array(); + private $fixedTokens = []; /** * The last value of each fixed token. @@ -72,7 +72,7 @@ class Fixer * * @var array */ - private $oldTokenValues = array(); + private $oldTokenValues = []; /** * A list of tokens that have been fixed during a changeset. @@ -82,7 +82,7 @@ class Fixer * * @var array */ - private $changeset = array(); + private $changeset = []; /** * Is there an open changeset. @@ -117,10 +117,10 @@ public function startFile(File $phpcsFile) { $this->currentFile = $phpcsFile; $this->numFixes = 0; - $this->fixedTokens = array(); + $this->fixedTokens = []; $tokens = $phpcsFile->getTokens(); - $this->tokens = array(); + $this->tokens = []; foreach ($tokens as $index => $token) { if (isset($token['orig_content']) === true) { $this->tokens[$index] = $token['orig_content']; @@ -270,7 +270,7 @@ public function generateDiff($filePath=null, $colors=true) $diffLines = explode("\n", $diff); } - $diff = array(); + $diff = []; foreach ($diffLines as $line) { if (isset($line[0]) === true) { switch ($line[0]) { @@ -365,7 +365,7 @@ public function beginChangeset() ob_start(); } - $this->changeset = array(); + $this->changeset = []; $this->inChangeset = true; }//end beginChangeset() @@ -385,7 +385,7 @@ public function endChangeset() $this->inChangeset = false; $success = true; - $applied = array(); + $applied = []; foreach ($this->changeset as $stackPtr => $content) { $success = $this->replaceToken($stackPtr, $content); if ($success === false) { @@ -413,7 +413,7 @@ public function endChangeset() ob_start(); } - $this->changeset = array(); + $this->changeset = []; }//end endChangeset() @@ -447,7 +447,7 @@ public function rollbackChangeset() ob_start(); } - $this->changeset = array(); + $this->changeset = []; }//end if }//end rollbackChangeset() @@ -519,11 +519,11 @@ public function replaceToken($stackPtr, $content) } if (isset($this->oldTokenValues[$stackPtr]) === false) { - $this->oldTokenValues[$stackPtr] = array( - 'curr' => $content, - 'prev' => $this->tokens[$stackPtr], - 'loop' => $this->loops, - ); + $this->oldTokenValues[$stackPtr] = [ + 'curr' => $content, + 'prev' => $this->tokens[$stackPtr], + 'loop' => $this->loops, + ]; } else { if ($this->oldTokenValues[$stackPtr]['prev'] === $content && $this->oldTokenValues[$stackPtr]['loop'] === ($this->loops - 1) diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index ee5457a7a1..816b97d291 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -31,7 +31,7 @@ abstract class Generator * * @var string[] */ - public $docFiles = array(); + public $docFiles = []; /** @@ -45,7 +45,7 @@ public function __construct(Ruleset $ruleset) { $this->ruleset = $ruleset; - $standardFiles = array(); + $standardFiles = []; foreach ($ruleset->sniffs as $className => $sniffClass) { $file = Autoload::getLoadedFileName($className); $docFile = str_replace( diff --git a/src/Generators/Text.php b/src/Generators/Text.php index 2ab33f2d87..ca31d9f10e 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -75,7 +75,7 @@ protected function printTextBlock(\DOMNode $node) $text = str_replace('', '*', $text); $text = str_replace('', '*', $text); - $lines = array(); + $lines = []; $tempLine = ''; $words = explode(' ', $text); @@ -121,7 +121,7 @@ protected function printCodeComparisonBlock(\DOMNode $node) $first = trim($codeBlocks->item(0)->nodeValue); $firstTitle = $codeBlocks->item(0)->getAttribute('title'); - $firstTitleLines = array(); + $firstTitleLines = []; $tempTitle = ''; $words = explode(' ', $firstTitle); @@ -156,7 +156,7 @@ protected function printCodeComparisonBlock(\DOMNode $node) $second = trim($codeBlocks->item(1)->nodeValue); $secondTitle = $codeBlocks->item(1)->getAttribute('title'); - $secondTitleLines = array(); + $secondTitleLines = []; $tempTitle = ''; $words = explode(' ', $secondTitle); diff --git a/src/Reporter.php b/src/Reporter.php index 9b2a435f9c..b9a64c2617 100644 --- a/src/Reporter.php +++ b/src/Reporter.php @@ -72,14 +72,14 @@ class Reporter * * @var array */ - private $reports = array(); + private $reports = []; /** * A cache of opened temporary files. * * @var array */ - private $tmpFiles = array(); + private $tmpFiles = []; /** @@ -123,10 +123,10 @@ public function __construct(Config $config) throw new RuntimeException('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer\Report" interface.'); } - $this->reports[$type] = array( - 'output' => $output, - 'class' => $reportClass, - ); + $this->reports[$type] = [ + 'output' => $output, + 'class' => $reportClass, + ]; if ($output === null) { // Using a temp file. @@ -310,13 +310,13 @@ public function cacheFileReport(File $phpcsFile) */ public function prepareFileReport(File $phpcsFile) { - $report = array( - 'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath), - 'errors' => $phpcsFile->getErrorCount(), - 'warnings' => $phpcsFile->getWarningCount(), - 'fixable' => $phpcsFile->getFixableCount(), - 'messages' => array(), - ); + $report = [ + 'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath), + 'errors' => $phpcsFile->getErrorCount(), + 'warnings' => $phpcsFile->getWarningCount(), + 'fixable' => $phpcsFile->getFixableCount(), + 'messages' => [], + ]; if ($report['errors'] === 0 && $report['warnings'] === 0) { // Prefect score! @@ -326,32 +326,32 @@ public function prepareFileReport(File $phpcsFile) if ($this->config->recordErrors === false) { $message = 'Errors are not being recorded but this report requires error messages. '; $message .= 'This report will not show the correct information.'; - $report['messages'][1][1] = array( - array( - 'message' => $message, - 'source' => 'Internal.RecordErrors', - 'severity' => 5, - 'fixable' => false, - 'type' => 'ERROR', - ), - ); + $report['messages'][1][1] = [ + [ + 'message' => $message, + 'source' => 'Internal.RecordErrors', + 'severity' => 5, + 'fixable' => false, + 'type' => 'ERROR', + ], + ]; return $report; } - $errors = array(); + $errors = []; // Merge errors and warnings. foreach ($phpcsFile->getErrors() as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { - $newErrors = array(); + $newErrors = []; foreach ($colErrors as $data) { - $newErrors[] = array( - 'message' => $data['message'], - 'source' => $data['source'], - 'severity' => $data['severity'], - 'fixable' => $data['fixable'], - 'type' => 'ERROR', - ); + $newErrors[] = [ + 'message' => $data['message'], + 'source' => $data['source'], + 'severity' => $data['severity'], + 'fixable' => $data['fixable'], + 'type' => 'ERROR', + ]; } $errors[$line][$column] = $newErrors; @@ -362,19 +362,19 @@ public function prepareFileReport(File $phpcsFile) foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) { foreach ($lineWarnings as $column => $colWarnings) { - $newWarnings = array(); + $newWarnings = []; foreach ($colWarnings as $data) { - $newWarnings[] = array( - 'message' => $data['message'], - 'source' => $data['source'], - 'severity' => $data['severity'], - 'fixable' => $data['fixable'], - 'type' => 'WARNING', - ); + $newWarnings[] = [ + 'message' => $data['message'], + 'source' => $data['source'], + 'severity' => $data['severity'], + 'fixable' => $data['fixable'], + 'type' => 'WARNING', + ]; } if (isset($errors[$line]) === false) { - $errors[$line] = array(); + $errors[$line] = []; } if (isset($errors[$line][$column]) === true) { diff --git a/src/Reports/Cbf.php b/src/Reports/Cbf.php index f9a22631d5..4d20ba10e5 100644 --- a/src/Reports/Cbf.php +++ b/src/Reports/Cbf.php @@ -148,7 +148,7 @@ public function generate( return; } - $reportFiles = array(); + $reportFiles = []; $maxLength = 0; $totalFixed = 0; $failures = 0; @@ -156,13 +156,13 @@ public function generate( foreach ($lines as $line) { $parts = explode('>>', $line); $fileLen = strlen($parts[0]); - $reportFiles[$parts[0]] = array( - 'errors' => $parts[1], - 'warnings' => $parts[2], - 'fixable' => $parts[3], - 'fixed' => $parts[4], - 'strlen' => $fileLen, - ); + $reportFiles[$parts[0]] = [ + 'errors' => $parts[1], + 'warnings' => $parts[2], + 'fixable' => $parts[3], + 'fixed' => $parts[4], + 'strlen' => $fileLen, + ]; $maxLength = max($maxLength, $fileLen); diff --git a/src/Reports/Code.php b/src/Reports/Code.php index 0aaa768292..c54c1e1a4e 100644 --- a/src/Reports/Code.php +++ b/src/Reports/Code.php @@ -74,7 +74,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, }//end if // Create an array that maps lines to the first token on the line. - $lineTokens = array(); + $lineTokens = []; $lastLine = 0; $stackPtr = 0; foreach ($tokens as $stackPtr => $token) { @@ -84,10 +84,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, } $lastLine++; - $lineTokens[$lastLine] = array( - 'start' => $stackPtr, - 'end' => null, - ); + $lineTokens[$lastLine] = [ + 'start' => $stackPtr, + 'end' => null, + ]; } } @@ -235,7 +235,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, $tokenContent = $token['content']; } - $tokenContent = Util\Common::prepareForOutput($tokenContent, array("\r", "\n", "\t")); + $tokenContent = Util\Common::prepareForOutput($tokenContent, ["\r", "\n", "\t"]); $tokenContent = str_replace("\000", ' ', $tokenContent); $underline = false; diff --git a/src/Reports/Gitblame.php b/src/Reports/Gitblame.php index 33271f7e07..e2b76af073 100644 --- a/src/Reports/Gitblame.php +++ b/src/Reports/Gitblame.php @@ -32,7 +32,7 @@ class Gitblame extends VersionControl */ protected function getAuthor($line) { - $blameParts = array(); + $blameParts = []; $line = preg_replace('|\s+|', ' ', $line); preg_match( '|\(.+[0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]+\)|', diff --git a/src/Reports/Hgblame.php b/src/Reports/Hgblame.php index 5bc255d3a4..223e498587 100644 --- a/src/Reports/Hgblame.php +++ b/src/Reports/Hgblame.php @@ -32,7 +32,7 @@ class Hgblame extends VersionControl */ protected function getAuthor($line) { - $blameParts = array(); + $blameParts = []; $line = preg_replace('|\s+|', ' ', $line); preg_match( diff --git a/src/Reports/Info.php b/src/Reports/Info.php index f932362ff8..b13d9e2bb3 100644 --- a/src/Reports/Info.php +++ b/src/Reports/Info.php @@ -78,14 +78,14 @@ public function generate( return; } - $metrics = array(); + $metrics = []; foreach ($lines as $line) { $parts = explode('>>', $line); $metric = $parts[0]; $value = $parts[1]; $count = $parts[2]; if (isset($metrics[$metric]) === false) { - $metrics[$metric] = array(); + $metrics[$metric] = []; } if (isset($metrics[$metric][$value]) === false) { diff --git a/src/Reports/Junit.php b/src/Reports/Junit.php index d69cfce1d2..3461d89f3d 100644 --- a/src/Reports/Junit.php +++ b/src/Reports/Junit.php @@ -110,7 +110,7 @@ public function generate( ) { // Figure out the total number of tests. $tests = 0; - $matches = array(); + $matches = []; preg_match_all('/tests="([0-9]+)"/', $cachedData, $matches); if (isset($matches[1]) === true) { foreach ($matches[1] as $match) { diff --git a/src/Reports/Source.php b/src/Reports/Source.php index d50464f0e8..7827d19411 100644 --- a/src/Reports/Source.php +++ b/src/Reports/Source.php @@ -37,17 +37,17 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, return false; } - $sources = array(); + $sources = []; foreach ($report['messages'] as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { foreach ($colErrors as $error) { $src = $error['source']; if (isset($sources[$src]) === false) { - $sources[$src] = array( - 'fixable' => (int) $error['fixable'], - 'count' => 1, - ); + $sources[$src] = [ + 'fixable' => (int) $error['fixable'], + 'count' => 1, + ]; } else { $sources[$src]['count']++; } @@ -98,7 +98,7 @@ public function generate( return; } - $sources = array(); + $sources = []; $maxLength = 0; foreach ($lines as $line) { @@ -133,21 +133,21 @@ public function generate( $maxLength = max($maxLength, strlen($sniff)); - $sources[$source] = array( - 'count' => $count, - 'fixable' => $fixable, - 'parts' => $parts, - ); + $sources[$source] = [ + 'count' => $count, + 'fixable' => $fixable, + 'parts' => $parts, + ]; } else { $sources[$source]['count'] += $count; }//end if $fileLen = strlen($parts[0]); - $reportFiles[$parts[0]] = array( - 'errors' => $parts[1], - 'warnings' => $parts[2], - 'strlen' => $fileLen, - ); + $reportFiles[$parts[0]] = [ + 'errors' => $parts[1], + 'warnings' => $parts[2], + 'strlen' => $fileLen, + ]; }//end foreach if ($showSources === true) { diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php index 13589f427a..08b69c137a 100644 --- a/src/Reports/Summary.php +++ b/src/Reports/Summary.php @@ -80,17 +80,17 @@ public function generate( return; } - $reportFiles = array(); + $reportFiles = []; $maxLength = 0; foreach ($lines as $line) { $parts = explode('>>', $line); $fileLen = strlen($parts[0]); - $reportFiles[$parts[0]] = array( - 'errors' => $parts[1], - 'warnings' => $parts[2], - 'strlen' => $fileLen, - ); + $reportFiles[$parts[0]] = [ + 'errors' => $parts[1], + 'warnings' => $parts[2], + 'strlen' => $fileLen, + ]; $maxLength = max($maxLength, $fileLen); } diff --git a/src/Reports/Svnblame.php b/src/Reports/Svnblame.php index 3c885a338f..e4f07dd262 100644 --- a/src/Reports/Svnblame.php +++ b/src/Reports/Svnblame.php @@ -31,7 +31,7 @@ class Svnblame extends VersionControl */ protected function getAuthor($line) { - $blameParts = array(); + $blameParts = []; preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts); if (isset($blameParts[2]) === false) { diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php index 612f4d5dbb..0f414567dc 100644 --- a/src/Reports/VersionControl.php +++ b/src/Reports/VersionControl.php @@ -42,9 +42,9 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, { $blames = $this->getBlameContent($report['filename']); - $authorCache = array(); - $praiseCache = array(); - $sourceCache = array(); + $authorCache = []; + $praiseCache = []; + $sourceCache = []; foreach ($report['messages'] as $line => $lineErrors) { $author = 'Unknown'; @@ -57,10 +57,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, if (isset($authorCache[$author]) === false) { $authorCache[$author] = 0; - $praiseCache[$author] = array( - 'good' => 0, - 'bad' => 0, - ); + $praiseCache[$author] = [ + 'good' => 0, + 'bad' => 0, + ]; } $praiseCache[$author]['bad']++; @@ -72,10 +72,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, if ($showSources === true) { $source = $error['source']; if (isset($sourceCache[$author][$source]) === false) { - $sourceCache[$author][$source] = array( - 'count' => 1, - 'fixable' => $error['fixable'], - ); + $sourceCache[$author][$source] = [ + 'count' => 1, + 'fixable' => $error['fixable'], + ]; } else { $sourceCache[$author][$source]['count']++; } @@ -101,10 +101,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, } $authorCache[$author] = 0; - $praiseCache[$author] = array( - 'good' => 0, - 'bad' => 0, - ); + $praiseCache[$author] = [ + 'good' => 0, + 'bad' => 0, + ]; } $praiseCache[$author]['good']++; @@ -171,9 +171,9 @@ public function generate( return; } - $authorCache = array(); - $praiseCache = array(); - $sourceCache = array(); + $authorCache = []; + $praiseCache = []; + $sourceCache = []; foreach ($lines as $line) { $parts = explode('>>', $line); @@ -187,10 +187,10 @@ public function generate( break; case 'PRAISE': if (isset($praiseCache[$parts[1]]) === false) { - $praiseCache[$parts[1]] = array( - 'good' => $parts[2], - 'bad' => $parts[3], - ); + $praiseCache[$parts[1]] = [ + 'good' => $parts[2], + 'bad' => $parts[3], + ]; } else { $praiseCache[$parts[1]]['good'] += $parts[2]; $praiseCache[$parts[1]]['bad'] += $parts[3]; @@ -198,14 +198,14 @@ public function generate( break; case 'SOURCE': if (isset($praiseCache[$parts[1]]) === false) { - $praiseCache[$parts[1]] = array(); + $praiseCache[$parts[1]] = []; } if (isset($sourceCache[$parts[1]][$parts[2]]) === false) { - $sourceCache[$parts[1]][$parts[2]] = array( - 'count' => $parts[3], - 'fixable' => (bool) $parts[4], - ); + $sourceCache[$parts[1]][$parts[2]] = [ + 'count' => $parts[3], + 'fixable' => (bool) $parts[4], + ]; } else { $sourceCache[$parts[1]][$parts[2]]['count'] += $parts[3]; } diff --git a/src/Ruleset.php b/src/Ruleset.php index 99aaaf1f93..b0b987518a 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -37,7 +37,7 @@ class Ruleset * * @var string[] */ - public $paths = array(); + public $paths = []; /** * A list of regular expressions used to ignore specific sniffs for files and folders. @@ -48,7 +48,7 @@ class Ruleset * * @var array */ - public $ignorePatterns = array(); + public $ignorePatterns = []; /** * A list of regular expressions used to include specific sniffs for files and folders. @@ -59,7 +59,7 @@ class Ruleset * * @var array> */ - public $includePatterns = array(); + public $includePatterns = []; /** * An array of sniff objects that are being used to check files. @@ -69,7 +69,7 @@ class Ruleset * * @var array */ - public $sniffs = array(); + public $sniffs = []; /** * A mapping of sniff codes to fully qualified class names. @@ -79,7 +79,7 @@ class Ruleset * * @var array */ - public $sniffCodes = array(); + public $sniffCodes = []; /** * An array of token types and the sniffs that are listening for them. @@ -89,7 +89,7 @@ class Ruleset * * @var array */ - public $tokenListeners = array(); + public $tokenListeners = []; /** * An array of rules from the ruleset.xml file. @@ -99,14 +99,14 @@ class Ruleset * * @var array */ - public $ruleset = array(); + public $ruleset = []; /** * The directories that the processed rulesets are in. * * @var string[] */ - protected $rulesetDirs = array(); + protected $rulesetDirs = []; /** * The config data for the run. @@ -126,17 +126,17 @@ class Ruleset public function __construct(Config $config) { // Ignore sniff restrictions if caching is on. - $restrictions = array(); - $exclusions = array(); + $restrictions = []; + $exclusions = []; if ($config->cache === false) { $restrictions = $config->sniffs; $exclusions = $config->exclude; } $this->config = $config; - $sniffs = array(); + $sniffs = []; - $standardPaths = array(); + $standardPaths = []; foreach ($config->standards as $standard) { $installed = Util\Standards::getInstalledStandardPath($standard); if ($installed === null) { @@ -200,14 +200,14 @@ public function __construct(Config $config) $sniffs = array_merge($sniffs, $this->processRuleset($standard)); }//end foreach - $sniffRestrictions = array(); + $sniffRestrictions = []; foreach ($restrictions as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; $sniffRestrictions[$sniffName] = true; } - $sniffExclusions = array(); + $sniffExclusions = []; foreach ($exclusions as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; @@ -320,9 +320,9 @@ public function processRuleset($rulesetPath, $depth=0) throw new RuntimeException("Ruleset $rulesetPath is not valid"); } - $ownSniffs = array(); - $includedSniffs = array(); - $excludedSniffs = array(); + $ownSniffs = []; + $includedSniffs = []; + $excludedSniffs = []; $rulesetDir = dirname($rulesetPath); $this->rulesetDirs[] = $rulesetDir; @@ -463,7 +463,7 @@ public function processRuleset($rulesetPath, $depth=0) }//end foreach // Process custom command line arguments. - $cliArgs = array(); + $cliArgs = []; foreach ($ruleset->{'arg'} as $arg) { if ($this->shouldProcessElement($arg) === false) { continue; @@ -572,7 +572,7 @@ public function processRuleset($rulesetPath, $depth=0) // Merge our own sniff list with our externally included // sniff list, but filter out any excluded sniffs. - $files = array(); + $files = []; foreach ($includedSniffs as $sniff) { if (in_array($sniff, $excludedSniffs) === true) { continue; @@ -597,7 +597,7 @@ public function processRuleset($rulesetPath, $depth=0) */ private function expandSniffDirectory($directory, $depth=0) { - $sniffs = array(); + $sniffs = []; $rdi = new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS); $di = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD); @@ -668,7 +668,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0) echo "\t\t* ignoring internal sniff code *".PHP_EOL; } - return array(); + return []; } // As sniffs can't begin with a full stop, assume references in @@ -703,7 +703,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0) if (substr($ref, -9) === 'Sniff.php') { // A single external sniff. $this->rulesetDirs[] = dirname(dirname(dirname($ref))); - return array($ref); + return [$ref]; } } else { // See if this is a whole standard being referenced. @@ -814,7 +814,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0) if (substr($ref, -9) === 'Sniff.php') { // A single sniff. - return array($ref); + return [$ref]; } else { // Assume an external ruleset.xml file. if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -843,7 +843,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0) private function processRule($rule, $newSniffs, $depth=0) { $ref = (string) $rule['ref']; - $todo = array($ref); + $todo = [$ref]; $parts = explode('.', $ref); if (count($parts) <= 2) { @@ -864,7 +864,7 @@ private function processRule($rule, $newSniffs, $depth=0) && $this->shouldProcessElement($rule->severity) === true ) { if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array(); + $this->ruleset[$code] = []; } $this->ruleset[$code]['severity'] = (int) $rule->severity; @@ -884,7 +884,7 @@ private function processRule($rule, $newSniffs, $depth=0) && $this->shouldProcessElement($rule->type) === true ) { if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array(); + $this->ruleset[$code] = []; } $type = strtolower((string) $rule->type); @@ -909,7 +909,7 @@ private function processRule($rule, $newSniffs, $depth=0) && $this->shouldProcessElement($rule->message) === true ) { if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array(); + $this->ruleset[$code] = []; } $this->ruleset[$code]['message'] = (string) $rule->message; @@ -934,11 +934,11 @@ private function processRule($rule, $newSniffs, $depth=0) } if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array( - 'properties' => array(), - ); + $this->ruleset[$code] = [ + 'properties' => [], + ]; } else if (isset($this->ruleset[$code]['properties']) === false) { - $this->ruleset[$code]['properties'] = array(); + $this->ruleset[$code]['properties'] = []; } $name = (string) $prop['name']; @@ -946,7 +946,7 @@ private function processRule($rule, $newSniffs, $depth=0) && (string) $prop['type'] === 'array' ) { $value = (string) $prop['value']; - $values = array(); + $values = []; foreach (explode(',', $value) as $val) { $v = ''; @@ -990,7 +990,7 @@ private function processRule($rule, $newSniffs, $depth=0) } if (isset($this->ignorePatterns[$code]) === false) { - $this->ignorePatterns[$code] = array(); + $this->ignorePatterns[$code] = []; } if (isset($pattern['type']) === false) { @@ -1016,7 +1016,7 @@ private function processRule($rule, $newSniffs, $depth=0) } if (isset($this->includePatterns[$code]) === false) { - $this->includePatterns[$code] = array(); + $this->includePatterns[$code] = []; } if (isset($pattern['type']) === false) { @@ -1087,7 +1087,7 @@ private function shouldProcessElement($element) */ public function registerSniffs($files, $restrictions, $exclusions) { - $listeners = array(); + $listeners = []; foreach ($files as $file) { // Work out where the position of /StandardName/Sniffs/... is @@ -1148,7 +1148,7 @@ public function registerSniffs($files, $restrictions, $exclusions) public function populateTokenListeners() { // Construct a list of listeners indexed by token being listened for. - $this->tokenListeners = array(); + $this->tokenListeners = []; foreach ($this->sniffs as $sniffClass => $sniffObject) { $this->sniffs[$sniffClass] = null; @@ -1164,14 +1164,14 @@ public function populateTokenListeners() } } - $tokenizers = array(); + $tokenizers = []; $vars = get_class_vars($sniffClass); if (isset($vars['supportedTokenizers']) === true) { foreach ($vars['supportedTokenizers'] as $tokenizer) { $tokenizers[$tokenizer] = $tokenizer; } } else { - $tokenizers = array('PHP' => 'PHP'); + $tokenizers = ['PHP' => 'PHP']; } $tokens = $this->sniffs[$sniffClass]->register(); @@ -1180,41 +1180,41 @@ public function populateTokenListeners() throw new RuntimeException($msg); } - $ignorePatterns = array(); + $ignorePatterns = []; $patterns = $this->getIgnorePatterns($sniffCode); foreach ($patterns as $pattern => $type) { - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); + $replacements = [ + '\\,' => ',', + '*' => '.*', + ]; $ignorePatterns[] = strtr($pattern, $replacements); } - $includePatterns = array(); + $includePatterns = []; $patterns = $this->getIncludePatterns($sniffCode); foreach ($patterns as $pattern => $type) { - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); + $replacements = [ + '\\,' => ',', + '*' => '.*', + ]; $includePatterns[] = strtr($pattern, $replacements); } foreach ($tokens as $token) { if (isset($this->tokenListeners[$token]) === false) { - $this->tokenListeners[$token] = array(); + $this->tokenListeners[$token] = []; } if (isset($this->tokenListeners[$token][$sniffClass]) === false) { - $this->tokenListeners[$token][$sniffClass] = array( - 'class' => $sniffClass, - 'source' => $sniffCode, - 'tokenizers' => $tokenizers, - 'ignore' => $ignorePatterns, - 'include' => $includePatterns, - ); + $this->tokenListeners[$token][$sniffClass] = [ + 'class' => $sniffClass, + 'source' => $sniffCode, + 'tokenizers' => $tokenizers, + 'ignore' => $ignorePatterns, + 'include' => $includePatterns, + ]; } } }//end foreach @@ -1276,7 +1276,7 @@ public function getIgnorePatterns($listener=null) return $this->ignorePatterns[$listener]; } - return array(); + return []; }//end getIgnorePatterns() @@ -1302,7 +1302,7 @@ public function getIncludePatterns($listener=null) return $this->includePatterns[$listener]; } - return array(); + return []; }//end getIncludePatterns() diff --git a/src/Runner.php b/src/Runner.php index d853c776fd..7ca7ef67fe 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -74,7 +74,7 @@ public function runPHPCS() if ($this->config->explain === true) { $standards = $this->config->standards; foreach ($standards as $standard) { - $this->config->standards = array($standard); + $this->config->standards = [$standard]; $ruleset = new Ruleset($this->config); $ruleset->explain(); } @@ -86,7 +86,7 @@ public function runPHPCS() if ($this->config->generator !== null) { $standards = $this->config->standards; foreach ($standards as $standard) { - $this->config->standards = array($standard); + $this->config->standards = [$standard]; $ruleset = new Ruleset($this->config); $class = 'PHP_CodeSniffer\Generators\\'.$this->config->generator; $generator = new $class($ruleset); @@ -100,7 +100,7 @@ public function runPHPCS() // so we hard-code the full report here and when outputting. // We also ensure parallel processing is off because we need to do one file at a time. if ($this->config->interactive === true) { - $this->config->reports = array('full' => null); + $this->config->reports = ['full' => null]; $this->config->parallel = 1; $this->config->showProgress = false; } @@ -183,7 +183,7 @@ public function runPHPCBF() $this->config->showSources = false; $this->config->recordErrors = false; $this->config->reportFile = null; - $this->config->reports = array('cbf' => null); + $this->config->reports = ['cbf' => null]; // If a standard tries to set command line arguments itself, some // may be blocked because PHPCBF is running, so stop the script @@ -361,7 +361,7 @@ private function run() }//end if // Turn all sniff errors into exceptions. - set_error_handler(array($this, 'handleErrors')); + set_error_handler([$this, 'handleErrors']); // If verbosity is too high, turn off parallelism so the // debug output is clean. @@ -401,7 +401,7 @@ private function run() } } else { // Batching and forking. - $childProcs = array(); + $childProcs = []; $numPerBatch = ceil($numFiles / $this->config->parallel); for ($batch = 0; $batch < $this->config->parallel; $batch++) { @@ -420,10 +420,10 @@ private function run() if ($pid === -1) { throw new RuntimeException('Failed to create child process'); } else if ($pid !== 0) { - $childProcs[] = array( - 'pid' => $pid, - 'out' => $childOutFilename, - ); + $childProcs[] = [ + 'pid' => $pid, + 'out' => $childOutFilename, + ]; } else { // Move forward to the start of the batch. $todo->rewind(); @@ -440,7 +440,7 @@ private function run() $this->reporter->totalFixed = 0; // Process the files. - $pathsProcessed = array(); + $pathsProcessed = []; ob_start(); for ($i = $startAt; $i < $endAt; $i++) { $path = $todo->key(); @@ -470,13 +470,13 @@ private function run() // Write information about the run to the filesystem // so it can be picked up by the main process. - $childOutput = array( - 'totalFiles' => $this->reporter->totalFiles, - 'totalErrors' => $this->reporter->totalErrors, - 'totalWarnings' => $this->reporter->totalWarnings, - 'totalFixable' => $this->reporter->totalFixable, - 'totalFixed' => $this->reporter->totalFixed, - ); + $childOutput = [ + 'totalFiles' => $this->reporter->totalFiles, + 'totalErrors' => $this->reporter->totalErrors, + 'totalWarnings' => $this->reporter->totalWarnings, + 'totalFixable' => $this->reporter->totalFixable, + 'totalFixed' => $this->reporter->totalFixed, + ]; $output = '<'.'?php'."\n".' $childOutput = '; $output .= var_export($childOutput, true); @@ -484,7 +484,7 @@ private function run() $output .= var_export($debugOutput, true); if ($this->config->cache === true) { - $childCache = array(); + $childCache = []; foreach ($pathsProcessed as $path) { $childCache[$path] = Cache::get($path); } diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php index 4af4c381af..b9402b4c03 100644 --- a/src/Sniffs/AbstractArraySniff.php +++ b/src/Sniffs/AbstractArraySniff.php @@ -24,10 +24,10 @@ abstract class AbstractArraySniff implements Sniff */ final public function register() { - return array( - T_ARRAY, - T_OPEN_SHORT_ARRAY, - ); + return [ + T_ARRAY, + T_OPEN_SHORT_ARRAY, + ]; }//end register() @@ -78,7 +78,7 @@ final public function process(File $phpcsFile, $stackPtr) } $keyUsed = false; - $indices = array(); + $indices = []; for ($checkToken = ($stackPtr + 1); $checkToken <= $lastArrayToken; $checkToken++) { // Skip bracketed statements, like function calls. @@ -96,7 +96,7 @@ final public function process(File $phpcsFile, $stackPtr) ) { // Let subsequent calls of this test handle nested arrays. if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) { - $indices[] = array('value_start' => $checkToken); + $indices[] = ['value_start' => $checkToken]; $lastToken = $checkToken; } @@ -158,7 +158,7 @@ final public function process(File $phpcsFile, $stackPtr) true ); - $indices[] = array('value_start' => $valueContent); + $indices[] = ['value_start' => $valueContent]; } $lastToken = $checkToken; @@ -181,12 +181,12 @@ final public function process(File $phpcsFile, $stackPtr) true ); - $indices[] = array( - 'index_start' => $indexStart, - 'index_end' => $indexEnd, - 'arrow' => $checkToken, - 'value_start' => $nextContent, - ); + $indices[] = [ + 'index_start' => $indexStart, + 'index_end' => $indexEnd, + 'arrow' => $checkToken, + 'value_start' => $nextContent, + ]; $lastToken = $checkToken; }//end if diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 80d909fa11..a5ce4576bc 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -37,7 +37,7 @@ abstract class AbstractPatternSniff implements Sniff * * @var array */ - private $parsedPatterns = array(); + private $parsedPatterns = []; /** * Tokens that this sniff wishes to process outside of the patterns. @@ -46,14 +46,14 @@ abstract class AbstractPatternSniff implements Sniff * @see registerSupplementary() * @see processSupplementary() */ - private $supplementaryTokens = array(); + private $supplementaryTokens = []; /** * Positions in the stack where errors have occurred. * * @var array */ - private $errorPos = array(); + private $errorPos = []; /** @@ -84,7 +84,7 @@ public function __construct($ignoreComments=null) */ final public function register() { - $listenTypes = array(); + $listenTypes = []; $patterns = $this->getPatterns(); foreach ($patterns as $pattern) { @@ -96,14 +96,14 @@ final public function register() $tokenType = $parsedPattern[$pos]['token']; $listenTypes[] = $tokenType; - $patternArray = array( - 'listen_pos' => $pos, - 'pattern' => $parsedPattern, - 'pattern_code' => $pattern, - ); + $patternArray = [ + 'listen_pos' => $pos, + 'pattern' => $parsedPattern, + 'pattern_code' => $pattern, + ]; if (isset($this->parsedPatterns[$tokenType]) === false) { - $this->parsedPatterns[$tokenType] = array(); + $this->parsedPatterns[$tokenType] = []; } $this->parsedPatterns[$tokenType][] = $patternArray; @@ -132,7 +132,7 @@ final public function register() */ private function getPatternTokenTypes($pattern) { - $tokenTypes = array(); + $tokenTypes = []; foreach ($pattern as $pos => $patternInfo) { if ($patternInfo['type'] === 'token') { if (isset($tokenTypes[$patternInfo['token']]) === false) { @@ -190,7 +190,7 @@ final public function process(File $phpcsFile, $stackPtr) $file = $phpcsFile->getFilename(); if ($this->currFile !== $file) { // We have changed files, so clean up. - $this->errorPos = array(); + $this->errorPos = []; $this->currFile = $file; } @@ -208,7 +208,7 @@ final public function process(File $phpcsFile, $stackPtr) return; } - $allErrors = array(); + $allErrors = []; // Loop over each pattern that is listening to the current token type // that we are processing. @@ -258,10 +258,10 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $pattern = $patternInfo['pattern']; $patternCode = $patternInfo['pattern_code']; - $errors = array(); + $errors = []; $found = ''; - $ignoreTokens = array(T_WHITESPACE); + $ignoreTokens = [T_WHITESPACE]; if ($this->ignoreComments === true) { $ignoreTokens = array_merge($ignoreTokens, Tokens::$commentTokens); @@ -737,7 +737,7 @@ abstract protected function getPatterns(); */ protected function registerSupplementary() { - return array(); + return []; }//end registerSupplementary() @@ -770,7 +770,7 @@ protected function processSupplementary(File $phpcsFile, $stackPtr) */ private function parse($pattern) { - $patterns = array(); + $patterns = []; $length = strlen($pattern); $lastToken = 0; $firstToken = 0; @@ -793,12 +793,12 @@ private function parse($pattern) $firstToken++; } } else if (substr($pattern, $i, 3) === 'abc') { - $specialPattern = array('type' => 'string'); + $specialPattern = ['type' => 'string']; $lastToken = ($i - $firstToken); $firstToken = ($i + 3); $i = ($i + 2); } else if (substr($pattern, $i, 3) === 'EOL') { - $specialPattern = array('type' => 'newline'); + $specialPattern = ['type' => 'newline']; $lastToken = ($i - $firstToken); $firstToken = ($i + 3); $i = ($i + 2); @@ -861,7 +861,7 @@ private function parse($pattern) */ private function createSkipPattern($pattern, $from) { - $skip = array('type' => 'skip'); + $skip = ['type' => 'skip']; $nestedParenthesis = 0; $nestedBraces = 0; @@ -922,13 +922,13 @@ private function createTokenPattern($str) $tokens = $tokenizer->getTokens(); $tokens = array_slice($tokens, 1, (count($tokens) - 2)); - $patterns = array(); + $patterns = []; foreach ($tokens as $patternInfo) { - $patterns[] = array( - 'type' => 'token', - 'token' => $patternInfo['code'], - 'value' => $patternInfo['content'], - ); + $patterns[] = [ + 'type' => 'token', + 'token' => $patternInfo['code'], + 'value' => $patternInfo['content'], + ]; } return $patterns; diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index be83bed954..48803dfade 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -37,14 +37,14 @@ abstract class AbstractScopeSniff implements Sniff * * @var array */ - private $tokens = array(); + private $tokens = []; /** * The type of scope opener tokens that this test wishes to listen to. * * @var string */ - private $scopeTokens = array(); + private $scopeTokens = []; /** * True if this test should fire on tokens outside of the scope. diff --git a/src/Sniffs/AbstractVariableSniff.php b/src/Sniffs/AbstractVariableSniff.php index 09ef253286..594e3678eb 100644 --- a/src/Sniffs/AbstractVariableSniff.php +++ b/src/Sniffs/AbstractVariableSniff.php @@ -30,11 +30,11 @@ public function __construct() { $scopes = Tokens::$ooScopeTokens; - $listen = array( - T_VARIABLE, - T_DOUBLE_QUOTED_STRING, - T_HEREDOC, - ); + $listen = [ + T_VARIABLE, + T_DOUBLE_QUOTED_STRING, + T_HEREDOC, + ]; parent::__construct($scopes, $listen, true); diff --git a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index 851fdbfaea..563fe91837 100644 --- a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -85,10 +85,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } $error = 'Array key not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $first, 'KeyIncorrect', $data); if ($fix === false) { continue; @@ -122,10 +122,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } $error = 'Array close brace not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceIncorrect', $data); if ($fix === false) { return; diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php index cf39925960..9a3c328057 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -23,7 +23,7 @@ class DisallowLongArraySyntaxSniff implements Sniff */ public function register() { - return array(T_ARRAY); + return [T_ARRAY]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php index 54b0bfed2b..8bd01ac9d9 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php @@ -23,7 +23,7 @@ class DisallowShortArraySyntaxSniff implements Sniff */ public function register() { - return array(T_OPEN_SHORT_ARRAY); + return [T_OPEN_SHORT_ARRAY]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php index aa204a6442..e20ea60808 100644 --- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php @@ -20,7 +20,7 @@ class DuplicateClassNameSniff implements Sniff * * @var array */ - protected $foundClasses = array(); + protected $foundClasses = []; /** @@ -30,7 +30,7 @@ class DuplicateClassNameSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -49,12 +49,12 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $namespace = ''; - $findTokens = array( - T_CLASS, - T_INTERFACE, - T_NAMESPACE, - T_CLOSE_TAG, - ); + $findTokens = [ + T_CLASS, + T_INTERFACE, + T_NAMESPACE, + T_CLOSE_TAG, + ]; $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1)); while ($stackPtr !== false) { @@ -67,11 +67,11 @@ public function process(File $phpcsFile, $stackPtr) // Keep track of what namespace we are in. if ($tokens[$stackPtr]['code'] === T_NAMESPACE) { $nsEnd = $phpcsFile->findNext( - array( - T_NS_SEPARATOR, - T_STRING, - T_WHITESPACE, - ), + [ + T_NS_SEPARATOR, + T_STRING, + T_WHITESPACE, + ], ($stackPtr + 1), null, true @@ -92,18 +92,18 @@ public function process(File $phpcsFile, $stackPtr) $file = $this->foundClasses[$compareName]['file']; $line = $this->foundClasses[$compareName]['line']; $error = 'Duplicate %s name "%s" found; first defined in %s on line %s'; - $data = array( - $type, - $name, - $file, - $line, - ); + $data = [ + $type, + $name, + $file, + $line, + ]; $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); } else { - $this->foundClasses[$compareName] = array( - 'file' => $phpcsFile->getFilename(), - 'line' => $tokens[$stackPtr]['line'], - ); + $this->foundClasses[$compareName] = [ + 'file' => $phpcsFile->getFilename(), + 'line' => $tokens[$stackPtr]['line'], + ]; } }//end if diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php index 39ca8f15a5..f3b9e09cad 100644 --- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php @@ -23,11 +23,11 @@ class OpeningBraceSameLineSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -45,7 +45,7 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $scopeIdentifier = $phpcsFile->findNext(T_STRING, ($stackPtr + 1)); - $errorData = array(strtolower($tokens[$stackPtr]['content']).' '.$tokens[$scopeIdentifier]['content']); + $errorData = [strtolower($tokens[$stackPtr]['content']).' '.$tokens[$scopeIdentifier]['content']]; if (isset($tokens[$stackPtr]['scope_opener']) === false) { $error = 'Possible parse error: %s missing opening or closing brace'; @@ -106,7 +106,7 @@ public function process(File $phpcsFile, $stackPtr) if ($length !== 1) { $error = 'Expected 1 space before opening brace; found %s'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data); if ($fix === true) { if ($length === 0 || $length === '\t') { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index cea574d063..2514a2d97f 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -28,14 +28,14 @@ class AssignmentInConditionSniff implements Sniff * * @var array */ - protected $assignmentTokens = array(); + protected $assignmentTokens = []; /** * The tokens that indicate the start of a condition. * * @var array */ - protected $conditionStartTokens = array(); + protected $conditionStartTokens = []; /** @@ -54,14 +54,14 @@ public function register() $this->conditionStartTokens = $starters; - return array( - T_IF, - T_ELSEIF, - T_FOR, - T_SWITCH, - T_CASE, - T_WHILE, - ); + return [ + T_IF, + T_ELSEIF, + T_FOR, + T_SWITCH, + T_CASE, + T_WHILE, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php index 772c7061db..9d42adfd20 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php @@ -38,18 +38,18 @@ class EmptyStatementSniff implements Sniff */ public function register() { - return array( - T_CATCH, - T_DO, - T_ELSE, - T_ELSEIF, - T_FOR, - T_FOREACH, - T_IF, - T_SWITCH, - T_TRY, - T_WHILE, - ); + return [ + T_CATCH, + T_DO, + T_ELSE, + T_ELSEIF, + T_FOR, + T_FOREACH, + T_IF, + T_SWITCH, + T_TRY, + T_WHILE, + ]; }//end register() @@ -87,7 +87,7 @@ public function process(File $phpcsFile, $stackPtr) // Get token identifier. $name = strtoupper($token['content']); $error = 'Empty %s statement detected'; - $phpcsFile->addError($error, $stackPtr, 'Detected'.$name, array($name)); + $phpcsFile->addError($error, $stackPtr, 'Detected'.$name, [$name]); }//end process() diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php index bfe59fd40f..f9026a75a4 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php @@ -37,7 +37,7 @@ class ForLoopShouldBeWhileLoopSniff implements Sniff */ public function register() { - return array(T_FOR); + return [T_FOR]; }//end register() @@ -64,11 +64,11 @@ public function process(File $phpcsFile, $stackPtr) $next = ++$token['parenthesis_opener']; $end = --$token['parenthesis_closer']; - $parts = array( - 0, - 0, - 0, - ); + $parts = [ + 0, + 0, + 0, + ]; $index = 0; for (; $next <= $end; ++$next) { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index 884591911f..18c0739498 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -41,7 +41,7 @@ class ForLoopWithTestFunctionCallSniff implements Sniff */ public function register() { - return array(T_FOR); + return [T_FOR]; }//end register() diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php index 4877c9b60f..94e05773a6 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php @@ -43,7 +43,7 @@ class JumbledIncrementerSniff implements Sniff */ public function register() { - return array(T_FOR); + return [T_FOR]; }//end register() @@ -89,7 +89,7 @@ public function process(File $phpcsFile, $stackPtr) if (count($diff) !== 0) { $error = 'Loop incrementor (%s) jumbling with inner loop'; - $data = array(join(', ', $diff)); + $data = [join(', ', $diff)]; $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); } } @@ -109,13 +109,13 @@ protected function findIncrementers(array $tokens, array $token) { // Skip invalid statement. if (isset($token['parenthesis_opener']) === false) { - return array(); + return []; } $start = ++$token['parenthesis_opener']; $end = --$token['parenthesis_closer']; - $incrementers = array(); + $incrementers = []; $semicolons = 0; for ($next = $start; $next <= $end; ++$next) { $code = $tokens[$next]['code']; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php index a381985d5e..4e9c69501c 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php @@ -41,10 +41,10 @@ class UnconditionalIfStatementSniff implements Sniff */ public function register() { - return array( - T_IF, - T_ELSEIF, - ); + return [ + T_IF, + T_ELSEIF, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php index 862e32ed87..de94fed0b3 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php @@ -37,7 +37,7 @@ class UnnecessaryFinalModifierSniff implements Sniff */ public function register() { - return array(T_CLASS); + return [T_CLASS]; }//end register() diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index eb2719c64c..0a9aee4768 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -31,10 +31,10 @@ class UnusedFunctionParameterSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -58,7 +58,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $params = array(); + $params = []; foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { $params[$param['name']] = $stackPtr; } @@ -67,13 +67,13 @@ public function process(File $phpcsFile, $stackPtr) $end = --$token['scope_closer']; $foundContent = false; - $validTokens = array( - T_HEREDOC => T_HEREDOC, - T_NOWDOC => T_NOWDOC, - T_END_HEREDOC => T_END_HEREDOC, - T_END_NOWDOC => T_END_NOWDOC, - T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, - ); + $validTokens = [ + T_HEREDOC => T_HEREDOC, + T_NOWDOC => T_NOWDOC, + T_END_HEREDOC => T_END_HEREDOC, + T_END_NOWDOC => T_END_NOWDOC, + T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, + ]; $validTokens += Tokens::$emptyTokens; for (; $next <= $end; ++$next) { @@ -165,7 +165,7 @@ public function process(File $phpcsFile, $stackPtr) if ($foundContent === true && count($params) > 0) { foreach ($params as $paramName => $position) { $error = 'The method parameter %s is never used'; - $data = array($paramName); + $data = [$paramName]; $phpcsFile->addWarning($error, $position, 'Found', $data); } } diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index 06f50f8668..39dcc1152a 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -36,7 +36,7 @@ class UselessOverridingMethodSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) $methodName = $phpcsFile->getDeclarationName($stackPtr); // Get all parameters from method signature. - $signature = array(); + $signature = []; foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { $signature[] = $param['name']; } @@ -113,7 +113,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $parameters = array(''); + $parameters = ['']; $parenthesisCount = 1; $count = count($tokens); for (++$next; $next < $count; ++$next) { diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index 6fddeeec11..3cd78e6ff2 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -20,10 +20,10 @@ class DocCommentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,7 +33,7 @@ class DocCommentSniff implements Sniff */ public function register() { - return array(T_DOC_COMMENT_OPEN_TAG); + return [T_DOC_COMMENT_OPEN_TAG]; }//end register() @@ -53,10 +53,10 @@ public function process(File $phpcsFile, $stackPtr) $commentStart = $stackPtr; $commentEnd = $tokens[$stackPtr]['comment_closer']; - $empty = array( - T_DOC_COMMENT_WHITESPACE, - T_DOC_COMMENT_STAR, - ); + $empty = [ + T_DOC_COMMENT_WHITESPACE, + T_DOC_COMMENT_STAR, + ]; $short = $phpcsFile->findNext($empty, ($stackPtr + 1), $commentEnd, true); if ($short === false) { @@ -209,7 +209,7 @@ public function process(File $phpcsFile, $stackPtr) // Break out the tags into groups and check alignment within each. // A tag group is one where there are no blank lines between tags. // The param tag group is special as it requires all @param tags to be inside. - $tagGroups = array(); + $tagGroups = []; $groupid = 0; $paramGroupid = null; foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) { @@ -252,7 +252,7 @@ public function process(File $phpcsFile, $stackPtr) foreach ($tagGroups as $group) { $maxLength = 0; - $paddings = array(); + $paddings = []; foreach ($group as $pos => $tag) { $tagLength = strlen($tokens[$tag]['content']); if ($tagLength > $maxLength) { @@ -271,7 +271,7 @@ public function process(File $phpcsFile, $stackPtr) $lastTag = $group[$pos]; $next = $phpcsFile->findNext(T_DOC_COMMENT_TAG, ($lastTag + 3), $commentEnd); if ($next !== false) { - $prev = $phpcsFile->findPrevious(array(T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING), ($next - 1), $commentStart); + $prev = $phpcsFile->findPrevious([T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING], ($next - 1), $commentStart); if ($tokens[$next]['line'] !== ($tokens[$prev]['line'] + 2)) { $error = 'There must be a single blank line after a tag group'; $fix = $phpcsFile->addFixableError($error, $lastTag, 'SpacingAfterTagGroup'); @@ -298,10 +298,10 @@ public function process(File $phpcsFile, $stackPtr) if ($padding !== $required) { $error = 'Tag value indented incorrectly; expected %s spaces but found %s'; - $data = array( - $required, - $padding, - ); + $data = [ + $required, + $padding, + ]; $fix = $phpcsFile->addFixableError($error, ($tag + 1), 'TagValueIndent', $data); if ($fix === true) { @@ -317,7 +317,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $tagGroups[$paramGroupid][0], 'ParamNotFirst'); } - $foundTags = array(); + $foundTags = []; foreach ($tokens[$stackPtr]['comment_tags'] as $pos => $tag) { $tagName = $tokens[$tag]['content']; if (isset($foundTags[$tagName]) === true) { diff --git a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index 2d2ad401b8..59265148fc 100644 --- a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -22,10 +22,10 @@ class FixmeSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -54,7 +54,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $content = $tokens[$stackPtr]['content']; - $matches = array(); + $matches = []; preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches); if (empty($matches) === false) { // Clear whitespace and some common characters not required at @@ -63,7 +63,7 @@ public function process(File $phpcsFile, $stackPtr) $fixmeMessage = trim($matches[1]); $fixmeMessage = trim($fixmeMessage, '-:[](). '); $error = 'Comment refers to a FIXME task'; - $data = array($fixmeMessage); + $data = [$fixmeMessage]; if ($fixmeMessage !== '') { $type = 'TaskFound'; $error .= ' "%s"'; diff --git a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php index 41746cc9e6..c1ad5e5061 100644 --- a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php @@ -21,10 +21,10 @@ class TodoSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $content = $tokens[$stackPtr]['content']; - $matches = array(); + $matches = []; preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches); if (empty($matches) === false) { // Clear whitespace and some common characters not required at @@ -62,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr) $todoMessage = trim($matches[1]); $todoMessage = trim($todoMessage, '-:[](). '); $error = 'Comment refers to a TODO task'; - $data = array($todoMessage); + $data = [$todoMessage]; if ($todoMessage !== '') { $type = 'TaskFound'; $error .= ' "%s"'; diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index a222d815ee..1708164dac 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -21,10 +21,10 @@ class InlineControlStructureSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * If true, an error will be thrown; otherwise a warning. @@ -41,16 +41,16 @@ class InlineControlStructureSniff implements Sniff */ public function register() { - return array( - T_IF, - T_ELSE, - T_ELSEIF, - T_FOREACH, - T_WHILE, - T_DO, - T_SWITCH, - T_FOR, - ); + return [ + T_IF, + T_ELSE, + T_ELSEIF, + T_FOREACH, + T_WHILE, + T_DO, + T_SWITCH, + T_FOR, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php index c21c97a5cf..8e152ce8da 100644 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php @@ -21,7 +21,7 @@ class CSSLintSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class CSSLintSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) $count = count($output); for ($i = 0; $i < $count; $i++) { - $matches = array(); + $matches = []; $numMatches = preg_match( '/(error|warning) at line (\d+)/', $output[$i], diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index bf10365791..5f780837ac 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -23,21 +23,21 @@ class ClosureLinterSniff implements Sniff * * @var integer */ - public $errorCodes = array(); + public $errorCodes = []; /** * A list of error codes to ignore. * * @var integer */ - public $ignoreCodes = array(); + public $ignoreCodes = []; /** * A list of tokenizers this sniff supports. * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -47,7 +47,7 @@ class ClosureLinterSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -80,7 +80,7 @@ public function process(File $phpcsFile, $stackPtr) } foreach ($output as $finding) { - $matches = array(); + $matches = []; $numMatches = preg_match('/^(.*):([0-9]+):\(.*?([0-9]+)\)(.*)$/', $finding, $matches); if ($numMatches === 0) { continue; @@ -96,10 +96,10 @@ public function process(File $phpcsFile, $stackPtr) $error = trim($matches[4]); $message = 'gjslint says: (%s) %s'; - $data = array( - $code, - $error, - ); + $data = [ + $code, + $error, + ]; if (in_array($code, $this->errorCodes) === true) { $phpcsFile->addErrorOnLine($message, $line, 'ExternalToolError', $data); } else { diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index 19cdc32c30..7dd447fd03 100644 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -21,7 +21,7 @@ class ESLintSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -39,7 +39,7 @@ class ESLintSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -72,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr) } } - $eslintOptions = array('--format json'); + $eslintOptions = ['--format json']; if (empty($configFile) === false) { $eslintOptions[] = '--config '.escapeshellarg($configFile); } diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index 0728e65578..226ea6d9dc 100644 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -22,7 +22,7 @@ class JSHintSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -32,7 +32,7 @@ class JSHintSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -65,7 +65,7 @@ public function process(File $phpcsFile, $stackPtr) if (is_array($output) === true) { foreach ($output as $finding) { - $matches = array(); + $matches = []; $numMatches = preg_match('/^(.+)\(.+:([0-9]+).*:[0-9]+\)$/', $finding, $matches); if ($numMatches === 0) { continue; diff --git a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php index 831f471eb8..6811335960 100644 --- a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php @@ -23,11 +23,11 @@ class ByteOrderMarkSniff implements Sniff * * @var array */ - protected $bomDefinitions = array( - 'UTF-8' => 'efbbbf', - 'UTF-16 (BE)' => 'feff', - 'UTF-16 (LE)' => 'fffe', - ); + protected $bomDefinitions = [ + 'UTF-8' => 'efbbbf', + 'UTF-16 (BE)' => 'feff', + 'UTF-16 (LE)' => 'fffe', + ]; /** @@ -37,7 +37,7 @@ class ByteOrderMarkSniff implements Sniff */ public function register() { - return array(T_INLINE_HTML); + return [T_INLINE_HTML]; }//end register() @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) $bomByteLength = (strlen($expectedBomHex) / 2); $htmlBomHex = bin2hex(substr($tokens[$stackPtr]['content'], 0, $bomByteLength)); if ($htmlBomHex === $expectedBomHex) { - $errorData = array($bomName); + $errorData = [$bomName]; $error = 'File contains %s byte order mark, which may corrupt your application'; $phpcsFile->addError($error, $stackPtr, 'Found', $errorData); $phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'yes'); diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php index 4a6740d73d..9b1a702e45 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php @@ -20,11 +20,11 @@ class EndFileNewlineSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** @@ -34,7 +34,7 @@ class EndFileNewlineSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php index 6a68633eb6..3de2f1aed7 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php @@ -20,11 +20,11 @@ class EndFileNoNewlineSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** @@ -34,7 +34,7 @@ class EndFileNoNewlineSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php index 523982ed30..96e3875e63 100644 --- a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +++ b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php @@ -23,7 +23,7 @@ class InlineHTMLSniff implements Sniff */ public function register() { - return array(T_INLINE_HTML); + return [T_INLINE_HTML]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index 341eb06fcf..8770dba9e1 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -20,11 +20,11 @@ class LineEndingsSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** * The valid EOL character. @@ -41,7 +41,7 @@ class LineEndingsSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -84,10 +84,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = $this->eolChar; $expected = str_replace("\n", '\n', $expected); $expected = str_replace("\r", '\r', $expected); - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; // Errors are always reported on line 1, no matter where the first PHP tag is. $fix = $phpcsFile->addFixableError($error, 0, 'InvalidEOLChar', $data); diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 2a7704548e..0da42e2f4d 100644 --- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -50,7 +50,7 @@ class LineLengthSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -153,18 +153,18 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr) if ($this->absoluteLineLimit > 0 && $lineLength > $this->absoluteLineLimit ) { - $data = array( - $this->absoluteLineLimit, - $lineLength, - ); + $data = [ + $this->absoluteLineLimit, + $lineLength, + ]; $error = 'Line exceeds maximum limit of %s characters; contains %s characters'; $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); } else if ($lineLength > $this->lineLimit) { - $data = array( - $this->lineLimit, - $lineLength, - ); + $data = [ + $this->lineLimit, + $lineLength, + ]; $warning = 'Line exceeds %s characters; contains %s characters'; $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data); diff --git a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index c693069044..bd0a5f129e 100644 --- a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -23,7 +23,7 @@ class LowercasedFilenameSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -47,10 +47,10 @@ public function process(File $phpcsFile, $stackPtr) $filename = basename($filename); $lowercaseFilename = strtolower($filename); if ($filename !== $lowercaseFilename) { - $data = array( - $filename, - $lowercaseFilename, - ); + $data = [ + $filename, + $lowercaseFilename, + ]; $error = 'Filename "%s" doesn\'t match the expected filename "%s"'; $phpcsFile->addError($error, $stackPtr, 'NotFound', $data); $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no'); diff --git a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php index 1b79ff8707..9084865749 100644 --- a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php @@ -23,7 +23,7 @@ class OneClassPerFileSniff implements Sniff */ public function register() { - return array(T_CLASS); + return [T_CLASS]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php index 14957c85ec..e8c5df94f4 100644 --- a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php @@ -23,7 +23,7 @@ class OneInterfacePerFileSniff implements Sniff */ public function register() { - return array(T_INTERFACE); + return [T_INTERFACE]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php index f6f058f0e3..95a80b68c9 100644 --- a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php @@ -23,11 +23,11 @@ class OneObjectStructurePerFileSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php index d5b7da6870..cb1c6c7766 100644 --- a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php @@ -23,7 +23,7 @@ class OneTraitPerFileSniff implements Sniff */ public function register() { - return array(T_TRAIT); + return [T_TRAIT]; }//end register() diff --git a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php index 1cb5e9c5a7..59b947a9f5 100644 --- a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php @@ -23,7 +23,7 @@ class DisallowMultipleStatementsSniff implements Sniff */ public function register() { - return array(T_SEMICOLON); + return [T_SEMICOLON]; }//end register() @@ -41,7 +41,7 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $prev = $phpcsFile->findPrevious(array(T_SEMICOLON, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO), ($stackPtr - 1)); + $prev = $phpcsFile->findPrevious([T_SEMICOLON, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO], ($stackPtr - 1)); if ($prev === false || $tokens[$prev]['code'] === T_OPEN_TAG || $tokens[$prev]['code'] === T_OPEN_TAG_WITH_ECHO diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index a096369c06..cdf817e8fb 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -24,10 +24,10 @@ class MultipleStatementAlignmentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * If true, an error will be thrown; otherwise a warning. @@ -103,7 +103,7 @@ public function checkAlignment($phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $assignments = array(); + $assignments = []; $prevAssign = null; $lastLine = $tokens[$stackPtr]['line']; $maxPadding = null; @@ -230,13 +230,13 @@ public function checkAlignment($phpcsFile, $stackPtr) } } - $assignments[$assign] = array( - 'var_end' => $varEnd, - 'assign_len' => $assignLen, - 'assign_col' => $assignColumn, - 'expected' => $padding, - 'found' => $found, - ); + $assignments[$assign] = [ + 'var_end' => $varEnd, + 'assign_len' => $assignLen, + 'assign_col' => $assignColumn, + 'expected' => $padding, + 'found' => $found, + ]; $lastLine = $tokens[$assign]['line']; $prevAssign = $assign; @@ -276,10 +276,10 @@ public function checkAlignment($phpcsFile, $stackPtr) $error = 'Equals sign not aligned with surrounding assignments; expected %s but found %s'; } - $errorData = array( - $expectedText, - $foundText, - ); + $errorData = [ + $expectedText, + $foundText, + ]; if ($this->error === true) { $fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData); diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index d61879bb4d..0a5af940b8 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -21,10 +21,10 @@ class SpaceAfterNotSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -34,7 +34,7 @@ class SpaceAfterNotSniff implements Sniff */ public function register() { - return array(T_BOOLEAN_NOT); + return [T_BOOLEAN_NOT]; }//end register() @@ -62,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr) } $message = 'There must be a single space after a NOT operator; %s found'; - $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing)); + $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', [$spacing]); if ($fix === true) { if ($spacing === 0) { diff --git a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php index 2e64e0b398..40a2933d04 100644 --- a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php @@ -24,10 +24,10 @@ class CallTimePassByReferenceSniff implements Sniff */ public function register() { - return array( - T_STRING, - T_VARIABLE, - ); + return [ + T_STRING, + T_VARIABLE, + ]; }//end register() @@ -47,7 +47,7 @@ public function process(File $phpcsFile, $stackPtr) $findTokens = array_merge( Tokens::$emptyTokens, - array(T_BITWISE_AND) + [T_BITWISE_AND] ); $prev = $phpcsFile->findPrevious($findTokens, ($stackPtr - 1), null, true); @@ -82,10 +82,10 @@ public function process(File $phpcsFile, $stackPtr) $closeBracket = $tokens[$openBracket]['parenthesis_closer']; $nextSeparator = $openBracket; - $find = array( - T_VARIABLE, - T_OPEN_SHORT_ARRAY, - ); + $find = [ + T_VARIABLE, + T_OPEN_SHORT_ARRAY, + ]; while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) { if (isset($tokens[$nextSeparator]['nested_parenthesis']) === false) { diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 01063a1fdc..e18cf318a6 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -82,12 +82,12 @@ public function process(File $phpcsFile, $stackPtr) $closeBracket = $tokens[$openBracket]['parenthesis_closer']; $nextSeparator = $openBracket; - $find = array( - T_COMMA, - T_VARIABLE, - T_CLOSURE, - T_OPEN_SHORT_ARRAY, - ); + $find = [ + T_COMMA, + T_VARIABLE, + T_CLOSURE, + T_OPEN_SHORT_ARRAY, + ]; while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) { if ($tokens[$nextSeparator]['code'] === T_CLOSURE) { @@ -134,7 +134,7 @@ public function process(File $phpcsFile, $stackPtr) $space = strlen($tokens[($nextSeparator + 1)]['content']); if ($space > 1) { $error = 'Expected 1 space after comma in function call; %s found'; - $data = array($space); + $data = [$space]; $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'TooMuchSpaceAfterComma', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($nextSeparator + 1), ' '); diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index caf5a383fb..3e4b9f936d 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -37,10 +37,10 @@ class OpeningFunctionBraceBsdAllmanSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -90,7 +90,7 @@ public function process(File $phpcsFile, $stackPtr) $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnSameLine'); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); - $indent = $phpcsFile->findFirstOnLine(array(), $openingBrace); + $indent = $phpcsFile->findFirstOnLine([], $openingBrace); if ($tokens[$indent]['code'] === T_WHITESPACE) { $phpcsFile->fixer->addContentBefore($openingBrace, $tokens[$indent]['content']); } @@ -102,7 +102,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line'); } else if ($lineDifference > 1) { $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)'; - $data = array(($lineDifference - 1)); + $data = [($lineDifference - 1)]; $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceSpacing', $data); if ($fix === true) { for ($i = ($tokens[$stackPtr]['parenthesis_closer'] + 1); $i < $openingBrace; $i++) { @@ -151,10 +151,10 @@ public function process(File $phpcsFile, $stackPtr) $found = ($braceIndent - 1); $error = 'Opening brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceIndent', $data); if ($fix === true) { diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index 7267ef2350..10e11abc7a 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -39,10 +39,10 @@ class OpeningFunctionBraceKernighanRitchieSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -156,7 +156,7 @@ public function process(File $phpcsFile, $stackPtr) if ($length !== 1) { $error = 'Expected 1 space before opening brace; found %s'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceBeforeBrace', $data); if ($fix === true) { if ($length === 0 || $length === '\t') { diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index 86ed2a486d..ab07e21e02 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -42,7 +42,7 @@ class CyclomaticComplexitySniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -72,17 +72,17 @@ public function process(File $phpcsFile, $stackPtr) $end = $tokens[$stackPtr]['scope_closer']; // Predicate nodes for PHP. - $find = array( - T_CASE => true, - T_DEFAULT => true, - T_CATCH => true, - T_IF => true, - T_FOR => true, - T_FOREACH => true, - T_WHILE => true, - T_DO => true, - T_ELSEIF => true, - ); + $find = [ + T_CASE => true, + T_DEFAULT => true, + T_CATCH => true, + T_IF => true, + T_FOR => true, + T_FOREACH => true, + T_WHILE => true, + T_DO => true, + T_ELSEIF => true, + ]; $complexity = 1; @@ -95,17 +95,17 @@ public function process(File $phpcsFile, $stackPtr) if ($complexity > $this->absoluteComplexity) { $error = 'Function\'s cyclomatic complexity (%s) exceeds allowed maximum of %s'; - $data = array( - $complexity, - $this->absoluteComplexity, - ); + $data = [ + $complexity, + $this->absoluteComplexity, + ]; $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); } else if ($complexity > $this->complexity) { $warning = 'Function\'s cyclomatic complexity (%s) exceeds %s; consider refactoring the function'; - $data = array( - $complexity, - $this->complexity, - ); + $data = [ + $complexity, + $this->complexity, + ]; $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); } diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php index fc5ed39ad5..742c1378f3 100644 --- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php @@ -38,7 +38,7 @@ class NestingLevelSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -80,17 +80,17 @@ public function process(File $phpcsFile, $stackPtr) if ($nestingLevel > $this->absoluteNestingLevel) { $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s'; - $data = array( - $nestingLevel, - $this->absoluteNestingLevel, - ); + $data = [ + $nestingLevel, + $this->absoluteNestingLevel, + ]; $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); } else if ($nestingLevel > $this->nestingLevel) { $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function'; - $data = array( - $nestingLevel, - $this->nestingLevel, - ); + $data = [ + $nestingLevel, + $this->nestingLevel, + ]; $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); } diff --git a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php index 008be8c2af..40e3197c80 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php @@ -22,23 +22,23 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff * * @var array */ - protected $magicMethods = array( - 'construct' => true, - 'destruct' => true, - 'call' => true, - 'callstatic' => true, - 'get' => true, - 'set' => true, - 'isset' => true, - 'unset' => true, - 'sleep' => true, - 'wakeup' => true, - 'tostring' => true, - 'set_state' => true, - 'clone' => true, - 'invoke' => true, - 'debuginfo' => true, - ); + protected $magicMethods = [ + 'construct' => true, + 'destruct' => true, + 'call' => true, + 'callstatic' => true, + 'get' => true, + 'set' => true, + 'isset' => true, + 'unset' => true, + 'sleep' => true, + 'wakeup' => true, + 'tostring' => true, + 'set_state' => true, + 'clone' => true, + 'invoke' => true, + 'debuginfo' => true, + ]; /** * A list of all PHP non-magic methods starting with a double underscore. @@ -47,26 +47,26 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff * * @var array */ - protected $methodsDoubleUnderscore = array( - 'soapcall' => true, - 'getlastrequest' => true, - 'getlastresponse' => true, - 'getlastrequestheaders' => true, - 'getlastresponseheaders' => true, - 'getfunctions' => true, - 'gettypes' => true, - 'dorequest' => true, - 'setcookie' => true, - 'setlocation' => true, - 'setsoapheaders' => true, - ); + protected $methodsDoubleUnderscore = [ + 'soapcall' => true, + 'getlastrequest' => true, + 'getlastresponse' => true, + 'getlastrequestheaders' => true, + 'getlastresponseheaders' => true, + 'getfunctions' => true, + 'gettypes' => true, + 'dorequest' => true, + 'setcookie' => true, + 'setlocation' => true, + 'setsoapheaders' => true, + ]; /** * A list of all PHP magic functions. * * @var array */ - protected $magicFunctions = array('autoload' => true); + protected $magicFunctions = ['autoload' => true]; /** * If TRUE, the string must not have two capital letters next to each other. @@ -81,7 +81,7 @@ class CamelCapsFunctionNameSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(Tokens::$ooScopeTokens, array(T_FUNCTION), true); + parent::__construct(Tokens::$ooScopeTokens, [T_FUNCTION], true); }//end __construct() @@ -105,7 +105,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop } $className = $phpcsFile->getDeclarationName($currScope); - $errorData = array($className.'::'.$methodName); + $errorData = [$className.'::'.$methodName]; // Is this a magic method. i.e., is prefixed with "__" ? if (preg_match('|^__[^_]|', $methodName) !== 0) { @@ -137,10 +137,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if (Common::isCamelCaps($methodName, false, true, $this->strict) === false) { if ($methodProps['scope_specified'] === true) { $error = '%s method name "%s" is not in camel caps format'; - $data = array( - ucfirst($methodProps['scope']), - $errorData[0], - ); + $data = [ + ucfirst($methodProps['scope']), + $errorData[0], + ]; $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); } else { $error = 'Method name "%s" is not in camel caps format'; @@ -173,7 +173,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) return; } - $errorData = array($functionName); + $errorData = [$functionName]; // Is this a magic function. i.e., it is prefixed with "__". if (preg_match('|^__[^_]|', $functionName) !== 0) { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php index 27b801174e..c42b7c231e 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php @@ -31,7 +31,7 @@ class ConstructorNameSniff extends AbstractScopeSniff * * @var string[] */ - private $functionList = array(); + private $functionList = []; /** @@ -39,7 +39,7 @@ class ConstructorNameSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS, T_ANON_CLASS, T_INTERFACE), array(T_FUNCTION), true); + parent::__construct([T_CLASS, T_ANON_CLASS, T_INTERFACE], [T_FUNCTION], true); }//end __construct() @@ -128,7 +128,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) */ protected function loadFunctionNamesInScope(File $phpcsFile, $currScope) { - $this->functionList = array(); + $this->functionList = []; $tokens = $phpcsFile->getTokens(); for ($i = ($tokens[$currScope]['scope_opener'] + 1); $i < $tokens[$currScope]['scope_closer']; $i++) { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index adeb126368..2fe74056f1 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -23,7 +23,7 @@ class UpperCaseConstantNameSniff implements Sniff */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() @@ -73,13 +73,13 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { $functionKeyword = $phpcsFile->findPrevious( - array( - T_WHITESPACE, - T_COMMA, - T_COMMENT, - T_STRING, - T_NS_SEPARATOR, - ), + [ + T_WHITESPACE, + T_COMMA, + T_COMMENT, + T_STRING, + T_NS_SEPARATOR, + ], ($stackPtr - 1), null, true @@ -98,10 +98,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Class constants must be uppercase; expected %s but found %s'; - $data = array( - strtoupper($constName), - $constName, - ); + $data = [ + strtoupper($constName), + $constName, + ]; $phpcsFile->addError($error, $stackPtr, 'ClassConstantNotUpperCase', $data); } else { $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'upper'); @@ -157,10 +157,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Constants must be uppercase; expected %s but found %s'; - $data = array( - $prefix.strtoupper($constName), - $prefix.$constName, - ); + $data = [ + $prefix.strtoupper($constName), + $prefix.$constName, + ]; $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); } else { $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'upper'); diff --git a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php index 7ef4e5df40..076b64924e 100644 --- a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php @@ -23,7 +23,7 @@ class BacktickOperatorSniff implements Sniff */ public function register() { - return array(T_BACKTICK); + return [T_BACKTICK]; }//end register() diff --git a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php index 4e7296c3b9..4346682255 100644 --- a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php @@ -23,7 +23,7 @@ class CharacterBeforePHPOpeningTagSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php index f810812cba..58edb5e323 100644 --- a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php @@ -23,7 +23,7 @@ class ClosingPHPTagSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php index 19ca3535a2..b66b23d782 100644 --- a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -21,7 +21,7 @@ class DeprecatedFunctionsSniff extends ForbiddenFunctionsSniff * * @var array(string => string|null) */ - public $forbiddenFunctions = array(); + public $forbiddenFunctions = []; /** @@ -60,7 +60,7 @@ public function __construct() */ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) { - $data = array($function); + $data = [$function]; $error = 'Function %s() has been deprecated'; $type = 'Deprecated'; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php index b05896a93a..be4bc1d93c 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php @@ -51,11 +51,11 @@ public function register() $this->aspTags = (boolean) ini_get('asp_tags'); } - return array( - T_OPEN_TAG, - T_OPEN_TAG_WITH_ECHO, - T_INLINE_HTML, - ); + return [ + T_OPEN_TAG, + T_OPEN_TAG_WITH_ECHO, + T_INLINE_HTML, + ]; }//end register() @@ -91,7 +91,7 @@ public function process(File $phpcsFile, $stackPtr) } if (isset($error, $closer, $errorCode) === true) { - $data = array($content); + $data = [$content]; if ($closer === false) { $phpcsFile->addError($error, $stackPtr, $errorCode, $data); @@ -110,11 +110,11 @@ public function process(File $phpcsFile, $stackPtr) $error = 'ASP style opening tag used with echo; expected "findNext(T_WHITESPACE, ($stackPtr + 1), null, true); $snippet = $this->getSnippet($tokens[$nextVar]['content']); - $data = array( - $snippet, - $content, - $snippet, - ); + $data = [ + $snippet, + $content, + $snippet, + ]; $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>'); @@ -137,7 +137,7 @@ public function process(File $phpcsFile, $stackPtr) ) { $error = 'Script style opening tag used; expected "getSnippet($content, $match[1]); - $data = array($match[1].$snippet); + $data = [$match[1].$snippet]; $phpcsFile->addError($error, $stackPtr, 'ScriptOpenTagFound', $data); return; @@ -147,13 +147,13 @@ public function process(File $phpcsFile, $stackPtr) if (strpos($content, '<%=') !== false) { $error = 'Possible use of ASP style short opening tags detected; found: %s'; $snippet = $this->getSnippet($content, '<%='); - $data = array('<%='.$snippet); + $data = ['<%='.$snippet]; $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPShortOpenTagFound', $data); } else if (strpos($content, '<%') !== false) { $error = 'Possible use of ASP style opening tags detected; found: %s'; $snippet = $this->getSnippet($content, '<%'); - $data = array('<%'.$snippet); + $data = ['<%'.$snippet]; $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data); } diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index cc490e16d0..af5f0f8d31 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -24,10 +24,10 @@ class DisallowShortOpenTagSniff implements Sniff */ public function register() { - $targets = array( - T_OPEN_TAG, - T_OPEN_TAG_WITH_ECHO, - ); + $targets = [ + T_OPEN_TAG, + T_OPEN_TAG_WITH_ECHO, + ]; $shortOpenTags = (boolean) ini_get('short_open_tag'); if ($shortOpenTags === false) { @@ -55,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr) if ($token['code'] === T_OPEN_TAG && $token['content'] === 'addFixableError($error, $stackPtr, 'Found', $data); if ($fix === true) { $correctOpening = 'findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true)]; $error = 'Short PHP opening tag used with echo; expected "addFixableError($error, $stackPtr, 'EchoFound', $data); if ($fix === true) { if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { @@ -121,7 +121,7 @@ public function process(File $phpcsFile, $stackPtr) if ($closerFound !== false) { $error = 'Possible use of short open tags detected; found: %s'; $snippet = $this->getSnippet($content, 'addWarning($error, $stackPtr, 'PossibleFound', $data); diff --git a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php index 03abe93118..b8ece50f2b 100644 --- a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php @@ -23,10 +23,10 @@ class DiscourageGotoSniff implements Sniff */ public function register() { - return array( - T_GOTO, - T_GOTO_LABEL, - ); + return [ + T_GOTO, + T_GOTO_LABEL, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index 7442bdd187..9479e1c8e4 100644 --- a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -26,17 +26,17 @@ class ForbiddenFunctionsSniff implements Sniff * * @var array */ - public $forbiddenFunctions = array( - 'sizeof' => 'count', - 'delete' => 'unset', - ); + public $forbiddenFunctions = [ + 'sizeof' => 'count', + 'delete' => 'unset', + ]; /** * A cache of forbidden function names, for faster lookups. * * @var string[] */ - protected $forbiddenFunctionNames = array(); + protected $forbiddenFunctionNames = []; /** * If true, forbidden functions will be considered regular expressions. @@ -69,7 +69,7 @@ public function register() $this->forbiddenFunctionNames[$i] = '/'.$name.'/i'; } - return array(T_STRING); + return [T_STRING]; } // If we are not pattern matching, we need to work out what @@ -79,7 +79,7 @@ public function register() $string .= $name.'();'; } - $register = array(); + $register = []; $tokens = token_get_all($string); array_shift($tokens); @@ -110,20 +110,20 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $ignore = array( - T_DOUBLE_COLON => true, - T_OBJECT_OPERATOR => true, - T_FUNCTION => true, - T_CONST => true, - T_PUBLIC => true, - T_PRIVATE => true, - T_PROTECTED => true, - T_AS => true, - T_NEW => true, - T_INSTEADOF => true, - T_NS_SEPARATOR => true, - T_IMPLEMENTS => true, - ); + $ignore = [ + T_DOUBLE_COLON => true, + T_OBJECT_OPERATOR => true, + T_FUNCTION => true, + T_CONST => true, + T_PUBLIC => true, + T_PRIVATE => true, + T_PROTECTED => true, + T_AS => true, + T_NEW => true, + T_INSTEADOF => true, + T_NS_SEPARATOR => true, + T_IMPLEMENTS => true, + ]; $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); @@ -196,7 +196,7 @@ public function process(File $phpcsFile, $stackPtr) */ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) { - $data = array($function); + $data = [$function]; $error = 'The use of function %s() is '; if ($this->error === true) { $type = 'Found'; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index d18de1ac42..432b0dc7d5 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -20,10 +20,10 @@ class LowerCaseConstantSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,11 +33,11 @@ class LowerCaseConstantSniff implements Sniff */ public function register() { - return array( - T_TRUE, - T_FALSE, - T_NULL, - ); + return [ + T_TRUE, + T_FALSE, + T_NULL, + ]; }//end register() @@ -64,10 +64,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'TRUE, FALSE and NULL must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $keyword, - ); + $data = [ + $expected, + $keyword, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data); if ($fix === true) { diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index 46c80b274e..a5b2a18e5e 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -23,79 +23,79 @@ class LowerCaseKeywordSniff implements Sniff */ public function register() { - return array( - T_HALT_COMPILER, - T_ABSTRACT, - T_ARRAY, - T_ARRAY_HINT, - T_AS, - T_BREAK, - T_CALLABLE, - T_CASE, - T_CATCH, - T_CLASS, - T_CLONE, - T_CLOSURE, - T_CONST, - T_CONTINUE, - T_DECLARE, - T_DEFAULT, - T_DO, - T_ECHO, - T_ELSE, - T_ELSEIF, - T_EMPTY, - T_ENDDECLARE, - T_ENDFOR, - T_ENDFOREACH, - T_ENDIF, - T_ENDSWITCH, - T_ENDWHILE, - T_EVAL, - T_EXIT, - T_EXTENDS, - T_FINAL, - T_FINALLY, - T_FOR, - T_FOREACH, - T_FUNCTION, - T_GLOBAL, - T_GOTO, - T_IF, - T_IMPLEMENTS, - T_INCLUDE, - T_INCLUDE_ONCE, - T_INSTANCEOF, - T_INSTEADOF, - T_INTERFACE, - T_ISSET, - T_LIST, - T_LOGICAL_AND, - T_LOGICAL_OR, - T_LOGICAL_XOR, - T_NAMESPACE, - T_NEW, - T_PARENT, - T_PRINT, - T_PRIVATE, - T_PROTECTED, - T_PUBLIC, - T_REQUIRE, - T_REQUIRE_ONCE, - T_RETURN, - T_SELF, - T_STATIC, - T_SWITCH, - T_THROW, - T_TRAIT, - T_TRY, - T_UNSET, - T_USE, - T_VAR, - T_WHILE, - T_YIELD, - T_YIELD_FROM, - ); + return [ + T_HALT_COMPILER, + T_ABSTRACT, + T_ARRAY, + T_ARRAY_HINT, + T_AS, + T_BREAK, + T_CALLABLE, + T_CASE, + T_CATCH, + T_CLASS, + T_CLONE, + T_CLOSURE, + T_CONST, + T_CONTINUE, + T_DECLARE, + T_DEFAULT, + T_DO, + T_ECHO, + T_ELSE, + T_ELSEIF, + T_EMPTY, + T_ENDDECLARE, + T_ENDFOR, + T_ENDFOREACH, + T_ENDIF, + T_ENDSWITCH, + T_ENDWHILE, + T_EVAL, + T_EXIT, + T_EXTENDS, + T_FINAL, + T_FINALLY, + T_FOR, + T_FOREACH, + T_FUNCTION, + T_GLOBAL, + T_GOTO, + T_IF, + T_IMPLEMENTS, + T_INCLUDE, + T_INCLUDE_ONCE, + T_INSTANCEOF, + T_INSTEADOF, + T_INTERFACE, + T_ISSET, + T_LIST, + T_LOGICAL_AND, + T_LOGICAL_OR, + T_LOGICAL_XOR, + T_NAMESPACE, + T_NEW, + T_PARENT, + T_PRINT, + T_PRIVATE, + T_PROTECTED, + T_PUBLIC, + T_REQUIRE, + T_REQUIRE_ONCE, + T_RETURN, + T_SELF, + T_STATIC, + T_SWITCH, + T_THROW, + T_TRAIT, + T_TRY, + T_UNSET, + T_USE, + T_VAR, + T_WHILE, + T_YIELD, + T_YIELD_FROM, + ]; }//end register() @@ -121,10 +121,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtolower($keyword), - $keyword, - ); + $data = [ + strtolower($keyword), + $keyword, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data); if ($fix === true) { diff --git a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php index c900218291..6ac7de124c 100644 --- a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php @@ -37,7 +37,7 @@ class NoSilencedErrorsSniff implements Sniff */ public function register() { - return array(T_ASPERAND); + return [T_ASPERAND]; }//end register() diff --git a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php index 983c31b2dd..8e2b119e2c 100644 --- a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php @@ -23,7 +23,7 @@ class SAPIUsageSniff implements Sniff */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() @@ -41,12 +41,12 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $ignore = array( - T_DOUBLE_COLON => true, - T_OBJECT_OPERATOR => true, - T_FUNCTION => true, - T_CONST => true, - ); + $ignore = [ + T_DOUBLE_COLON => true, + T_OBJECT_OPERATOR => true, + T_FUNCTION => true, + T_CONST => true, + ]; $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if (isset($ignore[$tokens[$prevToken]['code']]) === true) { diff --git a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php index f559e1809f..80cb81be73 100644 --- a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php @@ -32,7 +32,7 @@ class SyntaxSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -68,7 +68,7 @@ public function process(File $phpcsFile, $stackPtr) } $output = shell_exec($cmd); - $matches = array(); + $matches = []; if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/m', trim($output), $matches) === 1) { $error = trim($matches[1]); $line = (int) $matches[2]; diff --git a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php index d8d20039d9..c84f6291b4 100644 --- a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php @@ -23,11 +23,11 @@ class UpperCaseConstantSniff implements Sniff */ public function register() { - return array( - T_TRUE, - T_FALSE, - T_NULL, - ); + return [ + T_TRUE, + T_FALSE, + T_NULL, + ]; }//end register() @@ -54,10 +54,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'TRUE, FALSE and NULL must be uppercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $keyword, - ); + $data = [ + $expected, + $keyword, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data); if ($fix === true) { diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 52d973d647..6cc5f49caf 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -21,10 +21,10 @@ class UnnecessaryStringConcatSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * If true, an error will be thrown; otherwise a warning. @@ -51,10 +51,10 @@ class UnnecessaryStringConcatSniff implements Sniff */ public function register() { - return array( - T_STRING_CONCAT, - T_PLUS, - ); + return [ + T_STRING_CONCAT, + T_PLUS, + ]; }//end register() diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index 3007de8e7e..55d4d70a7f 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -25,10 +25,10 @@ class SubversionPropertiesSniff implements Sniff * * @var array */ - protected $properties = array( - 'svn:keywords' => 'Author Id Revision', - 'svn:eol-style' => 'native', - ); + protected $properties = [ + 'svn:keywords' => 'Author Id Revision', + 'svn:eol-style' => 'native', + ]; /** @@ -38,7 +38,7 @@ class SubversionPropertiesSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -69,10 +69,10 @@ public function process(File $phpcsFile, $stackPtr) && isset($this->properties[$key]) === false ) { $error = 'Unexpected Subversion property "%s" = "%s"'; - $data = array( - $key, - $properties[$key], - ); + $data = [ + $key, + $properties[$key], + ]; $phpcsFile->addError($error, $stackPtr, 'Unexpected', $data); continue; } @@ -81,10 +81,10 @@ public function process(File $phpcsFile, $stackPtr) && isset($this->properties[$key]) === true ) { $error = 'Missing Subversion property "%s" = "%s"'; - $data = array( - $key, - $this->properties[$key], - ); + $data = [ + $key, + $this->properties[$key], + ]; $phpcsFile->addError($error, $stackPtr, 'Missing', $data); continue; } @@ -93,11 +93,11 @@ public function process(File $phpcsFile, $stackPtr) && $properties[$key] !== $this->properties[$key] ) { $error = 'Subversion property "%s" = "%s" does not match "%s"'; - $data = array( - $key, - $properties[$key], - $this->properties[$key], - ); + $data = [ + $key, + $properties[$key], + $this->properties[$key], + ]; $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); } }//end foreach @@ -121,9 +121,9 @@ public function process(File $phpcsFile, $stackPtr) */ protected function getProperties($path) { - $properties = array(); + $properties = []; - $paths = array(); + $paths = []; $paths[] = dirname($path).'/.svn/props/'.basename($path).'.svn-work'; $paths[] = dirname($path).'/.svn/prop-base/'.basename($path).'.svn-base'; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index 7bc4a2c9b3..ab73f59f64 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -20,11 +20,11 @@ class DisallowSpaceIndentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** * The --tab-width CLI value that is being used. @@ -41,7 +41,7 @@ class DisallowSpaceIndentSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -68,11 +68,11 @@ public function process(File $phpcsFile, $stackPtr) } } - $checkTokens = array( - T_WHITESPACE => true, - T_INLINE_HTML => true, - T_DOC_COMMENT_WHITESPACE => true, - ); + $checkTokens = [ + T_WHITESPACE => true, + T_INLINE_HTML => true, + T_DOC_COMMENT_WHITESPACE => true, + ]; $tokens = $phpcsFile->getTokens(); for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index c2ab0dd0c4..382dc86901 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -20,11 +20,11 @@ class DisallowTabIndentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** * The --tab-width CLI value that is being used. @@ -41,7 +41,7 @@ class DisallowTabIndentSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -70,12 +70,12 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Spaces must be used to indent lines; tabs are not allowed'; $errorCode = 'TabsUsed'; - $checkTokens = array( - T_WHITESPACE => true, - T_INLINE_HTML => true, - T_DOC_COMMENT_WHITESPACE => true, - T_DOC_COMMENT_STRING => true, - ); + $checkTokens = [ + T_WHITESPACE => true, + T_INLINE_HTML => true, + T_DOC_COMMENT_WHITESPACE => true, + T_DOC_COMMENT_STRING => true, + ]; for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { if (isset($checkTokens[$tokens[$i]['code']]) === false) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index bdb1b2fe57..482d4cf1d5 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -22,10 +22,10 @@ class ScopeIndentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The number of spaces code should be indented. @@ -72,7 +72,7 @@ class ScopeIndentSniff implements Sniff * * @var int[] */ - public $ignoreIndentationTokens = array(); + public $ignoreIndentationTokens = []; /** * List of tokens not needing to be checked for indentation. @@ -82,14 +82,14 @@ class ScopeIndentSniff implements Sniff * * @var int[] */ - private $ignoreIndentation = array(); + private $ignoreIndentation = []; /** * Any scope openers that should not cause an indent. * * @var int[] */ - protected $nonIndentingScopes = array(); + protected $nonIndentingScopes = []; /** * Show debug output for this sniff. @@ -110,7 +110,7 @@ public function register() $this->debug = false; } - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -145,9 +145,9 @@ public function process(File $phpcsFile, $stackPtr) $currentIndent = 0; $lastOpenTag = $stackPtr; $lastCloseTag = null; - $openScopes = array(); - $adjustments = array(); - $setIndents = array(); + $openScopes = []; + $adjustments = []; + $setIndents = []; $tokens = $phpcsFile->getTokens(); $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr); @@ -164,7 +164,7 @@ public function process(File $phpcsFile, $stackPtr) } if (empty($this->ignoreIndentation) === true) { - $this->ignoreIndentation = array(T_INLINE_HTML => true); + $this->ignoreIndentation = [T_INLINE_HTML => true]; foreach ($this->ignoreIndentationTokens as $token) { if (is_int($token) === false) { if (defined($token) === false) { @@ -439,7 +439,7 @@ public function process(File $phpcsFile, $stackPtr) $first--; } - $prev = $phpcsFile->findStartOfStatement($first, array(T_COMMA, T_DOUBLE_ARROW)); + $prev = $phpcsFile->findStartOfStatement($first, [T_COMMA, T_DOUBLE_ARROW]); if ($prev !== $first) { // This is not the start of the statement. if ($this->debug === true) { @@ -449,7 +449,7 @@ public function process(File $phpcsFile, $stackPtr) } $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true); - $prev = $phpcsFile->findStartOfStatement($first, array(T_COMMA, T_DOUBLE_ARROW)); + $prev = $phpcsFile->findStartOfStatement($first, [T_COMMA, T_DOUBLE_ARROW]); $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true); if ($this->debug === true) { $line = $tokens[$first]['line']; @@ -846,16 +846,16 @@ public function process(File $phpcsFile, $stackPtr) if ($this->tabIndent === true) { $error .= '%s tabs, found %s'; - $data = array( - floor($checkIndent / $this->tabWidth), - floor($tokenIndent / $this->tabWidth), - ); + $data = [ + floor($checkIndent / $this->tabWidth), + floor($tokenIndent / $this->tabWidth), + ]; } else { $error .= '%s spaces, found %s'; - $data = array( - $checkIndent, - $tokenIndent, - ); + $data = [ + $checkIndent, + $tokenIndent, + ]; } if ($this->debug === true) { @@ -909,7 +909,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$i]['code'] === T_START_HEREDOC || $tokens[$i]['code'] === T_START_NOWDOC ) { - $i = $phpcsFile->findNext(array(T_END_HEREDOC, T_END_NOWDOC), ($i + 1)); + $i = $phpcsFile->findNext([T_END_HEREDOC, T_END_NOWDOC], ($i + 1)); continue; } @@ -1218,7 +1218,7 @@ public function process(File $phpcsFile, $stackPtr) }//end if if ($prev === false) { - $prev = $phpcsFile->findPrevious(array(T_EQUAL, T_RETURN), ($tokens[$i]['scope_condition'] - 1), null, false, null, true); + $prev = $phpcsFile->findPrevious([T_EQUAL, T_RETURN], ($tokens[$i]['scope_condition'] - 1), null, false, null, true); if ($prev === false) { $prev = $i; if ($this->debug === true) { diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index dbe34492d2..c236d996eb 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -25,19 +25,19 @@ class ArrayIndentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 14 => 1, - 15 => 1, - 17 => 1, - 30 => 1, - 31 => 1, - 33 => 1, - 41 => 1, - 49 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - ); + return [ + 14 => 1, + 15 => 1, + 17 => 1, + 30 => 1, + 31 => 1, + 33 => 1, + 41 => 1, + 49 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + ]; }//end getErrorList() @@ -52,7 +52,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php index d65e371fb1..459d243d23 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -25,14 +25,14 @@ class DisallowLongArraySyntaxUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 4 => 1, - 6 => 1, - 7 => 1, - 12 => 1, - 13 => 1, - ); + return [ + 2 => 1, + 4 => 1, + 6 => 1, + 7 => 1, + 12 => 1, + 13 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php index 1d2156a0a7..25c9666ebd 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php @@ -25,12 +25,12 @@ class DisallowShortArraySyntaxUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 7 => 1, - 8 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 7 => 1, + 8 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php index 47e4ff5572..e6a7c6e868 100644 --- a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php @@ -25,7 +25,7 @@ class DuplicateClassNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -44,28 +44,28 @@ public function getWarningList($testFile='') { switch ($testFile) { case 'DuplicateClassNameUnitTest.1.inc': - return array( - 6 => 1, - 7 => 1, - ); + return [ + 6 => 1, + 7 => 1, + ]; break; case 'DuplicateClassNameUnitTest.2.inc': - return array( - 2 => 1, - 3 => 1, - ); + return [ + 2 => 1, + 3 => 1, + ]; break; case 'DuplicateClassNameUnitTest.5.inc': - return array( - 3 => 1, - 7 => 1, - ); + return [ + 3 => 1, + 7 => 1, + ]; break; case 'DuplicateClassNameUnitTest.6.inc': - return array(10 => 1); + return [10 => 1]; break; default: - return array(); + return []; break; }//end switch diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php index 1680df26fe..61cd4c9e8f 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php @@ -26,19 +26,19 @@ class OpeningBraceSameLineUnitTest extends AbstractSniffUnitTest public function getErrorList() { - return array( - 19 => 2, - 23 => 1, - 28 => 2, - 34 => 1, - 38 => 1, - 41 => 1, - 44 => 1, - 47 => 1, - 70 => 1, - 79 => 1, - 90 => 1, - ); + return [ + 19 => 2, + 23 => 1, + 28 => 2, + 34 => 1, + 38 => 1, + 41 => 1, + 44 => 1, + 47 => 1, + 70 => 1, + 79 => 1, + 90 => 1, + ]; }//end getErrorList() @@ -53,7 +53,7 @@ public function getErrorList() */ public function getWarningList() { - return array(51 => 1); + return [51 => 1]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index eb13d5c98f..e489f1c35e 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -25,7 +25,7 @@ class AssignmentInConditionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,41 +40,41 @@ public function getErrorList() */ public function getWarningList() { - return array( - 46 => 1, - 47 => 1, - 48 => 1, - 49 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - 53 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 60 => 1, - 61 => 2, - 63 => 1, - 64 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - 73 => 1, - 75 => 1, - 77 => 1, - 80 => 2, - 84 => 1, - 85 => 2, - 88 => 1, - 90 => 1, - 92 => 1, - ); + return [ + 46 => 1, + 47 => 1, + 48 => 1, + 49 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + 53 => 1, + 54 => 1, + 55 => 1, + 56 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 61 => 2, + 63 => 1, + 64 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 75 => 1, + 77 => 1, + 80 => 2, + 84 => 1, + 85 => 2, + 88 => 1, + 90 => 1, + 92 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php index 3bd4992845..9d89ce2456 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php @@ -25,21 +25,21 @@ class EmptyStatementUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 30 => 1, - 35 => 1, - 41 => 1, - 47 => 1, - 52 => 1, - 55 => 1, - 64 => 1, - 68 => 1, - 72 => 2, - ); + return [ + 3 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 30 => 1, + 35 => 1, + 41 => 1, + 47 => 1, + 52 => 1, + 55 => 1, + 64 => 1, + 68 => 1, + 72 => 2, + ]; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php index 03018c1d06..1d9eddaa6a 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php @@ -25,7 +25,7 @@ class ForLoopShouldBeWhileLoopUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 6 => 1, - 10 => 1, - ); + return [ + 6 => 1, + 10 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index d3474ee441..60f00b5d97 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -25,7 +25,7 @@ class ForLoopWithTestFunctionCallUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 4 => 1, - 13 => 1, - ); + return [ + 4 => 1, + 13 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php index c431f2eb12..d6f0e3d4a4 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php @@ -25,7 +25,7 @@ class JumbledIncrementerUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 3 => 2, - 4 => 1, - 20 => 1, - ); + return [ + 3 => 2, + 4 => 1, + 20 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php index 475ec3cc55..a99fdd8dda 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php @@ -25,7 +25,7 @@ class UnconditionalIfStatementUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 3 => 1, - 5 => 1, - 7 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 7 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index 8e31ddbacd..100a9a63ba 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -25,7 +25,7 @@ class UnnecessaryFinalModifierUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 11 => 1, - 14 => 1, - 17 => 1, - ); + return [ + 11 => 1, + 14 => 1, + 17 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index a306af42a9..c01717a267 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -25,7 +25,7 @@ class UnusedFunctionParameterUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 3 => 1, - 7 => 1, - 78 => 1, - ); + return [ + 3 => 1, + 7 => 1, + 78 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php index 52eca80c21..d6ea1d03ba 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php @@ -25,7 +25,7 @@ class UselessOverridingMethodUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 4 => 1, - 16 => 1, - ); + return [ + 4 => 1, + 16 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index 02030deb91..6d3635f3a7 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -25,41 +25,41 @@ class DocCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 14 => 1, - 16 => 1, - 18 => 1, - 23 => 1, - 26 => 1, - 30 => 1, - 32 => 1, - 38 => 2, - 40 => 1, - 41 => 1, - 51 => 1, - 54 => 1, - 58 => 1, - 60 => 2, - 67 => 1, - 69 => 2, - 80 => 1, - 81 => 2, - 88 => 1, - 91 => 1, - 95 => 1, - 156 => 1, - 158 => 1, - 170 => 3, - 171 => 3, - 179 => 1, - 183 => 1, - 184 => 1, - 185 => 2, - 186 => 1, - 187 => 2, - 191 => 1, - 194 => 4, - ); + return [ + 14 => 1, + 16 => 1, + 18 => 1, + 23 => 1, + 26 => 1, + 30 => 1, + 32 => 1, + 38 => 2, + 40 => 1, + 41 => 1, + 51 => 1, + 54 => 1, + 58 => 1, + 60 => 2, + 67 => 1, + 69 => 2, + 80 => 1, + 81 => 2, + 88 => 1, + 91 => 1, + 95 => 1, + 156 => 1, + 158 => 1, + 170 => 3, + 171 => 3, + 179 => 1, + 183 => 1, + 184 => 1, + 185 => 2, + 186 => 1, + 187 => 2, + 191 => 1, + 194 => 4, + ]; }//end getErrorList() @@ -74,7 +74,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php index 89f760d5cb..e14ab316c3 100644 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php @@ -28,16 +28,16 @@ class FixmeUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='FixmeUnitTest.inc') { - return array( - 3 => 1, - 4 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); + return [ + 3 => 1, + 4 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ]; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList($testFile='FixmeUnitTest.inc') */ public function getWarningList($testFile='FixmeUnitTest.inc') { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php index 0e0b8df72b..4864b9373a 100644 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php @@ -27,7 +27,7 @@ class TodoUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='TodoUnitTest.inc') { - return array(); + return []; }//end getErrorList() @@ -44,16 +44,16 @@ public function getErrorList($testFile='TodoUnitTest.inc') */ public function getWarningList($testFile='TodoUnitTest.inc') { - return array( - 3 => 1, - 4 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); + return [ + 3 => 1, + 4 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index c85c846c1e..7ab2b4ba08 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -29,60 +29,60 @@ public function getErrorList($testFile='InlineControlStructureUnitTest.inc') { switch ($testFile) { case 'InlineControlStructureUnitTest.inc': - return array( - 3 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 17 => 1, - 23 => 1, - 42 => 1, - 43 => 1, - 45 => 1, - 46 => 1, - 49 => 1, - 62 => 1, - 66 => 1, - 78 => 1, - 120 => 1, - 128 => 1, - 134 => 1, - 142 => 1, - 143 => 1, - 144 => 1, - 150 => 1, - 158 => 1, - 159 => 1, - 162 => 1, - 163 => 1, - 164 => 1, - 167 => 1, - 168 => 1, - 170 => 1, - 178 => 1, - 185 => 1, - 188 => 2, - 191 => 1, - 195 => 1, - 198 => 1, - 206 => 1, - ); + return [ + 3 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + 17 => 1, + 23 => 1, + 42 => 1, + 43 => 1, + 45 => 1, + 46 => 1, + 49 => 1, + 62 => 1, + 66 => 1, + 78 => 1, + 120 => 1, + 128 => 1, + 134 => 1, + 142 => 1, + 143 => 1, + 144 => 1, + 150 => 1, + 158 => 1, + 159 => 1, + 162 => 1, + 163 => 1, + 164 => 1, + 167 => 1, + 168 => 1, + 170 => 1, + 178 => 1, + 185 => 1, + 188 => 2, + 191 => 1, + 195 => 1, + 198 => 1, + 206 => 1, + ]; break; case 'InlineControlStructureUnitTest.js': - return array( - 3 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 21 => 1, - 27 => 1, - 30 => 1, - ); + return [ + 3 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + 21 => 1, + 27 => 1, + 30 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -99,7 +99,7 @@ public function getErrorList($testFile='InlineControlStructureUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index 1ee36140c4..a95331d72c 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -25,7 +25,7 @@ class ByteOrderMarkUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(1 => 1); + return [1 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index 409f2b4af3..748e99f544 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -31,15 +31,15 @@ public function getErrorList($testFile='') case 'EndFileNewlineUnitTest.3.inc': case 'EndFileNewlineUnitTest.3.js': case 'EndFileNewlineUnitTest.3.css': - return array(2 => 1); + return [2 => 1]; case 'EndFileNewlineUnitTest.4.inc': // HHVM just removes the entire comment token, as if it was never there. if (defined('HHVM_VERSION') === true) { - return array(); + return []; } - return array(2 => 1); + return [2 => 1]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -57,7 +57,7 @@ public function getErrorList($testFile='') */ public function getWarningList($testFile='') { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index 013158850f..852e824bdd 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -32,24 +32,24 @@ public function getErrorList($testFile='') case 'EndFileNoNewlineUnitTest.1.css': case 'EndFileNoNewlineUnitTest.1.js': case 'EndFileNoNewlineUnitTest.2.inc': - return array(3 => 1); + return [3 => 1]; case 'EndFileNoNewlineUnitTest.2.css': case 'EndFileNoNewlineUnitTest.2.js': - return array(2 => 1); + return [2 => 1]; case 'EndFileNoNewlineUnitTest.5.inc': // HHVM just removes the entire comment token, as if it was never there. if (defined('HHVM_VERSION') === true) { - return array(1 => 1); + return [1 => 1]; } - return array(); + return []; case 'EndFileNoNewlineUnitTest.6.inc': // HHVM just removes the entire comment token, as if it was never there. if (defined('HHVM_VERSION') === true) { - return array(1 => 1); + return [1 => 1]; } - return array(2 => 1); + return [2 => 1]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -67,7 +67,7 @@ public function getErrorList($testFile='') */ public function getWarningList($testFile='') { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php index 6bb5c59adb..16d9458752 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php @@ -29,13 +29,13 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'InlineHTMLUnitTest.3.inc': - return array(4 => 1); + return [4 => 1]; break; case 'InlineHTMLUnitTest.4.inc': - return array(1 => 1); + return [1 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -54,7 +54,7 @@ public function getErrorList($testFile='') */ public function getWarningList($testFile='') { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php index e73e3f36d1..772d4c4a56 100644 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php @@ -40,7 +40,7 @@ public function setCliValues($testFile, $config) */ public function getErrorList() { - return array(1 => 1); + return [1 => 1]; }//end getErrorList() @@ -55,7 +55,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index 34bc0b1cb2..66d337e697 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -44,18 +44,18 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'LineLengthUnitTest.1.inc': - return array( - 31 => 1, - 34 => 1, - 45 => 1, - ); + return [ + 31 => 1, + 34 => 1, + 45 => 1, + ]; break; case 'LineLengthUnitTest.2.inc': case 'LineLengthUnitTest.3.inc': - return array(7 => 1); + return [7 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -76,27 +76,27 @@ public function getWarningList($testFile='') { switch ($testFile) { case 'LineLengthUnitTest.1.inc': - return array( - 9 => 1, - 15 => 1, - 21 => 1, - 24 => 1, - 29 => 1, - 37 => 1, - 63 => 1, - 73 => 1, - 75 => 1, - ); + return [ + 9 => 1, + 15 => 1, + 21 => 1, + 24 => 1, + 29 => 1, + 37 => 1, + 63 => 1, + 73 => 1, + 75 => 1, + ]; break; case 'LineLengthUnitTest.2.inc': case 'LineLengthUnitTest.3.inc': - return array(6 => 1); + return [6 => 1]; break; case 'LineLengthUnitTest.4.inc': - return array(10 => 1); + return [10 => 1]; break; default: - return array(); + return []; break; }//end switch diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index 781db1e3ce..4b4bc97427 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -25,7 +25,7 @@ class LowercasedFilenameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(1 => 1); + return [1 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php index 24502c352c..42a962284e 100644 --- a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php @@ -25,10 +25,10 @@ class OneClassPerFileUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 10 => 1, - ); + return [ + 6 => 1, + 10 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php index e86174a77f..f083178793 100644 --- a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php @@ -25,10 +25,10 @@ class OneInterfacePerFileUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 10 => 1, - ); + return [ + 6 => 1, + 10 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php index 7592676e29..f429f98095 100644 --- a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php @@ -25,12 +25,12 @@ class OneObjectStructurePerFileUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 10 => 1, - 14 => 1, - 18 => 1, - ); + return [ + 6 => 1, + 10 => 1, + 14 => 1, + 18 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php index a124ebcbf0..75b0dbc3f5 100644 --- a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php @@ -37,10 +37,10 @@ protected function shouldSkipTest() */ public function getErrorList() { - return array( - 6 => 1, - 10 => 1, - ); + return [ + 6 => 1, + 10 => 1, + ]; }//end getErrorList() @@ -55,7 +55,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php index 54eb10791e..62bc9a078e 100644 --- a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php @@ -25,12 +25,12 @@ class DisallowMultipleStatementsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 6 => 1, - 7 => 1, - 8 => 2, - ); + return [ + 2 => 1, + 6 => 1, + 7 => 1, + 8 => 2, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index 71aa577427..1804960241 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -25,7 +25,7 @@ class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -44,73 +44,73 @@ public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc { switch ($testFile) { case 'MultipleStatementAlignmentUnitTest.inc': - return array( - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 51 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 86 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 95 => 1, - 123 => 1, - 124 => 1, - 126 => 1, - 129 => 1, - 154 => 1, - 161 => 1, - 178 => 1, - 179 => 1, - 182 => 1, - 206 => 1, - 207 => 1, - ); + return [ + 11 => 1, + 12 => 1, + 23 => 1, + 24 => 1, + 26 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 50 => 1, + 51 => 1, + 61 => 1, + 62 => 1, + 64 => 1, + 65 => 1, + 71 => 1, + 78 => 1, + 79 => 1, + 86 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 95 => 1, + 123 => 1, + 124 => 1, + 126 => 1, + 129 => 1, + 154 => 1, + 161 => 1, + 178 => 1, + 179 => 1, + 182 => 1, + 206 => 1, + 207 => 1, + ]; break; case 'MultipleStatementAlignmentUnitTest.js': - return array( - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 51 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 81 => 1, - 82 => 1, - 83 => 1, - 85 => 1, - 86 => 1, - 100 => 1, - ); + return [ + 11 => 1, + 12 => 1, + 23 => 1, + 24 => 1, + 26 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 50 => 1, + 51 => 1, + 61 => 1, + 62 => 1, + 64 => 1, + 65 => 1, + 71 => 1, + 78 => 1, + 79 => 1, + 81 => 1, + 82 => 1, + 83 => 1, + 85 => 1, + 86 => 1, + 100 => 1, + ]; break; default: - return array(); + return []; break; }//end switch diff --git a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php index af89922de1..e93a792ad4 100644 --- a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php @@ -25,30 +25,30 @@ class NoSpaceAfterCastUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 7 => 1, - 9 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 21 => 1, - 23 => 1, - 25 => 1, - 27 => 1, - 29 => 1, - 31 => 1, - 33 => 1, - 35 => 1, - 37 => 1, - 39 => 1, - 41 => 1, - 43 => 1, - 45 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 7 => 1, + 9 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 21 => 1, + 23 => 1, + 25 => 1, + 27 => 1, + 29 => 1, + 31 => 1, + 33 => 1, + 35 => 1, + 37 => 1, + 39 => 1, + 41 => 1, + 43 => 1, + 45 => 1, + ]; }//end getErrorList() @@ -63,7 +63,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php index cec57b6e43..ac4a3564f0 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php @@ -25,30 +25,30 @@ class SpaceAfterCastUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 5 => 1, - 8 => 1, - 9 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 17 => 1, - 20 => 1, - 21 => 1, - 24 => 1, - 25 => 1, - 28 => 1, - 29 => 1, - 32 => 1, - 33 => 1, - 36 => 1, - 37 => 1, - 40 => 1, - 41 => 1, - 44 => 1, - 45 => 1, - ); + return [ + 4 => 1, + 5 => 1, + 8 => 1, + 9 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 17 => 1, + 20 => 1, + 21 => 1, + 24 => 1, + 25 => 1, + 28 => 1, + 29 => 1, + 32 => 1, + 33 => 1, + 36 => 1, + 37 => 1, + 40 => 1, + 41 => 1, + 44 => 1, + 45 => 1, + ]; }//end getErrorList() @@ -63,7 +63,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index 485ba302e2..25fd576ac7 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -25,11 +25,11 @@ class SpaceAfterNotUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 2, - 4 => 2, - 5 => 1, - ); + return [ + 2 => 2, + 4 => 2, + 5 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php index 3778f2366e..1c10c99fac 100644 --- a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php @@ -25,14 +25,14 @@ class CallTimePassByReferenceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 2, - 23 => 1, - 30 => 1, - ); + return [ + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 2, + 23 => 1, + 30 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index e5c9d9ef75..ab6cd8d2d3 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -25,29 +25,29 @@ class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 6 => 1, - 7 => 2, - 8 => 1, - 11 => 2, - 12 => 2, - 13 => 3, - 42 => 3, - 43 => 3, - 45 => 1, - 46 => 2, - 79 => 1, - 82 => 1, - 93 => 1, - 105 => 1, - 107 => 1, - 108 => 2, - 114 => 1, - 115 => 1, - 119 => 1, - 125 => 2, - ); + return [ + 5 => 1, + 6 => 1, + 7 => 2, + 8 => 1, + 11 => 2, + 12 => 2, + 13 => 3, + 42 => 3, + 43 => 3, + 45 => 1, + 46 => 2, + 79 => 1, + 82 => 1, + 93 => 1, + 105 => 1, + 107 => 1, + 108 => 2, + 114 => 1, + 115 => 1, + 119 => 1, + 125 => 2, + ]; }//end getErrorList() @@ -62,7 +62,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php index 44fba0dbf4..0f6b5f1ade 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php @@ -25,33 +25,33 @@ class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 13 => 1, - 19 => 1, - 24 => 1, - 30 => 1, - 40 => 1, - 44 => 1, - 50 => 1, - 55 => 1, - 67 => 1, - 78 => 1, - 85 => 1, - 91 => 1, - 98 => 1, - 110 => 1, - 115 => 1, - 122 => 1, - 128 => 1, - 155 => 1, - 158 => 1, - 164 => 1, - 168 => 1, - 172 => 1, - 176 => 1, - 196 => 1, - ); + return [ + 4 => 1, + 13 => 1, + 19 => 1, + 24 => 1, + 30 => 1, + 40 => 1, + 44 => 1, + 50 => 1, + 55 => 1, + 67 => 1, + 78 => 1, + 85 => 1, + 91 => 1, + 98 => 1, + 110 => 1, + 115 => 1, + 122 => 1, + 128 => 1, + 155 => 1, + 158 => 1, + 164 => 1, + 168 => 1, + 172 => 1, + 176 => 1, + 196 => 1, + ]; }//end getErrorList() @@ -66,7 +66,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 045a15c034..05b0893d73 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -25,30 +25,30 @@ class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 13 => 1, - 17 => 1, - 29 => 1, - 33 => 1, - 37 => 1, - 53 => 1, - 58 => 1, - 63 => 1, - 77 => 1, - 82 => 1, - 87 => 1, - 104 => 1, - 119 => 1, - 123 => 1, - 127 => 1, - 132 => 1, - 137 => 1, - 142 => 1, - 153 => 1, - 158 => 1, - 167 => 1, - ); + return [ + 9 => 1, + 13 => 1, + 17 => 1, + 29 => 1, + 33 => 1, + 37 => 1, + 53 => 1, + 58 => 1, + 63 => 1, + 77 => 1, + 82 => 1, + 87 => 1, + 104 => 1, + 119 => 1, + 123 => 1, + 127 => 1, + 132 => 1, + 137 => 1, + 142 => 1, + 153 => 1, + 158 => 1, + 167 => 1, + ]; }//end getErrorList() @@ -63,7 +63,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index 993048a6a6..e8099317cd 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -25,7 +25,7 @@ class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(116 => 1); + return [116 => 1]; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 45 => 1, - 72 => 1, - ); + return [ + 45 => 1, + 72 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php index 2c1a7c3550..ccd7550763 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php @@ -25,7 +25,7 @@ class NestingLevelUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(73 => 1); + return [73 => 1]; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 27 => 1, - 46 => 1, - ); + return [ + 27 => 1, + 46 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php index 5a9d94353c..e0de85de15 100644 --- a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php @@ -25,44 +25,44 @@ class CamelCapsFunctionNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - $errors = array( - 10 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 17 => 1, - 20 => 1, - 21 => 1, - 24 => 1, - 25 => 1, - 30 => 1, - 31 => 1, - 50 => 1, - 52 => 1, - 53 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 60 => 1, - 61 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 65 => 1, - 66 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 71 => 1, - 72 => 1, - 73 => 1, - 74 => 1, - 118 => 1, - 144 => 1, - 146 => 1, - 147 => 1, - ); + $errors = [ + 10 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 17 => 1, + 20 => 1, + 21 => 1, + 24 => 1, + 25 => 1, + 30 => 1, + 31 => 1, + 50 => 1, + 52 => 1, + 53 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 74 => 1, + 118 => 1, + 144 => 1, + 146 => 1, + 147 => 1, + ]; return $errors; @@ -79,7 +79,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php index 28f380276c..527a2cfc0b 100644 --- a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php @@ -25,12 +25,12 @@ class ConstructorNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 11 => 1, - 47 => 1, - 62 => 1, - ); + return [ + 6 => 1, + 11 => 1, + 47 => 1, + 62 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 2c5b187ed7..a9a72022bb 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -25,13 +25,13 @@ class UpperCaseConstantNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 8 => 1, - 10 => 1, - 12 => 1, - 14 => 1, - 19 => 1, - ); + return [ + 8 => 1, + 10 => 1, + 12 => 1, + 14 => 1, + 19 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php index bc3135a737..a2541851d7 100644 --- a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php @@ -25,7 +25,7 @@ class BacktickOperatorUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(2 => 2); + return [2 => 2]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php index 061d631c26..11f4f14dad 100644 --- a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php @@ -29,10 +29,10 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'CharacterBeforePHPOpeningTagUnitTest.1.inc': - return array(2 => 1); + return [2 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -49,7 +49,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php index db9badcf81..bcadc38655 100644 --- a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php @@ -25,7 +25,7 @@ class ClosingPHPTagUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(9 => 1); + return [9 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php index db3683b9fa..6313c6511a 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php @@ -24,7 +24,7 @@ class DisallowAlternativePHPTagsUnitTest extends AbstractSniffUnitTest */ protected function getTestFiles($testFileBase) { - $testFiles = array($testFileBase.'1.inc'); + $testFiles = [$testFileBase.'1.inc']; $aspTags = false; if (PHP_VERSION_ID < 70000) { @@ -66,21 +66,21 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'DisallowAlternativePHPTagsUnitTest.1.inc': - return array( - 4 => 1, - 7 => 1, - 8 => 1, - 11 => 1, - ); + return [ + 4 => 1, + 7 => 1, + 8 => 1, + 11 => 1, + ]; case 'DisallowAlternativePHPTagsUnitTest.2.inc': - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + ]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -96,7 +96,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index a20a50bd43..d9cb7ca83e 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -24,7 +24,7 @@ class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest */ protected function getTestFiles($testFileBase) { - $testFiles = array($testFileBase.'1.inc'); + $testFiles = [$testFileBase.'1.inc']; $option = (boolean) ini_get('short_open_tag'); if ($option === true || defined('HHVM_VERSION') === true) { @@ -56,24 +56,24 @@ public function getErrorList($testFile='') $option = (boolean) ini_get('short_open_tag'); if ($option === false) { // Short open tags are off and PHP isn't doing short echo by default. - return array(); + return []; } } - return array( - 5 => 1, - 6 => 1, - 7 => 1, - 10 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 7 => 1, + 10 => 1, + ]; case 'DisallowShortOpenTagUnitTest.2.inc': - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 7 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 7 => 1, + ]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -97,23 +97,23 @@ public function getWarningList($testFile='') $option = (boolean) ini_get('short_open_tag'); if ($option === false) { // Short open tags are off and PHP isn't doing short echo by default. - return array( - 5 => 1, - 6 => 1, - 7 => 1, - 10 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 7 => 1, + 10 => 1, + ]; } } - return array(); + return []; case 'DisallowShortOpenTagUnitTest.3.inc': - return array( - 3 => 1, - 6 => 1, - 11 => 1, - ); + return [ + 3 => 1, + 6 => 1, + 11 => 1, + ]; default: - return array(); + return []; }//end switch }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php index f7dafddc98..c1f82d61b7 100644 --- a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php @@ -25,7 +25,7 @@ class DiscourageGotoUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,12 +40,12 @@ public function getErrorList() */ public function getWarningList() { - return array( - 3 => 1, - 6 => 1, - 11 => 1, - 16 => 1, - ); + return [ + 3 => 1, + 6 => 1, + 11 => 1, + 16 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php index 52a4578516..760e807868 100644 --- a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php @@ -25,11 +25,11 @@ class ForbiddenFunctionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - $errors = array( - 2 => 1, - 4 => 1, - 6 => 1, - ); + $errors = [ + 2 => 1, + 4 => 1, + 6 => 1, + ]; return $errors; @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 749470dfeb..85e8f7011d 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -29,37 +29,37 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc') { switch ($testFile) { case 'LowerCaseConstantUnitTest.inc': - return array( - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 1, - 70 => 1, - 71 => 1, - ); + return [ + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 1, + 70 => 1, + 71 => 1, + ]; break; case 'LowerCaseConstantUnitTest.js': - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 7 => 1, - 8 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 7 => 1, + 8 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -76,7 +76,7 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php index e2204517a9..ca976b94d0 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php @@ -25,20 +25,20 @@ class LowerCaseKeywordUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 10 => 3, - 11 => 4, - 12 => 1, - 13 => 3, - 14 => 7, - 15 => 1, - 16 => 1, - 19 => 1, - 20 => 1, - 21 => 1, - 25 => 1, - 28 => 1, - ); + return [ + 10 => 3, + 11 => 4, + 12 => 1, + 13 => 3, + 14 => 7, + 15 => 1, + 16 => 1, + 19 => 1, + 20 => 1, + 21 => 1, + 25 => 1, + 28 => 1, + ]; }//end getErrorList() @@ -53,7 +53,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php index fb61d414d3..40b509bced 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -25,7 +25,7 @@ class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(5 => 1); + return [5 => 1]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php index 287db68726..08c0ccdcfb 100644 --- a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php @@ -25,7 +25,7 @@ class SAPIUsageUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(2 => 1); + return [2 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php index 3f434f6c5d..973ada7951 100644 --- a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php @@ -48,7 +48,7 @@ protected function shouldSkipTest() */ public function getErrorList() { - return array(3 => 1); + return [3 => 1]; }//end getErrorList() @@ -63,7 +63,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php index 81d7826cf3..0bdafe6a43 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php @@ -25,22 +25,22 @@ class UpperCaseConstantUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 1, - 70 => 1, - 71 => 1, - ); + return [ + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 1, + 70 => 1, + 71 => 1, + ]; }//end getErrorList() @@ -55,7 +55,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index 58d83fb1b0..6a9284822c 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -29,26 +29,26 @@ public function getErrorList($testFile='UnnecessaryStringConcatUnitTest.inc') { switch ($testFile) { case 'UnnecessaryStringConcatUnitTest.inc': - return array( - 2 => 1, - 6 => 1, - 9 => 1, - 12 => 1, - 19 => 1, - 20 => 1, - ); + return [ + 2 => 1, + 6 => 1, + 9 => 1, + 12 => 1, + 19 => 1, + 20 => 1, + ]; break; case 'UnnecessaryStringConcatUnitTest.js': - return array( - 1 => 1, - 8 => 1, - 11 => 1, - 14 => 1, - 15 => 1, - ); + return [ + 1 => 1, + 8 => 1, + 11 => 1, + 14 => 1, + 15 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -65,7 +65,7 @@ public function getErrorList($testFile='UnnecessaryStringConcatUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index e6a23b75ed..c66b953503 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -29,39 +29,39 @@ public function getErrorList($testFile='DisallowSpaceIndentUnitTest.inc') { switch ($testFile) { case 'DisallowSpaceIndentUnitTest.inc': - return array( - 5 => 1, - 9 => 1, - 15 => 1, - 22 => 1, - 24 => 1, - 30 => 1, - 35 => 1, - 50 => 1, - 55 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 60 => 1, - 65 => 1, - 66 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 73 => 1, - 77 => 1, - 81 => 1, - ); + return [ + 5 => 1, + 9 => 1, + 15 => 1, + 22 => 1, + 24 => 1, + 30 => 1, + 35 => 1, + 50 => 1, + 55 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 65 => 1, + 66 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 73 => 1, + 77 => 1, + 81 => 1, + ]; break; case 'DisallowSpaceIndentUnitTest.js': - return array(3 => 1); + return [3 => 1]; break; case 'DisallowSpaceIndentUnitTest.css': - return array(2 => 1); + return [2 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -78,7 +78,7 @@ public function getErrorList($testFile='DisallowSpaceIndentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 61be34536f..732a680556 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -44,43 +44,43 @@ public function getErrorList($testFile='DisallowTabIndentUnitTest.inc') { switch ($testFile) { case 'DisallowTabIndentUnitTest.inc': - return array( - 5 => 2, - 9 => 1, - 15 => 1, - 20 => 2, - 21 => 1, - 22 => 2, - 23 => 1, - 24 => 2, - 31 => 1, - 32 => 2, - 33 => 2, - 41 => 1, - 42 => 1, - 43 => 1, - 44 => 1, - 45 => 1, - 46 => 1, - 47 => 1, - 48 => 1, - ); + return [ + 5 => 2, + 9 => 1, + 15 => 1, + 20 => 2, + 21 => 1, + 22 => 2, + 23 => 1, + 24 => 2, + 31 => 1, + 32 => 2, + 33 => 2, + 41 => 1, + 42 => 1, + 43 => 1, + 44 => 1, + 45 => 1, + 46 => 1, + 47 => 1, + 48 => 1, + ]; break; case 'DisallowTabIndentUnitTest.js': - return array( - 3 => 1, - 5 => 1, - 6 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 6 => 1, + ]; break; case 'DisallowTabIndentUnitTest.css': - return array( - 1 => 1, - 2 => 1, - ); + return [ + 1 => 1, + 2 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -97,7 +97,7 @@ public function getErrorList($testFile='DisallowTabIndentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 45ec2fa9e7..3e74175d0b 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -48,109 +48,109 @@ public function setCliValues($testFile, $config) public function getErrorList($testFile='ScopeIndentUnitTest.inc') { if ($testFile === 'ScopeIndentUnitTest.1.js') { - return array( - 6 => 1, - 14 => 1, - 21 => 1, - 30 => 1, - 32 => 1, - 33 => 1, - 34 => 1, - 39 => 1, - 42 => 1, - 59 => 1, - 60 => 1, - 75 => 1, - 120 => 1, - 121 => 1, - 122 => 1, - 123 => 1, - 141 => 1, - 142 => 1, - 155 => 1, - 156 => 1, - 168 => 1, - 184 => 1, - ); + return [ + 6 => 1, + 14 => 1, + 21 => 1, + 30 => 1, + 32 => 1, + 33 => 1, + 34 => 1, + 39 => 1, + 42 => 1, + 59 => 1, + 60 => 1, + 75 => 1, + 120 => 1, + 121 => 1, + 122 => 1, + 123 => 1, + 141 => 1, + 142 => 1, + 155 => 1, + 156 => 1, + 168 => 1, + 184 => 1, + ]; }//end if if ($testFile === 'ScopeIndentUnitTest.3.inc') { - return array( - 6 => 1, - 7 => 1, - 10 => 1, - ); + return [ + 6 => 1, + 7 => 1, + 10 => 1, + ]; } - return array( - 7 => 1, - 10 => 1, - 13 => 1, - 17 => 1, - 20 => 1, - 24 => 1, - 25 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 58 => 1, - 123 => 1, - 224 => 1, - 225 => 1, - 279 => 1, - 280 => 1, - 281 => 1, - 282 => 1, - 283 => 1, - 284 => 1, - 285 => 1, - 286 => 1, - 336 => 1, - 349 => 1, - 380 => 1, - 386 => 1, - 387 => 1, - 388 => 1, - 389 => 1, - 390 => 1, - 397 => 1, - 419 => 1, - 420 => 1, - 465 => 1, - 467 => 1, - 472 => 1, - 473 => 1, - 474 => 1, - 496 => 1, - 498 => 1, - 500 => 1, - 524 => 1, - 526 => 1, - 544 => 1, - 545 => 1, - 546 => 1, - 639 => 1, - 660 => 1, - 662 => 1, - 802 => 1, - 803 => 1, - 823 => 1, - 858 => 1, - 879 => 1, - 1163 => 1, - 1197 => 1, - 1198 => 1, - 1243 => 1, - 1247 => 1, - 1252 => 1, - 1254 => 1, - 1257 => 1, - 1261 => 1, - 1262 => 1, - 1263 => 1, - 1264 => 1, - ); + return [ + 7 => 1, + 10 => 1, + 13 => 1, + 17 => 1, + 20 => 1, + 24 => 1, + 25 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 58 => 1, + 123 => 1, + 224 => 1, + 225 => 1, + 279 => 1, + 280 => 1, + 281 => 1, + 282 => 1, + 283 => 1, + 284 => 1, + 285 => 1, + 286 => 1, + 336 => 1, + 349 => 1, + 380 => 1, + 386 => 1, + 387 => 1, + 388 => 1, + 389 => 1, + 390 => 1, + 397 => 1, + 419 => 1, + 420 => 1, + 465 => 1, + 467 => 1, + 472 => 1, + 473 => 1, + 474 => 1, + 496 => 1, + 498 => 1, + 500 => 1, + 524 => 1, + 526 => 1, + 544 => 1, + 545 => 1, + 546 => 1, + 639 => 1, + 660 => 1, + 662 => 1, + 802 => 1, + 803 => 1, + 823 => 1, + 858 => 1, + 879 => 1, + 1163 => 1, + 1197 => 1, + 1198 => 1, + 1243 => 1, + 1247 => 1, + 1252 => 1, + 1254 => 1, + 1257 => 1, + 1261 => 1, + 1262 => 1, + 1263 => 1, + 1264 => 1, + ]; }//end getErrorList() @@ -165,7 +165,7 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php index d885957938..1ad68f38c3 100644 --- a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php +++ b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php @@ -20,7 +20,7 @@ class BrowserSpecificStylesSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** * A list of specific stylesheet suffixes we allow. @@ -31,13 +31,13 @@ class BrowserSpecificStylesSniff implements Sniff * * @var array */ - protected $specificStylesheets = array( - 'moz' => true, - 'ie' => true, - 'ie7' => true, - 'ie8' => true, - 'webkit' => true, - ); + protected $specificStylesheets = [ + 'moz' => true, + 'ie' => true, + 'ie7' => true, + 'ie8' => true, + 'webkit' => true, + ]; /** @@ -47,7 +47,7 @@ class BrowserSpecificStylesSniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() diff --git a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php index 4554d60ad0..be22dd2b26 100644 --- a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php @@ -24,7 +24,7 @@ class DisallowSelfActionsSniff implements Sniff */ public function register() { - return array(T_CLASS); + return [T_CLASS]; }//end register() @@ -55,8 +55,8 @@ public function process(File $phpcsFile, $stackPtr) return; } - $foundFunctions = array(); - $foundCalls = array(); + $foundFunctions = []; + $foundCalls = []; // Find all static method calls in the form self::method() in the class. $classEnd = $tokens[$stackPtr]['scope_closer']; @@ -95,10 +95,10 @@ public function process(File $phpcsFile, $stackPtr) continue; } - $foundCalls[$i] = array( - 'name' => $funcName, - 'type' => strtolower($tokens[$prevToken]['content']), - ); + $foundCalls[$i] = [ + 'name' => $funcName, + 'type' => strtolower($tokens[$prevToken]['content']), + ]; }//end for $errorClassName = substr($className, 0, -7); @@ -111,10 +111,10 @@ public function process(File $phpcsFile, $stackPtr) } else if ($foundFunctions[$funcData['name']] === 'public') { $type = $funcData['type']; $error = "Static calls to public methods in Action classes must not use the $type keyword; use %s::%s() instead"; - $data = array( - $errorClassName, - $funcName, - ); + $data = [ + $errorClassName, + $funcName, + ]; $phpcsFile->addError($error, $token, 'Found'.ucfirst($funcData['type']), $data); } } diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php index c1af6b13ed..2d56261cf3 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php @@ -23,7 +23,7 @@ class IncludeOwnSystemSniff implements Sniff */ public function register() { - return array(T_DOUBLE_COLON); + return [T_DOUBLE_COLON]; }//end register() @@ -40,7 +40,7 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $fileName = $phpcsFile->getFilename(); - $matches = array(); + $matches = []; if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|i', $fileName, $matches) === 0) { // Not an actions file. return; @@ -67,7 +67,7 @@ public function process(File $phpcsFile, $stackPtr) if ($included === strtolower($ownClass)) { $error = "You do not need to include \"%s\" from within the system's own actions file"; - $data = array($ownClass); + $data = [$ownClass]; $phpcsFile->addError($error, $stackPtr, 'NotRequired', $data); } diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php index ee9330a4f6..57ba49fc7c 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php @@ -21,24 +21,24 @@ class IncludeSystemSniff extends AbstractScopeSniff * * @var string[] */ - private $ignore = array( - 'self' => true, - 'static' => true, - 'parent' => true, - 'channels' => true, - 'basesystem' => true, - 'dal' => true, - 'init' => true, - 'pdo' => true, - 'util' => true, - 'ziparchive' => true, - 'phpunit_framework_assert' => true, - 'abstractmysourceunittest' => true, - 'abstractdatacleanunittest' => true, - 'exception' => true, - 'abstractwidgetwidgettype' => true, - 'domdocument' => true, - ); + private $ignore = [ + 'self' => true, + 'static' => true, + 'parent' => true, + 'channels' => true, + 'basesystem' => true, + 'dal' => true, + 'init' => true, + 'pdo' => true, + 'util' => true, + 'ziparchive' => true, + 'phpunit_framework_assert' => true, + 'abstractmysourceunittest' => true, + 'abstractdatacleanunittest' => true, + 'exception' => true, + 'abstractwidgetwidgettype' => true, + 'domdocument' => true, + ]; /** @@ -46,7 +46,7 @@ class IncludeSystemSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_FUNCTION), array(T_DOUBLE_COLON, T_EXTENDS), true); + parent::__construct([T_FUNCTION], [T_DOUBLE_COLON, T_EXTENDS], true); }//end __construct() @@ -84,10 +84,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop return; } - $includedClasses = array(); + $includedClasses = []; $fileName = strtolower($phpcsFile->getFilename()); - $matches = array(); + $matches = []; if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { // This is an actions file, which means we don't // have to include the system in which it exists. @@ -185,7 +185,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if (isset($includedClasses[strtolower($className)]) === false) { $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); + $data = [$className]; $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); } @@ -226,10 +226,10 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) return; } - $includedClasses = array(); + $includedClasses = []; $fileName = strtolower($phpcsFile->getFilename()); - $matches = array(); + $matches = []; if (preg_match('|/systems/([^/]+)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { // This is an actions file, which means we don't // have to include the system in which it exists @@ -266,11 +266,11 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) if (isset($includedClasses[strtolower($className)]) === false) { if ($tokens[$stackPtr]['code'] === T_EXTENDS) { $error = 'Class extends non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); + $data = [$className]; $phpcsFile->addError($error, $stackPtr, 'NotIncludedExtends', $data); } else { $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); + $data = [$className]; $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); } } diff --git a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php index 75161efa49..6b10cd3ede 100644 --- a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php @@ -23,7 +23,7 @@ class UnusedSystemSniff implements Sniff */ public function register() { - return array(T_DOUBLE_COLON); + return [T_DOUBLE_COLON]; }//end register() @@ -116,7 +116,7 @@ public function process(File $phpcsFile, $stackPtr) } break; case T_IMPLEMENTS: - $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1)); + $endImplements = $phpcsFile->findNext([T_EXTENDS, T_OPEN_CURLY_BRACKET], ($i + 1)); for ($x = ($i + 1); $x < $endImplements; $x++) { if ($tokens[$x]['code'] === T_STRING) { $className = strtolower($tokens[$x]['content']); @@ -132,7 +132,7 @@ public function process(File $phpcsFile, $stackPtr) // If we get to here, the system was not use. $error = 'Included system "%s" is never used'; - $data = array($systemName); + $data = [$systemName]; $phpcsFile->addError($error, $stackPtr, 'Found', $data); }//end process() diff --git a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php index 5d27ca2728..fd75bcb22e 100644 --- a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php @@ -55,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr) $hasApiTag = true; // There needs to be a blank line before the @api tag. - $prev = $phpcsFile->findPrevious(array(T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG), ($tag - 1)); + $prev = $phpcsFile->findPrevious([T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], ($tag - 1)); if ($tokens[$prev]['line'] !== ($tokens[$tag]['line'] - 2)) { $error = 'There must be one blank line before the @api tag in a function comment'; $phpcsFile->addError($error, $tag, 'ApiSpacing'); @@ -63,10 +63,10 @@ public function process(File $phpcsFile, $stackPtr) } else if (substr($tokens[$tag]['content'], 0, 5) === '@api-') { $hasApiTag = true; - $prev = $phpcsFile->findPrevious(array(T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG), ($tag - 1)); + $prev = $phpcsFile->findPrevious([T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], ($tag - 1)); if ($tokens[$prev]['line'] !== ($tokens[$tag]['line'] - 1)) { $error = 'There must be no blank line before the @%s tag in a function comment'; - $data = array($tokens[$tag]['content']); + $data = [$tokens[$tag]['content']]; $phpcsFile->addError($error, $tag, 'ApiTagSpacing', $data); } }//end if diff --git a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php index ff9d4363bb..eccf6fe4b4 100644 --- a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php @@ -23,7 +23,7 @@ class DebugCodeSniff implements Sniff */ public function register() { - return array(T_DOUBLE_COLON); + return [T_DOUBLE_COLON]; }//end register() @@ -45,7 +45,7 @@ public function process(File $phpcsFile, $stackPtr) if (strtolower($tokens[$className]['content']) === 'debug') { $method = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); $error = 'Call to debug function Debug::%s() must be removed'; - $data = array($tokens[$method]['content']); + $data = [$tokens[$method]['content']]; $phpcsFile->addError($error, $stackPtr, 'Found', $data); } diff --git a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php index 740040e5ff..3115bac4ec 100644 --- a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php @@ -20,7 +20,7 @@ class FirebugConsoleSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -30,12 +30,12 @@ class FirebugConsoleSniff implements Sniff */ public function register() { - return array( - T_STRING, - T_PROPERTY, - T_LABEL, - T_OBJECT, - ); + return [ + T_STRING, + T_PROPERTY, + T_LABEL, + T_OBJECT, + ]; }//end register() diff --git a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php index c7d34bf0ff..0a3c9cf21f 100644 --- a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php @@ -20,7 +20,7 @@ class AssignThisSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -30,7 +30,7 @@ class AssignThisSniff implements Sniff */ public function register() { - return array(T_THIS); + return [T_THIS]; }//end register() diff --git a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php index 90a6813691..55bddb273c 100644 --- a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php @@ -21,7 +21,7 @@ class CreateWidgetTypeCallbackSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -31,7 +31,7 @@ class CreateWidgetTypeCallbackSniff implements Sniff */ public function register() { - return array(T_OBJECT); + return [T_OBJECT]; }//end register() @@ -60,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $function = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($create + 1), null, true); + $function = $phpcsFile->findNext([T_WHITESPACE, T_COLON], ($create + 1), null, true); if ($tokens[$function]['code'] !== T_FUNCTION && $tokens[$function]['code'] !== T_CLOSURE ) { diff --git a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php index 18dacedf05..cae7c08d93 100644 --- a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php @@ -23,7 +23,7 @@ class DisallowNewWidgetSniff implements Sniff */ public function register() { - return array(T_NEW); + return [T_NEW]; }//end register() @@ -49,7 +49,7 @@ public function process(File $phpcsFile, $stackPtr) if (substr(strtolower($tokens[$className]['content']), -10) === 'widgettype') { $widgetType = substr($tokens[$className]['content'], 0, -10); $error = 'Manual creation of widget objects is banned; use Widget::getWidget(\'%s\'); instead'; - $data = array($widgetType); + $data = [$widgetType]; $phpcsFile->addError($error, $stackPtr, 'Found', $data); } diff --git a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php index 8959a7d625..f86fa9aef2 100644 --- a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php @@ -26,7 +26,7 @@ class AjaxNullComparisonSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -54,7 +54,7 @@ public function process(File $phpcsFile, $stackPtr) // Find all the vars passed in as we are only interested in comparisons // to NULL for these specific variables. - $foundVars = array(); + $foundVars = []; $open = $tokens[$stackPtr]['parenthesis_opener']; $close = $tokens[$stackPtr]['parenthesis_closer']; for ($i = ($open + 1); $i < $close; $i++) { diff --git a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php index 59e7fa2b98..39e9c3c226 100644 --- a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php +++ b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php @@ -24,7 +24,7 @@ class EvalObjectFactorySniff implements Sniff */ public function register() { - return array(T_EVAL); + return [T_EVAL]; }//end register() @@ -50,8 +50,8 @@ public function process(File $phpcsFile, $stackPtr) $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1)); $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - $strings = array(); - $vars = array(); + $strings = []; + $vars = []; for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) { diff --git a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php index 91d217ceb0..82419fcb89 100644 --- a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php @@ -23,7 +23,7 @@ class GetRequestDataSniff implements Sniff */ public function register() { - return array(T_VARIABLE); + return [T_VARIABLE]; }//end register() @@ -89,7 +89,7 @@ public function process(File $phpcsFile, $stackPtr) $type = 'SuperglobalAccessed'; $error = 'The %s super global must not be accessed directly; use Security::getRequestData('; - $data = array($varName); + $data = [$varName]; if ($usedVar !== '') { $type .= 'WithVar'; $error .= '%s, \'%s\''; diff --git a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php index c07ae1adfb..9b2029af41 100644 --- a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php @@ -23,7 +23,7 @@ class ReturnFunctionValueSniff implements Sniff */ public function register() { - return array(T_RETURN); + return [T_RETURN]; }//end register() diff --git a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php index b21e9b2bd5..311cf684fd 100644 --- a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php +++ b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php @@ -21,7 +21,7 @@ class JoinStringsSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -31,7 +31,7 @@ class JoinStringsSniff implements Sniff */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() diff --git a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php index 6ac2b04d54..2135349988 100644 --- a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php +++ b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php @@ -25,7 +25,7 @@ class BrowserSpecificStylesUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(5 => 1); + return [5 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php index 15a96fcf94..d29bf5c6cd 100644 --- a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php @@ -25,12 +25,12 @@ class DisallowSelfActionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 12 => 1, - 13 => 1, - 28 => 1, - 29 => 1, - ); + return [ + 12 => 1, + 13 => 1, + 28 => 1, + 29 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php index 77fcafcb60..0320038ec6 100644 --- a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php @@ -25,19 +25,19 @@ class IncludeSystemUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 14 => 1, - 24 => 1, - 27 => 1, - 28 => 1, - 31 => 1, - 36 => 1, - 41 => 1, - 61 => 1, - 70 => 1, - 89 => 1, - ); + return [ + 9 => 1, + 14 => 1, + 24 => 1, + 27 => 1, + 28 => 1, + 31 => 1, + 36 => 1, + 41 => 1, + 61 => 1, + 70 => 1, + 89 => 1, + ]; }//end getErrorList() @@ -52,7 +52,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php index aa8c419252..fbc0ac70b9 100644 --- a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php @@ -25,14 +25,14 @@ class UnusedSystemUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 5 => 1, - 8 => 1, - 24 => 1, - 34 => 1, - 54 => 1, - ); + return [ + 2 => 1, + 5 => 1, + 8 => 1, + 24 => 1, + 34 => 1, + 54 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php index 6d2ea09b0e..5cc43b6447 100644 --- a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php @@ -25,13 +25,13 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 28 => 1, - 36 => 1, - 37 => 2, - 49 => 1, - 58 => 1, - ); + return [ + 28 => 1, + 36 => 1, + 37 => 2, + 49 => 1, + 58 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php index 77d1066de2..78da9c94fe 100644 --- a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php @@ -25,10 +25,10 @@ class DebugCodeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - ); + return [ + 2 => 1, + 3 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php index 1cd41025bd..3a9c235845 100644 --- a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php @@ -28,17 +28,17 @@ class FirebugConsoleUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='FirebugConsoleUnitTest.js') { if ($testFile !== 'FirebugConsoleUnitTest.js') { - return array(); + return []; } - return array( - 1 => 1, - 2 => 1, - 3 => 1, - 5 => 1, - 6 => 1, - 8 => 1, - ); + return [ + 1 => 1, + 2 => 1, + 3 => 1, + 5 => 1, + 6 => 1, + 8 => 1, + ]; }//end getErrorList() @@ -53,7 +53,7 @@ public function getErrorList($testFile='FirebugConsoleUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php index cc6fff1832..f28dff191d 100644 --- a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php @@ -28,14 +28,14 @@ class AssignThisUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='AssignThisUnitTest.js') { if ($testFile !== 'AssignThisUnitTest.js') { - return array(); + return []; } - return array( - 7 => 1, - 11 => 1, - 16 => 1, - ); + return [ + 7 => 1, + 11 => 1, + 16 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList($testFile='AssignThisUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php index 15564855d5..a3c55bf367 100644 --- a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php @@ -27,16 +27,16 @@ class CreateWidgetTypeCallbackUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='CreateWidgetTypeCallbackUnitTest.js') { - return array( - 18 => 1, - 23 => 2, - 26 => 1, - 30 => 1, - 34 => 1, - 43 => 2, - 91 => 1, - 123 => 1, - ); + return [ + 18 => 1, + 23 => 2, + 26 => 1, + 30 => 1, + 34 => 1, + 43 => 2, + 91 => 1, + 123 => 1, + ]; }//end getErrorList() @@ -51,7 +51,7 @@ public function getErrorList($testFile='CreateWidgetTypeCallbackUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php index 16e8cfc178..333952f6c8 100644 --- a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php @@ -25,7 +25,7 @@ class DisallowNewWidgetUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(4 => 1); + return [4 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php index 3ba70d291d..a8900676bb 100644 --- a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php @@ -25,7 +25,7 @@ class AjaxNullComparisonUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,14 +40,14 @@ public function getErrorList() */ public function getWarningList() { - return array( - 37 => 1, - 49 => 1, - 60 => 1, - 73 => 1, - 88 => 1, - 118 => 1, - ); + return [ + 37 => 1, + 49 => 1, + 60 => 1, + 73 => 1, + 88 => 1, + 118 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php index 4395845dee..423f242d9f 100644 --- a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php @@ -25,7 +25,7 @@ class EvalObjectFactoryUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 4 => 1, - 12 => 1, - 21 => 1, - ); + return [ + 4 => 1, + 12 => 1, + 21 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php index 8ea89b16dd..16e4cfb277 100644 --- a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php @@ -25,15 +25,15 @@ class GetRequestDataUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 5 => 1, - 8 => 1, - 21 => 1, - 26 => 1, - 27 => 1, - 28 => 1, - ); + return [ + 2 => 1, + 5 => 1, + 8 => 1, + 21 => 1, + 26 => 1, + 27 => 1, + 28 => 1, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php index 8ed23923ab..3236378686 100644 --- a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php @@ -25,7 +25,7 @@ class ReturnFunctionValueUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 2 => 1, - 3 => 1, - 4 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php index cad315c245..ecd490a433 100644 --- a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php +++ b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php @@ -28,18 +28,18 @@ class JoinStringsUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='JoinStringsUnitTest.js') { if ($testFile !== 'JoinStringsUnitTest.js') { - return array(); + return []; } - return array( - 6 => 1, - 7 => 1, - 8 => 2, - 9 => 2, - 10 => 2, - 12 => 2, - 15 => 1, - ); + return [ + 6 => 1, + 7 => 1, + 8 => 2, + 9 => 2, + 10 => 2, + 12 => 2, + 15 => 1, + ]; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList($testFile='JoinStringsUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php index e22d9b977e..b7926dc1f8 100644 --- a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php @@ -23,11 +23,11 @@ class ClassDeclarationSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -44,7 +44,7 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $errorData = array(strtolower($tokens[$stackPtr]['content'])); + $errorData = [strtolower($tokens[$stackPtr]['content'])]; if (isset($tokens[$stackPtr]['scope_opener']) === false) { $error = 'Possible parse error: %s missing opening or closing brace'; @@ -76,11 +76,11 @@ public function process(File $phpcsFile, $stackPtr) if ($braceLine > ($classLine + 1)) { $error = 'Opening brace of a %s must be on the line following the %s declaration; found %s line(s)'; - $data = array( - $tokens[$stackPtr]['content'], - $tokens[$stackPtr]['content'], - ($braceLine - $classLine - 1), - ); + $data = [ + $tokens[$stackPtr]['content'], + $tokens[$stackPtr]['content'], + ($braceLine - $classLine - 1), + ]; $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); @@ -120,10 +120,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = ($tokens[$first]['column'] - 1); if ($spaces !== $expected) { $error = 'Expected %s spaces before opening brace; %s found'; - $data = array( - $expected, - $spaces, - ); + $data = [ + $expected, + $spaces, + ]; $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'SpaceBeforeBrace', $data); if ($fix === true) { diff --git a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php index 0bd39bb3f6..92ce3e9ea5 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php @@ -23,11 +23,11 @@ class ClassCommentSniff extends FileCommentSniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -47,7 +47,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $type = strtolower($tokens[$stackPtr]['content']); - $errorData = array($type); + $errorData = [$type]; $find = Tokens::$methodPrefixes; $find[] = T_WHITESPACE; @@ -94,7 +94,7 @@ protected function processVersion($phpcsFile, array $tags) $content = $tokens[($tag + 2)]['content']; if ((strstr($content, 'Release:') === false)) { $error = 'Invalid version "%s" in doc comment; consider "Release: " instead'; - $data = array($content); + $data = [$content]; $phpcsFile->addWarning($error, $tag, 'InvalidVersion', $data); } } diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 74f3ef8eaf..f5e0a8c407 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -21,52 +21,52 @@ class FileCommentSniff implements Sniff * * @var array */ - protected $tags = array( - '@category' => array( - 'required' => true, - 'allow_multiple' => false, - ), - '@package' => array( - 'required' => true, - 'allow_multiple' => false, - ), - '@subpackage' => array( - 'required' => false, - 'allow_multiple' => false, - ), - '@author' => array( - 'required' => true, - 'allow_multiple' => true, - ), - '@copyright' => array( - 'required' => false, - 'allow_multiple' => true, - ), - '@license' => array( - 'required' => true, - 'allow_multiple' => false, - ), - '@version' => array( - 'required' => false, - 'allow_multiple' => false, - ), - '@link' => array( - 'required' => true, - 'allow_multiple' => true, - ), - '@see' => array( - 'required' => false, - 'allow_multiple' => true, - ), - '@since' => array( - 'required' => false, - 'allow_multiple' => false, - ), - '@deprecated' => array( - 'required' => false, - 'allow_multiple' => false, - ), - ); + protected $tags = [ + '@category' => [ + 'required' => true, + 'allow_multiple' => false, + ], + '@package' => [ + 'required' => true, + 'allow_multiple' => false, + ], + '@subpackage' => [ + 'required' => false, + 'allow_multiple' => false, + ], + '@author' => [ + 'required' => true, + 'allow_multiple' => true, + ], + '@copyright' => [ + 'required' => false, + 'allow_multiple' => true, + ], + '@license' => [ + 'required' => true, + 'allow_multiple' => false, + ], + '@version' => [ + 'required' => false, + 'allow_multiple' => false, + ], + '@link' => [ + 'required' => true, + 'allow_multiple' => true, + ], + '@see' => [ + 'required' => false, + 'allow_multiple' => true, + ], + '@since' => [ + 'required' => false, + 'allow_multiple' => false, + ], + '@deprecated' => [ + 'required' => false, + 'allow_multiple' => false, + ], + ]; /** @@ -76,7 +76,7 @@ class FileCommentSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -145,21 +145,21 @@ public function process(File $phpcsFile, $stackPtr) true ); - $ignore = array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_FUNCTION, - T_CLOSURE, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_FINAL, - T_STATIC, - T_ABSTRACT, - T_CONST, - T_PROPERTY, - ); + $ignore = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + T_CLOSURE, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_FINAL, + T_STATIC, + T_ABSTRACT, + T_CONST, + T_PROPERTY, + ]; if (in_array($tokens[$nextToken]['code'], $ignore) === true) { $phpcsFile->addError('Missing file doc comment', $stackPtr, 'Missing'); @@ -218,8 +218,8 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) $commentEnd = $tokens[$commentStart]['comment_closer']; - $foundTags = array(); - $tagTokens = array(); + $foundTags = []; + $tagTokens = []; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { $name = $tokens[$tag]['content']; if (isset($this->tags[$name]) === false) { @@ -228,10 +228,10 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) if ($this->tags[$name]['allow_multiple'] === false && isset($tagTokens[$name]) === true) { $error = 'Only one %s tag is allowed in a %s comment'; - $data = array( - $name, - $docBlock, - ); + $data = [ + $name, + $docBlock, + ]; $phpcsFile->addError($error, $tag, 'Duplicate'.ucfirst(substr($name, 1)).'Tag', $data); } @@ -241,10 +241,10 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd); if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) { $error = 'Content missing for %s tag in %s comment'; - $data = array( - $name, - $docBlock, - ); + $data = [ + $name, + $docBlock, + ]; $phpcsFile->addError($error, $tag, 'Empty'.ucfirst(substr($name, 1)).'Tag', $data); continue; } @@ -256,10 +256,10 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) if (isset($tagTokens[$tag]) === false) { if ($tagData['required'] === true) { $error = 'Missing %s tag in %s comment'; - $data = array( - $tag, - $docBlock, - ); + $data = [ + $tag, + $docBlock, + ]; $phpcsFile->addError($error, $commentEnd, 'Missing'.ucfirst(substr($tag, 1)).'Tag', $data); } @@ -268,7 +268,7 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) $method = 'process'.substr($tag, 1); if (method_exists($this, $method) === true) { // Process each tag if a method is defined. - call_user_func(array($this, $method), $phpcsFile, $tagTokens[$tag]); + call_user_func([$this, $method], $phpcsFile, $tagTokens[$tag]); } } @@ -278,10 +278,10 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) if ($foundTags[$pos] !== $tag) { $error = 'The tag in position %s should be the %s tag'; - $data = array( - ($pos + 1), - $tag, - ); + $data = [ + ($pos + 1), + $tag, + ]; $phpcsFile->addError($error, $tokens[$commentStart]['comment_tags'][$pos], ucfirst(substr($tag, 1)).'TagOrder', $data); } @@ -326,10 +326,10 @@ protected function processCategory($phpcsFile, array $tags) $error = 'Category name "%s" is not valid; consider "%s" instead'; $validName = trim($newName, '_'); - $data = array( - $content, - $validName, - ); + $data = [ + $content, + $validName, + ]; $phpcsFile->addError($error, $tag, 'InvalidCategory', $data); } }//end foreach @@ -365,7 +365,7 @@ protected function processPackage($phpcsFile, array $tags) if ($newContent === '') { $error = 'Package name "%s" is not valid'; - $data = array($content); + $data = [$content]; $phpcsFile->addError($error, $tag, 'InvalidPackageValue', $data); } else { $nameBits = explode('_', $newContent); @@ -379,10 +379,10 @@ protected function processPackage($phpcsFile, array $tags) $error = 'Package name "%s" is not valid; consider "%s" instead'; $validName = trim($newName, '_'); - $data = array( - $content, - $validName, - ); + $data = [ + $content, + $validName, + ]; $phpcsFile->addError($error, $tag, 'InvalidPackage', $data); }//end if }//end foreach @@ -424,10 +424,10 @@ protected function processSubpackage($phpcsFile, array $tags) $error = 'Subpackage name "%s" is not valid; consider "%s" instead'; $validName = trim($newName, '_'); - $data = array( - $content, - $validName, - ); + $data = [ + $content, + $validName, + ]; $phpcsFile->addError($error, $tag, 'InvalidSubpackage', $data); }//end foreach @@ -482,7 +482,7 @@ protected function processCopyright($phpcsFile, array $tags) } $content = $tokens[($tag + 2)]['content']; - $matches = array(); + $matches = []; if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) { // Check earliest-latest year order. if ($matches[3] !== '' && $matches[3] !== null) { @@ -523,7 +523,7 @@ protected function processLicense($phpcsFile, array $tags) } $content = $tokens[($tag + 2)]['content']; - $matches = array(); + $matches = []; preg_match('/^([^\s]+)\s+(.*)/', $content, $matches); if (count($matches) !== 3) { $error = '@license tag must contain a URL and a license name'; @@ -558,7 +558,7 @@ protected function processVersion($phpcsFile, array $tags) && strstr($content, 'HG:') === false ) { $error = 'Invalid version "%s" in file comment; consider "CVS: " or "SVN: " or "GIT: " or "HG: " instead'; - $data = array($content); + $data = [$content]; $phpcsFile->addWarning($error, $tag, 'InvalidVersion', $data); } } diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index f35eefc4ce..4b52a9e516 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -24,7 +24,7 @@ class FunctionCommentSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -158,7 +158,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); - $throws = array(); + $throws = []; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { if ($tokens[$tag]['content'] !== '@throws') { continue; @@ -167,7 +167,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) $exception = null; $comment = null; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = []; preg_match('/([^\s]+)(?:\s+(.*))?/', $tokens[($tag + 2)]['content'], $matches); $exception = $matches[1]; if (isset($matches[2]) === true) { @@ -198,7 +198,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); - $params = array(); + $params = []; $maxType = 0; $maxVar = 0; foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) { @@ -212,10 +212,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $varSpace = 0; $comment = ''; $commentEnd = 0; - $commentTokens = array(); + $commentTokens = []; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = []; preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches); if (empty($matches) === false) { @@ -266,20 +266,20 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $phpcsFile->addError($error, $tag, 'MissingParamType'); }//end if - $params[] = array( - 'tag' => $tag, - 'type' => $type, - 'var' => $var, - 'comment' => $comment, - 'comment_end' => $commentEnd, - 'comment_tokens' => $commentTokens, - 'type_space' => $typeSpace, - 'var_space' => $varSpace, - ); + $params[] = [ + 'tag' => $tag, + 'type' => $type, + 'var' => $var, + 'comment' => $comment, + 'comment_end' => $commentEnd, + 'comment_tokens' => $commentTokens, + 'type_space' => $typeSpace, + 'var_space' => $varSpace, + ]; }//end foreach $realParams = $phpcsFile->getMethodParameters($stackPtr); - $foundParams = array(); + $foundParams = []; // We want to use ... for all variable length arguments, so add // this prefix to the variable name so comparisons are easier. @@ -300,10 +300,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $spaces = ($maxType - strlen($param['type']) + 1); if ($param['type_space'] !== $spaces) { $error = 'Expected %s spaces after parameter type; %s found'; - $data = array( - $spaces, - $param['type_space'], - ); + $data = [ + $spaces, + $param['type_space'], + ]; $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data); if ($fix === true) { @@ -341,10 +341,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $realName = $realParams[$pos]['name']; if ($realName !== $param['var']) { $code = 'ParamNameNoMatch'; - $data = array( - $param['var'], - $realName, - ); + $data = [ + $param['var'], + $realName, + ]; $error = 'Doc comment for parameter %s does not match '; if (strtolower($param['var']) === strtolower($realName)) { @@ -370,10 +370,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $spaces = ($maxVar - strlen($param['var']) + 1); if ($param['var_space'] !== $spaces) { $error = 'Expected %s spaces after parameter name; %s found'; - $data = array( - $spaces, - $param['var_space'], - ); + $data = [ + $spaces, + $param['var_space'], + ]; $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data); if ($fix === true) { @@ -426,10 +426,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } $error = 'Parameter comment not aligned correctly; expected %s spaces but found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $commentToken, 'ParamCommentAlignment', $data); if ($fix === true) { $padding = str_repeat(' ', $expected); @@ -443,7 +443,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) }//end if }//end foreach - $realNames = array(); + $realNames = []; foreach ($realParams as $realParam) { $realNames[] = $realParam['name']; } @@ -452,7 +452,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $diff = array_diff($realNames, $foundParams); foreach ($diff as $neededParam) { $error = 'Doc comment for parameter "%s" missing'; - $data = array($neededParam); + $data = [$neededParam]; $phpcsFile->addError($error, $commentStart, 'MissingParamTag', $data); } diff --git a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php index 0bd1a34c29..47fd3dfd4f 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php @@ -23,7 +23,7 @@ class InlineCommentSniff implements Sniff */ public function register() { - return array(T_COMMENT); + return [T_COMMENT]; }//end register() diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php index 0afb63c963..5724592c69 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -29,17 +29,17 @@ class ControlSignatureSniff extends AbstractPatternSniff */ protected function getPatterns() { - return array( - 'do {EOL...} while (...);EOL', - 'while (...) {EOL', - 'for (...) {EOL', - 'if (...) {EOL', - 'foreach (...) {EOL', - '} else if (...) {EOL', - '} elseif (...) {EOL', - '} else {EOL', - 'do {EOL', - ); + return [ + 'do {EOL...} while (...);EOL', + 'while (...) {EOL', + 'for (...) {EOL', + 'if (...) {EOL', + 'foreach (...) {EOL', + '} else if (...) {EOL', + '} elseif (...) {EOL', + '} else {EOL', + 'do {EOL', + ]; }//end getPatterns() diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index f6f6655cca..45e4f3b168 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -21,10 +21,10 @@ class MultiLineConditionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The number of spaces code should be indented. @@ -41,10 +41,10 @@ class MultiLineConditionSniff implements Sniff */ public function register() { - return array( - T_IF, - T_ELSEIF, - ); + return [ + T_IF, + T_ELSEIF, + ]; }//end register() @@ -158,10 +158,10 @@ public function process(File $phpcsFile, $stackPtr) if ($expectedIndent !== $foundIndent) { $error = 'Multi-line IF statement not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $i, 'Alignment', $data); if ($fix === true) { @@ -241,7 +241,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $data = array($length); + $data = [$length]; $code = 'SpaceBeforeOpenBrace'; $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement; found '; diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index 6833f0fec9..cda11e4ae6 100644 --- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -26,12 +26,12 @@ class IncludingFileSniff implements Sniff */ public function register() { - return array( - T_INCLUDE_ONCE, - T_REQUIRE_ONCE, - T_REQUIRE, - T_INCLUDE, - ); + return [ + T_INCLUDE_ONCE, + T_REQUIRE_ONCE, + T_REQUIRE, + T_INCLUDE, + ]; }//end register() @@ -52,7 +52,7 @@ public function process(File $phpcsFile, $stackPtr) $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) { $error = '"%s" is a statement not a function; no parentheses are required'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); diff --git a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php index 99f6dc3f97..9ecea94a9e 100644 --- a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -30,7 +30,7 @@ class MultiLineAssignmentSniff implements Sniff */ public function register() { - return array(T_EQUAL); + return [T_EQUAL]; }//end register() @@ -93,10 +93,10 @@ public function process(File $phpcsFile, $stackPtr) $foundIndent = strlen($tokens[$prev]['content']); if ($foundIndent !== $expectedIndent) { $error = 'Multi-line assignment not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $phpcsFile->addError($error, $stackPtr, 'Indent', $data); } diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index ecaaf8be51..aa7b662a49 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -21,10 +21,10 @@ class FunctionCallSignatureSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The number of spaces code should be indented. @@ -235,10 +235,10 @@ public function processSingleLineCall(File $phpcsFile, $stackPtr, $openBracket, if ($spaceAfterOpen !== $requiredSpacesAfterOpen) { $error = 'Expected %s spaces after opening bracket; %s found'; - $data = array( - $requiredSpacesAfterOpen, - $spaceAfterOpen, - ); + $data = [ + $requiredSpacesAfterOpen, + $spaceAfterOpen, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterOpenBracket', $data); if ($fix === true) { $padding = str_repeat(' ', $requiredSpacesAfterOpen); @@ -267,10 +267,10 @@ public function processSingleLineCall(File $phpcsFile, $stackPtr, $openBracket, if ($spaceBeforeClose !== $requiredSpacesBeforeClose) { $error = 'Expected %s spaces before closing bracket; %s found'; - $data = array( - $requiredSpacesBeforeClose, - $spaceBeforeClose, - ); + $data = [ + $requiredSpacesBeforeClose, + $spaceBeforeClose, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeCloseBracket', $data); if ($fix === true) { $padding = str_repeat(' ', $requiredSpacesBeforeClose); @@ -339,7 +339,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ // call itself is, so we can work out how far to // indent the arguments. $start = $phpcsFile->findStartOfStatement($stackPtr); - foreach (array('stackPtr', 'start') as $checkToken) { + foreach (['stackPtr', 'start'] as $checkToken) { $x = $$checkToken; for ($i = ($x - 1); $i >= 0; $i--) { if ($tokens[$i]['line'] !== $tokens[$x]['line']) { @@ -505,10 +505,10 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ && $expectedIndent !== $foundIndent) ) { $error = 'Multi-line function call not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $i, 'Indent', $data); if ($fix === true) { @@ -538,7 +538,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ // If we are within an argument we should be ignoring commas // as these are not signaling the end of an argument. if ($inArg === false && $tokens[$i]['code'] === T_COMMA) { - $next = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($i + 1), $closeBracket, true); + $next = $phpcsFile->findNext([T_WHITESPACE, T_COMMENT], ($i + 1), $closeBracket, true); if ($next === false) { continue; } diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index a287d1aa25..f18360888e 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -23,10 +23,10 @@ class FunctionDeclarationSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The number of spaces code should be indented. @@ -43,10 +43,10 @@ class FunctionDeclarationSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -87,7 +87,7 @@ public function process(File $phpcsFile, $stackPtr) if ($spaces !== 1) { $error = 'Expected 1 space after FUNCTION keyword; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterFunction', $data); if ($fix === true) { if ($spaces === 0) { @@ -113,7 +113,7 @@ public function process(File $phpcsFile, $stackPtr) if ($spaces !== 0) { $error = 'Expected 0 spaces before opening parenthesis; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $openBracket, 'SpaceBeforeOpenParen', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($openBracket - 1), ''); @@ -135,7 +135,7 @@ public function process(File $phpcsFile, $stackPtr) if ($length !== 1) { $error = 'Expected 1 space after USE keyword; found %s'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $use, 'SpaceAfterUse', $data); if ($fix === true) { if ($length === 0) { @@ -156,7 +156,7 @@ public function process(File $phpcsFile, $stackPtr) if ($length !== 1) { $error = 'Expected 1 space before USE keyword; found %s'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $use, 'SpaceBeforeUse', $data); if ($fix === true) { if ($length === 0) { @@ -355,10 +355,10 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) if ($expectedIndent !== $foundIndent) { $error = 'Multi-line function declaration not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $i, 'Indent', $data); if ($fix === true) { @@ -435,7 +435,7 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) if ($length !== 1) { $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found %s spaces'; - $fix = $phpcsFile->addFixableError($error, ($opener - 1), 'SpaceBeforeOpenBrace', array($length)); + $fix = $phpcsFile->addFixableError($error, ($opener - 1), 'SpaceBeforeOpenBrace', [$length]); if ($fix === true) { if ($length === 0) { $phpcsFile->fixer->addContentBefore($opener, ' '); diff --git a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php index cfe24c5035..085f5db255 100644 --- a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php @@ -24,10 +24,10 @@ class ValidDefaultValueSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php index a0f27b4b54..2ee79bf869 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -23,11 +23,11 @@ class ValidClassNameSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -47,7 +47,7 @@ public function process(File $phpcsFile, $stackPtr) $className = $phpcsFile->findNext(T_STRING, $stackPtr); $name = trim($tokens[$className]['content']); - $errorData = array(ucfirst($tokens[$stackPtr]['content'])); + $errorData = [ucfirst($tokens[$stackPtr]['content'])]; // Make sure the first letter is a capital. if (preg_match('|^[A-Z]|', $name) === 0) { diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 3a67e0dfc2..2d9902263f 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -22,30 +22,30 @@ class ValidFunctionNameSniff extends AbstractScopeSniff * * @var array */ - protected $magicMethods = array( - 'construct' => true, - 'destruct' => true, - 'call' => true, - 'callstatic' => true, - 'get' => true, - 'set' => true, - 'isset' => true, - 'unset' => true, - 'sleep' => true, - 'wakeup' => true, - 'tostring' => true, - 'set_state' => true, - 'clone' => true, - 'invoke' => true, - 'debuginfo' => true, - ); + protected $magicMethods = [ + 'construct' => true, + 'destruct' => true, + 'call' => true, + 'callstatic' => true, + 'get' => true, + 'set' => true, + 'isset' => true, + 'unset' => true, + 'sleep' => true, + 'wakeup' => true, + 'tostring' => true, + 'set_state' => true, + 'clone' => true, + 'invoke' => true, + 'debuginfo' => true, + ]; /** * A list of all PHP magic functions. * * @var array */ - protected $magicFunctions = array('autoload' => true); + protected $magicFunctions = ['autoload' => true]; /** @@ -53,7 +53,7 @@ class ValidFunctionNameSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(Tokens::$ooScopeTokens, array(T_FUNCTION), true); + parent::__construct(Tokens::$ooScopeTokens, [T_FUNCTION], true); }//end __construct() @@ -77,7 +77,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop } $className = $phpcsFile->getDeclarationName($currScope); - $errorData = array($className.'::'.$methodName); + $errorData = [$className.'::'.$methodName]; // Is this a magic method. i.e., is prefixed with "__" ? if (preg_match('|^__[^_]|', $methodName) !== 0) { @@ -125,10 +125,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop // If it's not a private method, it must not have an underscore on the front. if ($isPublic === true && $scopeSpecified === true && $methodName{0} === '_') { $error = '%s method name "%s" must not be prefixed with an underscore'; - $data = array( - ucfirst($scope), - $errorData[0], - ); + $data = [ + ucfirst($scope), + $errorData[0], + ]; $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); return; } @@ -146,10 +146,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if (Common::isCamelCaps($testMethodName, false, $isPublic, false) === false) { if ($scopeSpecified === true) { $error = '%s method name "%s" is not in camel caps format'; - $data = array( - ucfirst($scope), - $errorData[0], - ); + $data = [ + ucfirst($scope), + $errorData[0], + ]; $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); } else { $error = 'Method name "%s" is not in camel caps format'; @@ -184,7 +184,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) return; } - $errorData = array($functionName); + $errorData = [$functionName]; // Is this a magic function. i.e., it is prefixed with "__". if (preg_match('|^__[^_]|', $functionName) !== 0) { diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php index 850798e348..26d25ae9ce 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -47,7 +47,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) // If it's a private member, it must have an underscore on the front. if ($isPublic === false && $memberName{0} !== '_') { $error = 'Private member variable "%s" must be prefixed with an underscore'; - $data = array($memberName); + $data = [$memberName]; $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); return; } @@ -55,10 +55,10 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) // If it's not a private member, it must not have an underscore on the front. if ($isPublic === true && $scopeSpecified === true && $memberName{0} === '_') { $error = '%s member variable "%s" must not be prefixed with an underscore'; - $data = array( - ucfirst($scope), - $memberName, - ); + $data = [ + ucfirst($scope), + $memberName, + ]; $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); return; } diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index 34721a5d0f..b59fdeadc8 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -30,7 +30,7 @@ class ObjectOperatorIndentSniff implements Sniff */ public function register() { - return array(T_OBJECT_OPERATOR); + return [T_OBJECT_OPERATOR]; }//end register() @@ -129,10 +129,10 @@ public function process(File $phpcsFile, $stackPtr) if ($foundIndent !== $requiredIndent) { $error = 'Object operator not indented correctly; expected %s spaces but found %s'; - $data = array( - $requiredIndent, - $foundIndent, - ); + $data = [ + $requiredIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $next, 'Incorrect', $data); if ($fix === true) { diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index d43fc922a1..ae44c8425e 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -94,11 +94,11 @@ public function process(File $phpcsFile, $stackPtr) // Check that the closing brace is on it's own line. $lastContent = $phpcsFile->findPrevious( - array( - T_WHITESPACE, - T_INLINE_HTML, - T_OPEN_TAG, - ), + [ + T_WHITESPACE, + T_INLINE_HTML, + T_OPEN_TAG, + ], ($scopeEnd - 1), $scopeStart, true @@ -145,20 +145,20 @@ public function process(File $phpcsFile, $stackPtr) $expectedIndent = ($startColumn + $this->indent - 1); if ($braceIndent !== $expectedIndent) { $error = 'Case breaking statement indented incorrectly; expected %s spaces, found %s'; - $data = array( - $expectedIndent, - $braceIndent, - ); + $data = [ + $expectedIndent, + $braceIndent, + ]; $fix = $phpcsFile->addFixableError($error, $scopeEnd, 'BreakIndent', $data); } } else { $expectedIndent = max(0, ($startColumn - 1)); if ($braceIndent !== $expectedIndent) { $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - $expectedIndent, - $braceIndent, - ); + $data = [ + $expectedIndent, + $braceIndent, + ]; $fix = $phpcsFile->addFixableError($error, $scopeEnd, 'Indent', $data); } }//end if diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php index fcc1d9888a..2620d20f2e 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -19,6 +19,6 @@ class ScopeIndentSniff extends GenericScopeIndentSniff * * @var int[] */ - protected $nonIndentingScopes = array(T_SWITCH); + protected $nonIndentingScopes = [T_SWITCH]; }//end class diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index bb10947c12..fd20c233c6 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -25,15 +25,15 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 21 => 1, - 22 => 1, - 23 => 1, - 27 => 1, - 33 => 1, - 38 => 1, - 49 => 1, - ); + return [ + 21 => 1, + 22 => 1, + 23 => 1, + 27 => 1, + 33 => 1, + 38 => 1, + 49 => 1, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php index c6cf1fbffa..9a4bcf7dd6 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php @@ -25,26 +25,26 @@ class ClassCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 15 => 1, - 51 => 1, - 63 => 1, - 65 => 2, - 66 => 1, - 68 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - 74 => 2, - 75 => 1, - 76 => 1, - 77 => 1, - 85 => 1, - 96 => 5, - 106 => 5, - 116 => 5, - ); + return [ + 4 => 1, + 15 => 1, + 51 => 1, + 63 => 1, + 65 => 2, + 66 => 1, + 68 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + 74 => 2, + 75 => 1, + 76 => 1, + 77 => 1, + 85 => 1, + 96 => 5, + 106 => 5, + 116 => 5, + ]; }//end getErrorList() @@ -59,10 +59,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 71 => 1, - 73 => 1, - ); + return [ + 71 => 1, + 73 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index e8aa666ed3..edb40b2760 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -25,23 +25,23 @@ class FileCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 21 => 1, - 23 => 2, - 24 => 1, - 26 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 32 => 2, - 33 => 1, - 34 => 1, - 35 => 1, - 40 => 2, - 41 => 2, - 42 => 1, - ); + return [ + 21 => 1, + 23 => 2, + 24 => 1, + 26 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 32 => 2, + 33 => 1, + 34 => 1, + 35 => 1, + 40 => 2, + 41 => 2, + 42 => 1, + ]; }//end getErrorList() @@ -56,12 +56,12 @@ public function getErrorList() */ public function getWarningList() { - return array( - 29 => 1, - 30 => 1, - 34 => 1, - 42 => 1, - ); + return [ + 29 => 1, + 30 => 1, + 34 => 1, + 42 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php index ab1864b7c0..cf755c8196 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php @@ -25,51 +25,51 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 10 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 28 => 1, - 76 => 1, - 87 => 1, - 103 => 1, - 109 => 1, - 112 => 1, - 122 => 1, - 123 => 2, - 124 => 2, - 125 => 1, - 126 => 1, - 137 => 1, - 138 => 1, - 139 => 1, - 152 => 1, - 155 => 1, - 165 => 1, - 172 => 1, - 183 => 1, - 190 => 2, - 206 => 1, - 234 => 1, - 272 => 1, - 313 => 1, - 317 => 1, - 324 => 1, - 327 => 1, - 329 => 1, - 332 => 1, - 344 => 1, - 343 => 1, - 345 => 1, - 346 => 1, - 360 => 1, - 361 => 1, - 363 => 1, - 364 => 1, - ); + return [ + 5 => 1, + 10 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 28 => 1, + 76 => 1, + 87 => 1, + 103 => 1, + 109 => 1, + 112 => 1, + 122 => 1, + 123 => 2, + 124 => 2, + 125 => 1, + 126 => 1, + 137 => 1, + 138 => 1, + 139 => 1, + 152 => 1, + 155 => 1, + 165 => 1, + 172 => 1, + 183 => 1, + 190 => 2, + 206 => 1, + 234 => 1, + 272 => 1, + 313 => 1, + 317 => 1, + 324 => 1, + 327 => 1, + 329 => 1, + 332 => 1, + 344 => 1, + 343 => 1, + 345 => 1, + 346 => 1, + 360 => 1, + 361 => 1, + 363 => 1, + 364 => 1, + ]; }//end getErrorList() @@ -84,7 +84,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php index 5dfce60495..6cc5cd3b5a 100644 --- a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php @@ -25,14 +25,14 @@ class InlineCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 15 => 1, - 24 => 1, - 25 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - ); + return [ + 15 => 1, + 24 => 1, + 25 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php index c62e426822..5cb267672b 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -25,30 +25,30 @@ class ControlSignatureUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 14 => 1, - 20 => 1, - 22 => 1, - 32 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 56 => 1, - 60 => 1, - 68 => 1, - 72 => 1, - 84 => 1, - 88 => 2, - 100 => 1, - 104 => 2, - 122 => 2, - 128 => 1, - 132 => 3, - 133 => 2, - 147 => 1, - 157 => 1, - ); + return [ + 9 => 1, + 14 => 1, + 20 => 1, + 22 => 1, + 32 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 56 => 1, + 60 => 1, + 68 => 1, + 72 => 1, + 84 => 1, + 88 => 2, + 100 => 1, + 104 => 2, + 122 => 2, + 128 => 1, + 132 => 3, + 133 => 2, + 147 => 1, + 157 => 1, + ]; }//end getErrorList() @@ -63,7 +63,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index 2a65b9a02f..bbc17a5e9a 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -27,34 +27,34 @@ class MultiLineConditionUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='MultiLineConditionUnitTest.inc') { - $errors = array( - 21 => 1, - 22 => 1, - 35 => 1, - 40 => 1, - 41 => 1, - 42 => 1, - 43 => 1, - 49 => 1, - 54 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 67 => 1, - 87 => 1, - 88 => 1, - 89 => 1, - 90 => 1, - 96 => 2, - 101 => 1, - 109 => 2, - 125 => 1, - 145 => 2, - 153 => 2, - 168 => 1, - 177 => 1, - ); + $errors = [ + 21 => 1, + 22 => 1, + 35 => 1, + 40 => 1, + 41 => 1, + 42 => 1, + 43 => 1, + 49 => 1, + 54 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 61 => 1, + 67 => 1, + 87 => 1, + 88 => 1, + 89 => 1, + 90 => 1, + 96 => 2, + 101 => 1, + 109 => 2, + 125 => 1, + 145 => 2, + 153 => 2, + 168 => 1, + 177 => 1, + ]; if ($testFile === 'MultiLineConditionUnitTest.inc') { $errors[183] = 1; @@ -75,7 +75,7 @@ public function getErrorList($testFile='MultiLineConditionUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php index 254598bcad..ab3ea8acec 100644 --- a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php +++ b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php @@ -25,26 +25,26 @@ class IncludingFileUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 5 => 1, - 11 => 1, - 12 => 1, - 16 => 1, - 17 => 1, - 33 => 1, - 34 => 1, - 47 => 1, - 48 => 1, - 64 => 1, - 65 => 1, - 73 => 1, - 74 => 1, - 85 => 1, - 86 => 1, - 98 => 1, - 99 => 2, - ); + return [ + 4 => 1, + 5 => 1, + 11 => 1, + 12 => 1, + 16 => 1, + 17 => 1, + 33 => 1, + 34 => 1, + 47 => 1, + 48 => 1, + 64 => 1, + 65 => 1, + 73 => 1, + 74 => 1, + 85 => 1, + 86 => 1, + 98 => 1, + 99 => 2, + ]; }//end getErrorList() @@ -59,7 +59,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php index 9213eae32d..734d4fce8d 100644 --- a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php +++ b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php @@ -25,11 +25,11 @@ class MultiLineAssignmentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 6 => 1, - 8 => 1, - ); + return [ + 3 => 1, + 6 => 1, + 8 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index fdc79372e7..6230a126cc 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -28,78 +28,78 @@ class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') { if ($testFile === 'FunctionCallSignatureUnitTest.js') { - return array( - 5 => 1, - 6 => 2, - 7 => 1, - 8 => 1, - 9 => 2, - 10 => 3, - 17 => 1, - 18 => 1, - 21 => 1, - 24 => 1, - 28 => 2, - 30 => 2, - 35 => 1, - 49 => 1, - 51 => 1, - 54 => 1, - 70 => 1, - 71 => 1, - ); + return [ + 5 => 1, + 6 => 2, + 7 => 1, + 8 => 1, + 9 => 2, + 10 => 3, + 17 => 1, + 18 => 1, + 21 => 1, + 24 => 1, + 28 => 2, + 30 => 2, + 35 => 1, + 49 => 1, + 51 => 1, + 54 => 1, + 70 => 1, + 71 => 1, + ]; }//end if - return array( - 5 => 1, - 6 => 2, - 7 => 1, - 8 => 1, - 9 => 2, - 10 => 3, - 17 => 1, - 18 => 1, - 31 => 1, - 34 => 1, - 43 => 2, - 57 => 1, - 59 => 1, - 63 => 1, - 64 => 1, - 82 => 1, - 93 => 1, - 100 => 1, - 106 => 2, - 119 => 1, - 120 => 1, - 129 => 1, - 137 => 1, - 142 => 2, - 171 => 1, - 180 => 1, - 181 => 1, - 194 => 1, - 213 => 2, - 215 => 2, - 217 => 2, - 218 => 2, - 277 => 1, - 278 => 1, - 303 => 1, - 308 => 1, - 321 => 1, - 322 => 1, - 329 => 1, - 330 => 1, - 337 => 1, - 342 => 1, - 343 => 1, - 345 => 1, - 346 => 2, - 353 => 1, - 354 => 1, - 355 => 2, - ); + return [ + 5 => 1, + 6 => 2, + 7 => 1, + 8 => 1, + 9 => 2, + 10 => 3, + 17 => 1, + 18 => 1, + 31 => 1, + 34 => 1, + 43 => 2, + 57 => 1, + 59 => 1, + 63 => 1, + 64 => 1, + 82 => 1, + 93 => 1, + 100 => 1, + 106 => 2, + 119 => 1, + 120 => 1, + 129 => 1, + 137 => 1, + 142 => 2, + 171 => 1, + 180 => 1, + 181 => 1, + 194 => 1, + 213 => 2, + 215 => 2, + 217 => 2, + 218 => 2, + 277 => 1, + 278 => 1, + 303 => 1, + 308 => 1, + 321 => 1, + 322 => 1, + 329 => 1, + 330 => 1, + 337 => 1, + 342 => 1, + 343 => 1, + 345 => 1, + 346 => 2, + 353 => 1, + 354 => 1, + 355 => 2, + ]; }//end getErrorList() @@ -114,7 +114,7 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 3a09fdd7d4..f81e087314 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -28,51 +28,51 @@ class FunctionDeclarationUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='FunctionDeclarationUnitTest.inc') { if ($testFile === 'FunctionDeclarationUnitTest.inc') { - $errors = array( - 3 => 1, - 4 => 1, - 5 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 14 => 1, - 17 => 1, - 44 => 1, - 52 => 1, - 61 => 2, - 98 => 1, - 110 => 2, - 120 => 3, - 121 => 1, - 140 => 1, - 145 => 1, - 161 => 2, - 162 => 2, - 164 => 2, - 167 => 2, - 171 => 1, - 173 => 1, - 201 => 1, - 206 => 1, - 208 => 1, - 216 => 1, - 223 => 1, - 230 => 1, - 237 => 1, - ); + $errors = [ + 3 => 1, + 4 => 1, + 5 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 14 => 1, + 17 => 1, + 44 => 1, + 52 => 1, + 61 => 2, + 98 => 1, + 110 => 2, + 120 => 3, + 121 => 1, + 140 => 1, + 145 => 1, + 161 => 2, + 162 => 2, + 164 => 2, + 167 => 2, + 171 => 1, + 173 => 1, + 201 => 1, + 206 => 1, + 208 => 1, + 216 => 1, + 223 => 1, + 230 => 1, + 237 => 1, + ]; } else { - $errors = array( - 3 => 1, - 4 => 1, - 5 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 14 => 1, - 17 => 1, - 41 => 1, - 48 => 1, - ); + $errors = [ + 3 => 1, + 4 => 1, + 5 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 14 => 1, + 17 => 1, + 41 => 1, + 48 => 1, + ]; }//end if return $errors; @@ -90,7 +90,7 @@ public function getErrorList($testFile='FunctionDeclarationUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php index 1a115f7b32..1c114b825b 100644 --- a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php @@ -25,16 +25,16 @@ class ValidDefaultValueUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 29 => 1, - 34 => 1, - 39 => 1, - 71 => 1, - 76 => 1, - 81 => 1, - 91 => 1, - 99 => 1, - ); + return [ + 29 => 1, + 34 => 1, + 39 => 1, + 71 => 1, + 76 => 1, + 81 => 1, + 91 => 1, + 99 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php index 5c3faa45d5..8ff9c674b2 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php @@ -25,26 +25,26 @@ class ValidClassNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 7 => 2, - 9 => 1, - 19 => 1, - 24 => 1, - 26 => 2, - 28 => 1, - 38 => 1, - 40 => 2, - 42 => 2, - 44 => 1, - 46 => 1, - 50 => 1, - 52 => 2, - 54 => 1, - 64 => 1, - 66 => 2, - 68 => 1, - ); + return [ + 5 => 1, + 7 => 2, + 9 => 1, + 19 => 1, + 24 => 1, + 26 => 2, + 28 => 1, + 38 => 1, + 40 => 2, + 42 => 2, + 44 => 1, + 46 => 1, + 50 => 1, + 52 => 2, + 54 => 1, + 64 => 1, + 66 => 2, + 68 => 1, + ]; }//end getErrorList() @@ -59,7 +59,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 223788bfd5..f5b20e6855 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -25,120 +25,120 @@ class ValidFunctionNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 11 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - 20 => 1, - 24 => 1, - 25 => 1, - 26 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 32 => 1, - 33 => 1, - 35 => 1, - 36 => 1, - 37 => 1, - 38 => 1, - 39 => 1, - 40 => 1, - 43 => 1, - 44 => 1, - 45 => 1, - 46 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - 53 => 1, - 56 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - 73 => 1, - 74 => 1, - 75 => 1, - 76 => 1, - 80 => 1, - 81 => 1, - 82 => 1, - 83 => 1, - 84 => 1, - 85 => 1, - 86 => 1, - 87 => 1, - 88 => 1, - 89 => 1, - 91 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 95 => 1, - 96 => 1, - 99 => 1, - 100 => 1, - 101 => 1, - 102 => 1, - 106 => 1, - 107 => 1, - 108 => 1, - 109 => 1, - 112 => 1, - 113 => 1, - 114 => 1, - 115 => 1, - 121 => 1, - 122 => 1, - 123 => 1, - 124 => 1, - 125 => 1, - 126 => 1, - 127 => 1, - 128 => 1, - 129 => 1, - 130 => 1, - 149 => 1, - 151 => 1, - 152 => 1, - 155 => 1, - 156 => 1, - 157 => 1, - 158 => 1, - 159 => 1, - 160 => 1, - 161 => 1, - 162 => 1, - 163 => 1, - 164 => 1, - 165 => 1, - 166 => 1, - 167 => 1, - 169 => 1, - 170 => 1, - 171 => 1, - 173 => 1, - 174 => 1, - 175 => 1, - 207 => 1, - 227 => 1, - 229 => 1, - 230 => 1, - ); + return [ + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 20 => 1, + 24 => 1, + 25 => 1, + 26 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 32 => 1, + 33 => 1, + 35 => 1, + 36 => 1, + 37 => 1, + 38 => 1, + 39 => 1, + 40 => 1, + 43 => 1, + 44 => 1, + 45 => 1, + 46 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + 53 => 1, + 56 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 74 => 1, + 75 => 1, + 76 => 1, + 80 => 1, + 81 => 1, + 82 => 1, + 83 => 1, + 84 => 1, + 85 => 1, + 86 => 1, + 87 => 1, + 88 => 1, + 89 => 1, + 91 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 95 => 1, + 96 => 1, + 99 => 1, + 100 => 1, + 101 => 1, + 102 => 1, + 106 => 1, + 107 => 1, + 108 => 1, + 109 => 1, + 112 => 1, + 113 => 1, + 114 => 1, + 115 => 1, + 121 => 1, + 122 => 1, + 123 => 1, + 124 => 1, + 125 => 1, + 126 => 1, + 127 => 1, + 128 => 1, + 129 => 1, + 130 => 1, + 149 => 1, + 151 => 1, + 152 => 1, + 155 => 1, + 156 => 1, + 157 => 1, + 158 => 1, + 159 => 1, + 160 => 1, + 161 => 1, + 162 => 1, + 163 => 1, + 164 => 1, + 165 => 1, + 166 => 1, + 167 => 1, + 169 => 1, + 170 => 1, + 171 => 1, + 173 => 1, + 174 => 1, + 175 => 1, + 207 => 1, + 227 => 1, + 229 => 1, + 230 => 1, + ]; }//end getErrorList() @@ -153,7 +153,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php index c504bc548c..834852c335 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -25,15 +25,15 @@ class ValidVariableNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 12 => 1, - 17 => 1, - 22 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 99 => 1, - ); + return [ + 12 => 1, + 17 => 1, + 22 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 99 => 1, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php index a3b1c6b994..ef7580a5fd 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -25,17 +25,17 @@ class ObjectOperatorIndentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 2, - 6 => 1, - 15 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 49 => 1, - 50 => 1, - ); + return [ + 3 => 2, + 6 => 1, + 15 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 49 => 1, + 50 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index b6fb2592c8..9de3a69ea7 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -25,22 +25,22 @@ class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 11 => 1, - 13 => 1, - 24 => 1, - 30 => 1, - 61 => 1, - 65 => 1, - 85 => 1, - 89 => 1, - 98 => 1, - 122 => 1, - 127 => 1, - 135 => 1, - 141 => 1, - 146 => 1, - ); + return [ + 11 => 1, + 13 => 1, + 24 => 1, + 30 => 1, + 61 => 1, + 65 => 1, + 85 => 1, + 89 => 1, + 98 => 1, + 122 => 1, + 127 => 1, + 135 => 1, + 141 => 1, + 146 => 1, + ]; }//end getErrorList() @@ -55,7 +55,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php index c1067e65c4..0857021b2e 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -25,25 +25,25 @@ class ScopeIndentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 10 => 1, - 17 => 1, - 20 => 1, - 24 => 1, - 25 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 58 => 1, - 123 => 1, - 224 => 1, - 225 => 1, - 279 => 1, - 284 => 1, - 311 => 1, - ); + return [ + 7 => 1, + 10 => 1, + 17 => 1, + 20 => 1, + 24 => 1, + 25 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 58 => 1, + 123 => 1, + 224 => 1, + 225 => 1, + 279 => 1, + 284 => 1, + 311 => 1, + ]; }//end getErrorList() @@ -58,7 +58,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php index 7b0c5c8edc..858a626853 100644 --- a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php @@ -23,11 +23,11 @@ class ClassDeclarationSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -48,9 +48,9 @@ public function process(File $phpcsFile, $stackPtr) return; } - $errorData = array(strtolower($tokens[$stackPtr]['content'])); + $errorData = [strtolower($tokens[$stackPtr]['content'])]; - $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_TRAIT), ($tokens[$stackPtr]['scope_closer'] + 1)); + $nextClass = $phpcsFile->findNext([T_CLASS, T_INTERFACE, T_TRAIT], ($tokens[$stackPtr]['scope_closer'] + 1)); if ($nextClass !== false) { $error = 'Each %s must be in a file by itself'; $phpcsFile->addError($error, $nextClass, 'MultipleClasses', $errorData); @@ -59,7 +59,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes'); } - $namespace = $phpcsFile->findNext(array(T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT), 0); + $namespace = $phpcsFile->findNext([T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT], 0); if ($tokens[$namespace]['code'] !== T_NAMESPACE) { $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)'; $phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $errorData); diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index 2b07d390bf..05c7dc7775 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -24,7 +24,7 @@ class SideEffectsSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -45,10 +45,10 @@ public function process(File $phpcsFile, $stackPtr) if ($result['symbol'] !== null && $result['effect'] !== null) { $error = 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line %s and the first side effect is on line %s.'; - $data = array( - $tokens[$result['symbol']]['line'], - $tokens[$result['effect']]['line'], - ); + $data = [ + $tokens[$result['symbol']]['line'], + $tokens[$result['effect']]['line'], + ]; $phpcsFile->addWarning($error, 0, 'FoundWithSymbols', $data); $phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'yes'); } else { @@ -78,18 +78,18 @@ public function process(File $phpcsFile, $stackPtr) */ private function searchForConflict($phpcsFile, $start, $end, $tokens) { - $symbols = array( - T_CLASS => T_CLASS, - T_INTERFACE => T_INTERFACE, - T_TRAIT => T_TRAIT, - T_FUNCTION => T_FUNCTION, - ); - - $conditions = array( - T_IF => T_IF, - T_ELSE => T_ELSE, - T_ELSEIF => T_ELSEIF, - ); + $symbols = [ + T_CLASS => T_CLASS, + T_INTERFACE => T_INTERFACE, + T_TRAIT => T_TRAIT, + T_FUNCTION => T_FUNCTION, + ]; + + $conditions = [ + T_IF => T_IF, + T_ELSE => T_ELSE, + T_ELSEIF => T_ELSEIF, + ]; $firstSymbol = null; $firstEffect = null; @@ -238,10 +238,10 @@ private function searchForConflict($phpcsFile, $start, $end, $tokens) } }//end for - return array( - 'symbol' => $firstSymbol, - 'effect' => $firstEffect, - ); + return [ + 'symbol' => $firstSymbol, + 'effect' => $firstEffect, + ]; }//end searchForConflict() diff --git a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php index 10aa20efcc..f1bc59290d 100644 --- a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php +++ b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php @@ -49,7 +49,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($testName !== '' && Common::isCamelCaps($testName, false, true, false) === false) { $error = 'Method name "%s" is not in camel caps format'; $className = $phpcsFile->getDeclarationName($currScope); - $errorData = array($className.'::'.$methodName); + $errorData = [$className.'::'.$methodName]; $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'no'); } else { diff --git a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php index 53b4b3bddc..9c72fd9fab 100644 --- a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php @@ -28,16 +28,16 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='') { if ($testFile === 'ClassDeclarationUnitTest.2.inc') { - return array(); + return []; } if (PHP_VERSION_ID >= 50300) { - return array( - 2 => 1, - 3 => 2, - ); + return [ + 2 => 1, + 3 => 2, + ]; } else { - return array(3 => 1); + return [3 => 1]; } }//end getErrorList() @@ -53,7 +53,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index b14e8087a5..5dff3e2ecb 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -27,7 +27,7 @@ class SideEffectsUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='') { - return array(); + return []; }//end getErrorList() @@ -49,9 +49,9 @@ public function getWarningList($testFile='') case 'SideEffectsUnitTest.4.inc': case 'SideEffectsUnitTest.5.inc': case 'SideEffectsUnitTest.10.inc': - return array(1 => 1); + return [1 => 1]; default: - return array(); + return []; }//end switch }//end getWarningList() diff --git a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php index 411d5ce63a..0533dd13ae 100644 --- a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php +++ b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php @@ -25,17 +25,17 @@ class CamelCapsMethodNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 17 => 1, - 21 => 1, - 25 => 1, - 26 => 1, - ); + return [ + 6 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 17 => 1, + 21 => 1, + 25 => 1, + 26 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index b11eeef653..4e35d3cb08 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -71,16 +71,16 @@ public function processOpen(File $phpcsFile, $stackPtr) $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); $spaces = strlen($blankSpace); - if (in_array($tokens[($stackPtr - 2)]['code'], array(T_ABSTRACT, T_FINAL)) === true + if (in_array($tokens[($stackPtr - 2)]['code'], [T_ABSTRACT, T_FINAL]) === true && $spaces !== 1 ) { $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); $error = 'Expected 1 space between %s and %s keywords; %s found'; - $data = array( - $prevContent, - $stackPtrType, - $spaces, - ); + $data = [ + $prevContent, + $stackPtrType, + $spaces, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeKeyword', $data); if ($fix === true) { @@ -92,10 +92,10 @@ public function processOpen(File $phpcsFile, $stackPtr) ) { $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); $error = 'Expected 1 space between %s and %s keywords; newline found'; - $data = array( - $prevContent, - $stackPtrType, - ); + $data = [ + $prevContent, + $stackPtrType, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NewlineBeforeKeyword', $data); if ($fix === true) { @@ -126,11 +126,11 @@ public function processOpen(File $phpcsFile, $stackPtr) if (strlen($gap) !== 1) { $found = strlen($gap); $error = 'Expected 1 space between %s keyword and %s name; %s found'; - $data = array( - $stackPtrType, - $stackPtrType, - $found, - ); + $data = [ + $stackPtrType, + $stackPtrType, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data); if ($fix === true) { @@ -144,10 +144,10 @@ public function processOpen(File $phpcsFile, $stackPtr) if (strlen($gap) !== 1) { $found = strlen($gap); $error = 'Expected 1 space after %s name; %s found'; - $data = array( - $stackPtrType, - $found, - ); + $data = [ + $stackPtrType, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $className, 'SpaceAfterName', $data); if ($fix === true) { @@ -159,12 +159,12 @@ public function processOpen(File $phpcsFile, $stackPtr) $openingBrace = $tokens[$stackPtr]['scope_opener']; // Check positions of the extends and implements keywords. - foreach (array('extends', 'implements') as $keywordType) { + foreach (['extends', 'implements'] as $keywordType) { $keyword = $phpcsFile->findNext(constant('T_'.strtoupper($keywordType)), ($stackPtr + 1), $openingBrace); if ($keyword !== false) { if ($tokens[$keyword]['line'] !== $tokens[$stackPtr]['line']) { $error = 'The '.$keywordType.' keyword must be on the same line as the %s name'; - $data = array($stackPtrType); + $data = [$stackPtrType]; $fix = $phpcsFile->addFixableError($error, $keyword, ucfirst($keywordType).'Line', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); @@ -184,7 +184,7 @@ public function processOpen(File $phpcsFile, $stackPtr) $gap = strlen($tokens[($keyword - 1)]['content']); if ($gap !== 1) { $error = 'Expected 1 space before '.$keywordType.' keyword; %s found'; - $data = array($gap); + $data = [$gap]; $fix = $phpcsFile->addFixableError($error, $keyword, 'SpaceBefore'.ucfirst($keywordType), $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($keyword - 1), ' '); @@ -216,12 +216,12 @@ public function processOpen(File $phpcsFile, $stackPtr) } } - $find = array( - T_STRING, - $keywordTokenType, - ); + $find = [ + T_STRING, + $keywordTokenType, + ]; - $classNames = array(); + $classNames = []; $nextClass = $phpcsFile->findNext($find, ($className + 2), ($openingBrace - 1)); while ($nextClass !== false) { $classNames[] = $nextClass; @@ -244,10 +244,10 @@ public function processOpen(File $phpcsFile, $stackPtr) || $tokens[($className - 2)]['code'] !== T_STRING) ) { $prev = $phpcsFile->findPrevious( - array( - T_NS_SEPARATOR, - T_WHITESPACE, - ), + [ + T_NS_SEPARATOR, + T_WHITESPACE, + ], ($className - 1), $implements, true @@ -308,10 +308,10 @@ public function processOpen(File $phpcsFile, $stackPtr) $expected = ($classIndent + $this->indent); if ($found !== $expected) { $error = 'Expected %s spaces before interface name; %s found'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $className, 'InterfaceWrongIndent', $data); if ($fix === true) { $padding = str_repeat(' ', $expected); @@ -332,7 +332,7 @@ public function processOpen(File $phpcsFile, $stackPtr) && $tokens[($className - 2)]['code'] === T_COMMA) ) { $error = 'Expected 1 space before "%s"; 0 found'; - $data = array($tokens[$className]['content']); + $data = [$tokens[$className]['content']]; $fix = $phpcsFile->addFixableError($error, ($nextComma + 1), 'NoSpaceBeforeName', $data); if ($fix === true) { $phpcsFile->fixer->addContentBefore(($nextComma + 1), ' '); @@ -347,10 +347,10 @@ public function processOpen(File $phpcsFile, $stackPtr) $spaceBefore = strlen($tokens[$prev]['content']); if ($spaceBefore !== 1) { $error = 'Expected 1 space before "%s"; %s found'; - $data = array( - $tokens[$className]['content'], - $spaceBefore, - ); + $data = [ + $tokens[$className]['content'], + $spaceBefore, + ]; $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeName', $data); if ($fix === true) { @@ -369,10 +369,10 @@ public function processOpen(File $phpcsFile, $stackPtr) // is not where we expect it to be. if ($tokens[($className + 2)]['code'] !== $keywordTokenType) { $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $tokens[$className]['content'], - strlen($tokens[($className + 1)]['content']), - ); + $data = [ + $tokens[$className]['content'], + strlen($tokens[($className + 1)]['content']), + ]; $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeComma', $data); if ($fix === true) { @@ -410,7 +410,7 @@ public function processClose(File $phpcsFile, $stackPtr) && $tokens[$prevContent]['line'] !== ($tokens[$closeBrace]['line'] - 1) ) { $error = 'The closing brace for the %s must go on the next line after the body'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'CloseBraceAfterBody', $data); if ($fix === true) { @@ -429,13 +429,13 @@ public function processClose(File $phpcsFile, $stackPtr) // Check the closing brace is on it's own line, but allow // for comments like "//end class". - $nextContent = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($closeBrace + 1), null, true); + $nextContent = $phpcsFile->findNext([T_WHITESPACE, T_COMMENT], ($closeBrace + 1), null, true); if ($tokens[$nextContent]['content'] !== $phpcsFile->eolChar && $tokens[$nextContent]['line'] === $tokens[$closeBrace]['line'] ) { $type = strtolower($tokens[$stackPtr]['content']); $error = 'Closing %s brace must be on a line by itself'; - $data = array($type); + $data = [$type]; $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data); } diff --git a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php index 3fcaa2392e..6e97e262b9 100644 --- a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php @@ -31,7 +31,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) if ($tokens[$stackPtr]['content'][1] === '_') { $error = 'Property name "%s" should not be prefixed with an underscore to indicate visibility'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addWarning($error, $stackPtr, 'Underscore', $data); } @@ -39,7 +39,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) // for this, but also only process the first property in the list so we don't // repeat errors. $find = Tokens::$scopeModifiers; - $find = array_merge($find, array(T_VARIABLE, T_VAR, T_SEMICOLON)); + $find = array_merge($find, [T_VARIABLE, T_VAR, T_SEMICOLON]); $prev = $phpcsFile->findPrevious($find, ($stackPtr - 1)); if ($tokens[$prev]['code'] === T_VARIABLE) { return; @@ -50,7 +50,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $stackPtr, 'VarUsed'); } - $next = $phpcsFile->findNext(array(T_VARIABLE, T_SEMICOLON), ($stackPtr + 1)); + $next = $phpcsFile->findNext([T_VARIABLE, T_SEMICOLON], ($stackPtr + 1)); if ($tokens[$next]['code'] === T_VARIABLE) { $error = 'There must not be more than one property declared per statement'; $phpcsFile->addError($error, $stackPtr, 'Multiple'); @@ -59,7 +59,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) $modifier = $phpcsFile->findPrevious(Tokens::$scopeModifiers, $stackPtr); if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { $error = 'Visibility must be declared on property "%s"'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addError($error, $stackPtr, 'ScopeMissing', $data); } diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 7570493ccf..a15c7e4265 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -38,18 +38,18 @@ class ControlStructureSpacingSniff implements Sniff */ public function register() { - return array( - T_IF, - T_WHILE, - T_FOREACH, - T_FOR, - T_SWITCH, - T_DO, - T_ELSE, - T_ELSEIF, - T_TRY, - T_CATCH, - ); + return [ + T_IF, + T_WHILE, + T_FOREACH, + T_FOR, + T_SWITCH, + T_DO, + T_ELSE, + T_ELSEIF, + T_TRY, + T_CATCH, + ]; }//end register() @@ -90,10 +90,10 @@ public function process(File $phpcsFile, $stackPtr) if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) { $error = 'Expected %s spaces after opening bracket; %s found'; - $data = array( - $this->requiredSpacesAfterOpen, - $spaceAfterOpen, - ); + $data = [ + $this->requiredSpacesAfterOpen, + $spaceAfterOpen, + ]; $fix = $phpcsFile->addFixableError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesAfterOpen); @@ -117,10 +117,10 @@ public function process(File $phpcsFile, $stackPtr) if ($spaceBeforeClose !== $this->requiredSpacesBeforeClose) { $error = 'Expected %s spaces before closing bracket; %s found'; - $data = array( - $this->requiredSpacesBeforeClose, - $spaceBeforeClose, - ); + $data = [ + $this->requiredSpacesBeforeClose, + $spaceBeforeClose, + ]; $fix = $phpcsFile->addFixableError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesBeforeClose); diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 14f134c013..0bb0c18721 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -23,10 +23,10 @@ class ElseIfDeclarationSniff implements Sniff */ public function register() { - return array( - T_ELSE, - T_ELSEIF, - ); + return [ + T_ELSE, + T_ELSEIF, + ]; }//end register() diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 2471c1d767..e7b01b263e 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -31,7 +31,7 @@ class SwitchDeclarationSniff implements Sniff */ public function register() { - return array(T_SWITCH); + return [T_SWITCH]; }//end register() @@ -74,10 +74,10 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) { $expected = strtolower($tokens[$nextCase]['content']); $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $tokens[$nextCase]['content'], - ); + $data = [ + $expected, + $tokens[$nextCase]['content'], + ]; $fix = $phpcsFile->addFixableError($error, $nextCase, $type.'NotLower', $data); if ($fix === true) { @@ -216,7 +216,7 @@ public function process(File $phpcsFile, $stackPtr) private function findNextCase($phpcsFile, $stackPtr, $end) { $tokens = $phpcsFile->getTokens(); - while (($stackPtr = $phpcsFile->findNext(array(T_CASE, T_DEFAULT, T_SWITCH), $stackPtr, $end)) !== false) { + while (($stackPtr = $phpcsFile->findNext([T_CASE, T_DEFAULT, T_SWITCH], $stackPtr, $end)) !== false) { // Skip nested SWITCH statements; they are handled on their own. if ($tokens[$stackPtr]['code'] === T_SWITCH) { $stackPtr = $tokens[$stackPtr]['scope_closer']; @@ -243,13 +243,13 @@ private function findNextCase($phpcsFile, $stackPtr, $end) private function findNestedTerminator($phpcsFile, $stackPtr, $end) { $tokens = $phpcsFile->getTokens(); - $terminators = array( - T_RETURN, - T_BREAK, - T_CONTINUE, - T_THROW, - T_EXIT, - ); + $terminators = [ + T_RETURN, + T_BREAK, + T_CONTINUE, + T_THROW, + T_EXIT, + ]; $lastToken = $phpcsFile->findPrevious(T_WHITESPACE, ($end - 1), $stackPtr, true); if ($lastToken !== false) { diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index bd689c5406..c4e060f996 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -24,7 +24,7 @@ class ClosingTagSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php index 31c92c383d..b26a8b2370 100644 --- a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php @@ -23,7 +23,7 @@ class EndFileNewlineSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -69,7 +69,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$lastToken]['code'] === T_WHITESPACE || $tokens[$lastToken]['code'] === T_DOC_COMMENT_WHITESPACE ) { - $lastCode = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT_WHITESPACE), ($lastToken - 1), null, true); + $lastCode = $phpcsFile->findPrevious([T_WHITESPACE, T_DOC_COMMENT_WHITESPACE], ($lastToken - 1), null, true); } else { $lastCode = $lastToken; } @@ -80,7 +80,7 @@ public function process(File $phpcsFile, $stackPtr) if ($blankLines > 1) { $error = 'Expected 1 blank line at end of file; %s found'; - $data = array($blankLines); + $data = [$blankLines]; $fix = $phpcsFile->addFixableError($error, $lastCode, 'TooMany', $data); if ($fix === true) { diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php index 933329dc63..140d2a15d7 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php @@ -23,10 +23,10 @@ class FunctionClosingBraceSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Function closing brace must go on the next line following the body; found %s blank lines before brace'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeClose', $data); if ($fix === true) { diff --git a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php index 52149b1fae..03c3594506 100644 --- a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php @@ -22,7 +22,7 @@ class MethodDeclarationSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION)); + parent::__construct([T_CLASS, T_INTERFACE], [T_FUNCTION]); }//end __construct() @@ -48,7 +48,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($methodName[0] === '_' && isset($methodName[1]) === true && $methodName[1] !== '_') { $error = 'Method name "%s" should not be prefixed with an underscore to indicate visibility'; - $data = array($methodName); + $data = [$methodName]; $phpcsFile->addWarning($error, $stackPtr, 'Underscore', $data); } @@ -79,7 +79,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop } } - $fixes = array(); + $fixes = []; if ($visibility !== 0 && $final > $visibility) { $error = 'The final declaration must precede the visibility declaration'; diff --git a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php index cd9904af60..3df2cea26a 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php @@ -23,7 +23,7 @@ class NamespaceDeclarationSniff implements Sniff */ public function register() { - return array(T_NAMESPACE); + return [T_NAMESPACE]; }//end register() diff --git a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index 9aeaa678c0..6f30ebdfd4 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -24,7 +24,7 @@ class UseDeclarationSniff implements Sniff */ public function register() { - return array(T_USE); + return [T_USE]; }//end register() @@ -56,7 +56,7 @@ public function process(File $phpcsFile, $stackPtr) } // Only one USE declaration allowed per statement. - $next = $phpcsFile->findNext(array(T_COMMA, T_SEMICOLON, T_OPEN_USE_GROUP, T_CLOSE_TAG), ($stackPtr + 1)); + $next = $phpcsFile->findNext([T_COMMA, T_SEMICOLON, T_OPEN_USE_GROUP, T_CLOSE_TAG], ($stackPtr + 1)); if ($next !== false && $tokens[$next]['code'] !== T_SEMICOLON && $tokens[$next]['code'] !== T_CLOSE_TAG @@ -155,7 +155,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'There must be one blank line after the last USE statement; %s found;'; - $data = array($diff); + $data = [$diff]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterLastUse', $data); if ($fix === true) { if ($diff === 0) { @@ -199,7 +199,7 @@ private function shouldIgnoreUse($phpcsFile, $stackPtr) } // Ignore USE keywords for traits. - if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true) { + if ($phpcsFile->hasCondition($stackPtr, [T_CLASS, T_TRAIT]) === true) { return true; } diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index a4eafa4b34..ed64075741 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -25,32 +25,32 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 7 => 3, - 12 => 1, - 13 => 1, - 17 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 1, - 25 => 1, - 27 => 2, - 34 => 1, - 35 => 2, - 44 => 1, - 45 => 1, - 63 => 1, - 95 => 1, - 116 => 1, - 118 => 1, - 119 => 1, - 124 => 1, - 130 => 2, - 131 => 1, - 158 => 1, - ); + return [ + 2 => 1, + 7 => 3, + 12 => 1, + 13 => 1, + 17 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 1, + 25 => 1, + 27 => 2, + 34 => 1, + 35 => 2, + 44 => 1, + 45 => 1, + 63 => 1, + 95 => 1, + 116 => 1, + 118 => 1, + 119 => 1, + 124 => 1, + 130 => 2, + 131 => 1, + 158 => 1, + ]; }//end getErrorList() @@ -65,7 +65,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php index bdd6578a17..ad47dfd341 100644 --- a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php @@ -25,13 +25,13 @@ class PropertyDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 9 => 2, - 10 => 1, - 16 => 1, - 17 => 1, - ); + return [ + 7 => 1, + 9 => 2, + 10 => 1, + 16 => 1, + 17 => 1, + ]; }//end getErrorList() @@ -46,11 +46,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 12 => 1, - 13 => 1, - 14 => 1, - ); + return [ + 12 => 1, + 13 => 1, + 14 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index f01c24bc90..7e576cdae6 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -25,15 +25,15 @@ class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 14 => 2, - 26 => 2, - 27 => 2, - 31 => 1, - 41 => 2, - 43 => 2, - ); + return [ + 4 => 1, + 14 => 2, + 26 => 2, + 27 => 2, + 31 => 1, + 41 => 2, + 43 => 2, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index 0d777e9bcf..935205b404 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -25,7 +25,7 @@ class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 4 => 1, - 12 => 1, - ); + return [ + 4 => 1, + 12 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php index e2ef986e77..9c1735563f 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -25,29 +25,29 @@ class SwitchDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 10 => 1, - 11 => 1, - 14 => 1, - 16 => 1, - 20 => 1, - 23 => 1, - 29 => 1, - 33 => 1, - 37 => 2, - 108 => 2, - 109 => 1, - 111 => 1, - 113 => 2, - 114 => 1, - 128 => 1, - 141 => 1, - 172 => 1, - 194 => 1, - 224 => 1, - 236 => 1, - 260 => 1, - ); + return [ + 10 => 1, + 11 => 1, + 14 => 1, + 16 => 1, + 20 => 1, + 23 => 1, + 29 => 1, + 33 => 1, + 37 => 2, + 108 => 2, + 109 => 1, + 111 => 1, + 113 => 2, + 114 => 1, + 128 => 1, + 141 => 1, + 172 => 1, + 194 => 1, + 224 => 1, + 236 => 1, + 260 => 1, + ]; }//end getErrorList() @@ -62,7 +62,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php index e8cfcb365c..49de6c4dc4 100644 --- a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php @@ -29,14 +29,14 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'ClosingTagUnitTest.1.inc': - return array(11 => 1); + return [11 => 1]; case 'ClosingTagUnitTest.4.inc': case 'ClosingTagUnitTest.5.inc': - return array(1 => 1); + return [1 => 1]; default: - return array(); + return []; } }//end getErrorList() @@ -52,7 +52,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php index 410f250788..3edb153389 100644 --- a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php @@ -32,16 +32,16 @@ public function getErrorList($testFile='') case 'EndFileNewlineUnitTest.3.inc': case 'EndFileNewlineUnitTest.6.inc': case 'EndFileNewlineUnitTest.7.inc': - return array(2 => 1); + return [2 => 1]; case 'EndFileNewlineUnitTest.9.inc': case 'EndFileNewlineUnitTest.10.inc': // HHVM just removes the entire comment token, as if it was never there. if (defined('HHVM_VERSION') === true) { - return array(); + return []; } - return array(2 => 1); + return [2 => 1]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -59,7 +59,7 @@ public function getErrorList($testFile='') */ public function getWarningList($testFile='') { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php index 8f864bdca5..4c2125f98e 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php @@ -25,41 +25,41 @@ class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 18 => 3, - 21 => 1, - 48 => 1, - 87 => 1, - 90 => 1, - 91 => 1, - 103 => 1, - 111 => 1, - 117 => 4, - 121 => 1, - 125 => 1, - 129 => 1, - 133 => 1, - 138 => 1, - 146 => 1, - 150 => 1, - 154 => 1, - 158 => 1, - 162 => 1, - 167 => 1, - 172 => 1, - 175 => 1, - 178 => 1, - 186 => 1, - 187 => 1, - 194 => 3, - 199 => 1, - 200 => 2, - 202 => 1, - 203 => 1, - 210 => 2, - 211 => 1, - 212 => 2, - ); + return [ + 18 => 3, + 21 => 1, + 48 => 1, + 87 => 1, + 90 => 1, + 91 => 1, + 103 => 1, + 111 => 1, + 117 => 4, + 121 => 1, + 125 => 1, + 129 => 1, + 133 => 1, + 138 => 1, + 146 => 1, + 150 => 1, + 154 => 1, + 158 => 1, + 162 => 1, + 167 => 1, + 172 => 1, + 175 => 1, + 178 => 1, + 186 => 1, + 187 => 1, + 194 => 3, + 199 => 1, + 200 => 2, + 202 => 1, + 203 => 1, + 210 => 2, + 211 => 1, + 212 => 2, + ]; }//end getErrorList() @@ -74,7 +74,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php index 07084f29d5..2497f35bb5 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php @@ -25,14 +25,14 @@ class FunctionClosingBraceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 16 => 1, - 23 => 1, - 40 => 1, - 47 => 1, - 63 => 1, - 70 => 1, - ); + return [ + 16 => 1, + 23 => 1, + 40 => 1, + 47 => 1, + 63 => 1, + 70 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php index cd8efbb8a0..e1706cb02d 100644 --- a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php @@ -25,12 +25,12 @@ class MethodDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 11 => 1, - 13 => 1, - 15 => 3, - ); + return [ + 9 => 1, + 11 => 1, + 13 => 1, + 15 => 3, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(5 => 1); + return [5 => 1]; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php index 7bb3177688..0cf6d37a93 100644 --- a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php @@ -25,10 +25,10 @@ class NamespaceDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 9 => 1, - ); + return [ + 6 => 1, + 9 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php index 6096d23aee..e478d69386 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php @@ -29,28 +29,28 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'UseDeclarationUnitTest.2.inc': - return array( - 4 => 1, - 5 => 1, - 10 => 2, - ); + return [ + 4 => 1, + 5 => 1, + 10 => 2, + ]; case 'UseDeclarationUnitTest.3.inc': - return array( - 4 => 1, - 6 => 1, - ); + return [ + 4 => 1, + 6 => 1, + ]; case 'UseDeclarationUnitTest.5.inc': - return array( - 5 => 1, - 6 => 1, - 8 => 1, - 14 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 8 => 1, + 14 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + ]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -66,7 +66,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php index fc3fda3c00..9c6040d7c8 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php @@ -24,10 +24,10 @@ class ArrayBracketSpacingSniff implements Sniff */ public function register() { - return array( - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - ); + return [ + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + ]; }//end register() @@ -61,10 +61,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = $tokens[$nonSpace]['content'].$tokens[$stackPtr]['content']; $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).$tokens[$stackPtr]['content']; $error = 'Space found before square bracket; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeBracket', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr - 1), ''); @@ -79,10 +79,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = $tokens[$stackPtr]['content'].$tokens[$nonSpace]['content']; $found = $phpcsFile->getTokensAsString($stackPtr, ($nonSpace - $stackPtr + 1)); $error = 'Space found after square bracket; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterBracket', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index ffdefcd03c..0fb81b337d 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -24,10 +24,10 @@ class ArrayDeclarationSniff implements Sniff */ public function register() { - return array( - T_ARRAY, - T_OPEN_SHORT_ARRAY, - ); + return [ + T_ARRAY, + T_OPEN_SHORT_ARRAY, + ]; }//end register() @@ -57,7 +57,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Array keyword should be lower case; expected "array" but found "%s"'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotLowerCase', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken($stackPtr, 'array'); @@ -148,7 +148,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra // 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 ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { @@ -180,7 +180,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($tokens[($nextArrow - 1)]['code'] !== T_WHITESPACE) { $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 ($fix === true) { $phpcsFile->fixer->addContentBefore($nextArrow, ' '); @@ -190,10 +190,10 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($spaceLength !== 1) { $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 ($fix === true) { @@ -205,7 +205,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($tokens[($nextArrow + 1)]['code'] !== T_WHITESPACE) { $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 ($fix === true) { $phpcsFile->fixer->addContent($nextArrow, ' '); @@ -215,10 +215,10 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($spaceLength !== 1) { $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 ($fix === true) { @@ -256,7 +256,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { $content = $tokens[($comma + 1)]['content']; $error = 'Expected 1 space between comma and "%s"; 0 found'; - $data = array($content); + $data = [$content]; $fix = $phpcsFile->addFixableError($error, $comma, 'NoSpaceAfterComma', $data); if ($fix === true) { $phpcsFile->fixer->addContent($comma, ' '); @@ -266,10 +266,10 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra if ($spaceLength !== 1) { $content = $tokens[($comma + 2)]['content']; $error = 'Expected 1 space between comma and "%s"; %s found'; - $data = array( - $content, - $spaceLength, - ); + $data = [ + $content, + $spaceLength, + ]; $fix = $phpcsFile->addFixableError($error, $comma, 'SpaceAfterComma', $data); if ($fix === true) { @@ -282,10 +282,10 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra $content = $tokens[($comma - 2)]['content']; $spaceLength = $tokens[($comma - 1)]['length']; $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $content, - $spaceLength, - ); + $data = [ + $content, + $spaceLength, + ]; $fix = $phpcsFile->addFixableError($error, $comma, 'SpaceBeforeComma', $data); if ($fix === true) { @@ -327,10 +327,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $expected = ($keywordStart - 1); $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 ($fix === true) { @@ -344,7 +344,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $keyUsed = false; $singleUsed = false; - $indices = array(); + $indices = []; $maxLength = 0; if ($tokens[$stackPtr]['code'] === T_ARRAY) { @@ -370,7 +370,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array ) { // Let subsequent calls of this test handle nested arrays. if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) { - $indices[] = array('value' => $nextToken); + $indices[] = ['value' => $nextToken]; $lastToken = $nextToken; } @@ -399,7 +399,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array continue; } - $currentEntry = array(); + $currentEntry = []; if ($tokens[$nextToken]['code'] === T_COMMA) { $stackPtrCount = 0; @@ -439,10 +439,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $content, - $spaceLength, - ); + $data = [ + $content, + $spaceLength, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data); if ($fix === true) { @@ -457,7 +457,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array true ); - $indices[] = array('value' => $valueContent); + $indices[] = ['value' => $valueContent]; $singleUsed = true; }//end if @@ -610,10 +610,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $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 ($fix === true) { @@ -709,10 +709,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $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); if ($fix === true) { @@ -730,10 +730,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); $found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data); if ($fix === true) { @@ -755,10 +755,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } $error = 'Array value not aligned correctly; expected %s space(s) but found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $index['arrow'], 'ValueNotAligned', $data); if ($fix === true) { @@ -854,10 +854,10 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $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 ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php index 3a785e7bfc..d2087b7881 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php @@ -21,7 +21,7 @@ class ClassDefinitionClosingBraceSpaceSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class ClassDefinitionClosingBraceSpaceSniff implements Sniff */ public function register() { - return array(T_CLOSE_CURLY_BRACKET); + return [T_CLOSE_CURLY_BRACKET]; }//end register() @@ -58,7 +58,7 @@ public function process(File $phpcsFile, $stackPtr) $found = (($tokens[$next]['line'] - $tokens[$stackPtr]['line']) - 1); if ($found !== 1) { $error = 'Expected one blank line after closing brace of class definition; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterClose', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php index 3d651531ab..092ac779ea 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php @@ -21,7 +21,7 @@ class ClassDefinitionNameSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class ClassDefinitionNameSpacingSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() @@ -57,11 +57,11 @@ public function process(File $phpcsFile, $stackPtr) // Find the first blank line before this opening brace, unless we get // to another style definition, comment or the start of the file. - $endTokens = array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_OPEN_TAG => T_OPEN_TAG, - ); + $endTokens = [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_OPEN_TAG => T_OPEN_TAG, + ]; $endTokens += Tokens::$commentTokens; $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php index 4f0b51ac2c..e36bb0d15a 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php @@ -21,7 +21,7 @@ class ClassDefinitionOpeningBraceSpaceSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class ClassDefinitionOpeningBraceSpaceSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() @@ -68,7 +68,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Expected 1 space before opening brace of class definition; %s found'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); @@ -104,7 +104,7 @@ public function process(File $phpcsFile, $stackPtr) if ($nested === true) { if ($foundLines !== 1) { $error = 'Expected 1 blank line after opening brace of nesting class definition; %s found'; - $data = array($foundLines); + $data = [$foundLines]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'AfterNesting', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php index 91fbc20805..67c815683b 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php @@ -21,7 +21,7 @@ class ColonSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class ColonSpacingSniff implements Sniff */ public function register() { - return array(T_COLON); + return [T_COLON]; }//end register() @@ -85,7 +85,7 @@ public function process(File $phpcsFile, $stackPtr) $length = strlen($content); if ($length !== 1) { $error = 'Expected 1 space after colon in style definition; %s found'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'After', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php index 90de6be89c..792eaea920 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php @@ -20,7 +20,7 @@ class ColourDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class ColourDefinitionSniff implements Sniff */ public function register() { - return array(T_COLOUR); + return [T_COLOUR]; }//end register() @@ -52,10 +52,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = strtoupper($colour); if ($colour !== $expected) { $error = 'CSS colours must be defined in uppercase; expected %s but found %s'; - $data = array( - $expected, - $colour, - ); + $data = [ + $expected, + $colour, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotUpper', $data); if ($fix === true) { @@ -71,10 +71,10 @@ public function process(File $phpcsFile, $stackPtr) if ($colour{1} === $colour{2} && $colour{3} === $colour{4} && $colour{5} === $colour{6}) { $expected = '#'.$colour{1}.$colour{3}.$colour{5}; $error = 'CSS colours must use shorthand if available; expected %s but found %s'; - $data = array( - $expected, - $colour, - ); + $data = [ + $expected, + $colour, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Shorthand', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php index ce35bf4ca4..3697ffd3cf 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php @@ -20,7 +20,7 @@ class DisallowMultipleStyleDefinitionsSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class DisallowMultipleStyleDefinitionsSniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php index 8acf1a1fde..ef1ffa6623 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php @@ -21,7 +21,7 @@ class DuplicateClassDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class DuplicateClassDefinitionSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -50,7 +50,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // Find the content of each class definition name. - $classNames = array(); + $classNames = []; $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1)); if ($next === false) { // No class definitions in the file. @@ -61,11 +61,11 @@ public function process(File $phpcsFile, $stackPtr) // to prevent false positives with @media blocks. $scope = 'main'; - $find = array( - T_CLOSE_CURLY_BRACKET, - T_OPEN_CURLY_BRACKET, - T_OPEN_TAG, - ); + $find = [ + T_CLOSE_CURLY_BRACKET, + T_OPEN_CURLY_BRACKET, + T_OPEN_TAG, + ]; while ($next !== false) { $prev = $phpcsFile->findPrevious($find, ($next - 1)); @@ -100,7 +100,7 @@ public function process(File $phpcsFile, $stackPtr) } else if (isset($classNames[$scope][$name]) === true) { $first = $classNames[$scope][$name]; $error = 'Duplicate class definition found; first defined on line %s'; - $data = array($tokens[$first]['line']); + $data = [$tokens[$first]['line']]; $phpcsFile->addError($error, $next, 'Found', $data); } else { $classNames[$scope][$name] = $next; diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php index d1cb1de0fa..52fabd59f5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php @@ -20,7 +20,7 @@ class DuplicateStyleDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class DuplicateStyleDefinitionSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() @@ -49,13 +49,13 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // Find the content of each style definition name. - $styleNames = array(); + $styleNames = []; $next = $stackPtr; $end = $tokens[$stackPtr]['bracket_closer']; do { - $next = $phpcsFile->findNext(array(T_STYLE, T_OPEN_CURLY_BRACKET), ($next + 1), $end); + $next = $phpcsFile->findNext([T_STYLE, T_OPEN_CURLY_BRACKET], ($next + 1), $end); if ($next === false) { // Class definition is empty. break; @@ -70,7 +70,7 @@ public function process(File $phpcsFile, $stackPtr) if (isset($styleNames[$name]) === true) { $first = $styleNames[$name]; $error = 'Duplicate style definition found; first defined on line %s'; - $data = array($tokens[$first]['line']); + $data = [$tokens[$first]['line']]; $phpcsFile->addError($error, $next, 'Found', $data); } else { $styleNames[$name] = $next; diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php index aa279f7678..aaf62aeddd 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php @@ -21,7 +21,7 @@ class EmptyClassDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -31,7 +31,7 @@ class EmptyClassDefinitionSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php index 4aed2ae854..8d5957c89a 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php @@ -20,7 +20,7 @@ class EmptyStyleDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class EmptyStyleDefinitionSniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() @@ -47,7 +47,7 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($stackPtr + 1), null, true); + $next = $phpcsFile->findNext([T_WHITESPACE, T_COLON], ($stackPtr + 1), null, true); if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { $error = 'Style definition is empty'; diff --git a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php index 4bfa5ec3af..ac1a7da6aa 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php @@ -20,7 +20,7 @@ class ForbiddenStylesSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** * A list of forbidden styles with their alternatives. @@ -30,23 +30,23 @@ class ForbiddenStylesSniff implements Sniff * * @var array */ - protected $forbiddenStyles = array( - '-moz-border-radius' => 'border-radius', - '-webkit-border-radius' => 'border-radius', - '-moz-border-radius-topleft' => 'border-top-left-radius', - '-moz-border-radius-topright' => 'border-top-right-radius', - '-moz-border-radius-bottomright' => 'border-bottom-right-radius', - '-moz-border-radius-bottomleft' => 'border-bottom-left-radius', - '-moz-box-shadow' => 'box-shadow', - '-webkit-box-shadow' => 'box-shadow', - ); + protected $forbiddenStyles = [ + '-moz-border-radius' => 'border-radius', + '-webkit-border-radius' => 'border-radius', + '-moz-border-radius-topleft' => 'border-top-left-radius', + '-moz-border-radius-topright' => 'border-top-right-radius', + '-moz-border-radius-bottomright' => 'border-bottom-right-radius', + '-moz-border-radius-bottomleft' => 'border-bottom-left-radius', + '-moz-box-shadow' => 'box-shadow', + '-webkit-box-shadow' => 'box-shadow', + ]; /** * A cache of forbidden style names, for faster lookups. * * @var string[] */ - protected $forbiddenStyleNames = array(); + protected $forbiddenStyleNames = []; /** * If true, forbidden styles will be considered regular expressions. @@ -78,7 +78,7 @@ public function register() } } - return array(T_STYLE); + return [T_STYLE]; }//end register() @@ -138,7 +138,7 @@ public function process(File $phpcsFile, $stackPtr) */ protected function addError($phpcsFile, $stackPtr, $style, $pattern=null) { - $data = array($style); + $data = [$style]; $error = 'The use of style %s is '; if ($this->error === true) { $type = 'Found'; diff --git a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php index 550d1ff6c0..518f44c52b 100644 --- a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php @@ -20,7 +20,7 @@ class IndentationSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** * The number of spaces code should be indented. @@ -37,7 +37,7 @@ class IndentationSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -118,10 +118,10 @@ public function process(File $phpcsFile, $stackPtr) } } else if ($foundIndent !== $expectedIndent) { $error = 'Line indented incorrectly; expected %s spaces, found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); + $data = [ + $expectedIndent, + $foundIndent, + ]; $fix = $phpcsFile->addFixableError($error, $i, 'Incorrect', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php index 5c5893cbf7..12474ae5b4 100644 --- a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php @@ -20,7 +20,7 @@ class LowercaseStyleDefinitionSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class LowercaseStyleDefinitionSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() @@ -78,10 +78,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = strtolower($tokens[$i]['content']); if ($expected !== $tokens[$i]['content']) { $error = 'Style definitions must be lowercase; expected %s but found %s'; - $data = array( - $expected, - $tokens[$i]['content'], - ); + $data = [ + $expected, + $tokens[$i]['content'], + ]; $fix = $phpcsFile->addFixableError($error, $i, 'FoundUpper', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php index 4c815d1ac6..52b2f8f57f 100644 --- a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php @@ -20,7 +20,7 @@ class MissingColonSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class MissingColonSniff implements Sniff */ public function register() { - return array(T_OPEN_CURLY_BRACKET); + return [T_OPEN_CURLY_BRACKET]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php index 90c28155a3..6200166e18 100644 --- a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php @@ -20,7 +20,7 @@ class NamedColoursSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,25 +30,25 @@ class NamedColoursSniff implements Sniff * * @var array */ - protected $colourNames = array( - 'aqua' => 'aqua', - 'black' => 'black', - 'blue' => 'blue', - 'fuchsia' => 'fuchsia', - 'gray' => 'gray', - 'green' => 'green', - 'lime' => 'lime', - 'maroon' => 'maroon', - 'navy' => 'navy', - 'olive' => 'olive', - 'orange' => 'orange', - 'purple' => 'purple', - 'red' => 'red', - 'silver' => 'silver', - 'teal' => 'teal', - 'white' => 'white', - 'yellow' => 'yellow', - ); + protected $colourNames = [ + 'aqua' => 'aqua', + 'black' => 'black', + 'blue' => 'blue', + 'fuchsia' => 'fuchsia', + 'gray' => 'gray', + 'green' => 'green', + 'lime' => 'lime', + 'maroon' => 'maroon', + 'navy' => 'navy', + 'olive' => 'olive', + 'orange' => 'orange', + 'purple' => 'purple', + 'red' => 'red', + 'silver' => 'silver', + 'teal' => 'teal', + 'white' => 'white', + 'yellow' => 'yellow', + ]; /** @@ -58,7 +58,7 @@ class NamedColoursSniff implements Sniff */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php index 70ea3f889e..d97adf117b 100644 --- a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php @@ -20,7 +20,7 @@ class OpacitySniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class OpacitySniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() @@ -52,7 +52,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true); + $next = $phpcsFile->findNext([T_COLON, T_WHITESPACE], ($stackPtr + 1), null, true); if ($next === false || ($tokens[$next]['code'] !== T_DNUMBER @@ -73,14 +73,14 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $next, 'DecimalPrecision'); } else if ($value === '0.0' || $value === '1.0') { $error = 'Opacity value does not require decimal point; use %s instead'; - $data = array($value{0}); + $data = [$value{0}]; $fix = $phpcsFile->addFixableError($error, $next, 'PointNotRequired', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken($next, $value{0}); } } else if ($value{0} === '.') { $error = 'Opacity values must not start with a decimal point; use 0%s instead'; - $data = array($value); + $data = [$value]; $fix = $phpcsFile->addFixableError($error, $next, 'StartWithPoint', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken($next, '0'.$value); diff --git a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php index 3b7b82483f..bf6e447eb5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php @@ -20,7 +20,7 @@ class SemicolonSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** @@ -30,7 +30,7 @@ class SemicolonSpacingSniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() @@ -58,7 +58,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[($semicolon - 1)]['code'] === T_WHITESPACE) { $length = strlen($tokens[($semicolon - 1)]['content']); $error = 'Expected 0 spaces before semicolon in style definition; %s found'; - $data = array($length); + $data = [$length]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($semicolon - 1), ''); diff --git a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php index acec0c4a84..1967312c8f 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php @@ -20,7 +20,7 @@ class ShorthandSizeSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('CSS'); + public $supportedTokenizers = ['CSS']; /** * A list of styles that we shouldn't check. @@ -29,13 +29,13 @@ class ShorthandSizeSniff implements Sniff * * @var array */ - protected $excludeStyles = array( - 'background-position' => 'background-position', - 'box-shadow' => 'box-shadow', - 'transform-origin' => 'transform-origin', - '-webkit-transform-origin' => '-webkit-transform-origin', - '-ms-transform-origin' => '-ms-transform-origin', - ); + protected $excludeStyles = [ + 'background-position' => 'background-position', + 'box-shadow' => 'box-shadow', + 'transform-origin' => 'transform-origin', + '-webkit-transform-origin' => '-webkit-transform-origin', + '-ms-transform-origin' => '-ms-transform-origin', + ]; /** @@ -45,7 +45,7 @@ class ShorthandSizeSniff implements Sniff */ public function register() { - return array(T_STYLE); + return [T_STYLE]; }//end register() @@ -83,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr) // Check if this style value is a set of numbers with optional prefixes. $content = preg_replace('/\s+/', ' ', $content); - $values = array(); + $values = []; $num = preg_match_all( '/([0-9]+)([a-zA-Z]{2}\s+|%\s+|\s+)/', $content.' ', @@ -109,7 +109,7 @@ public function process(File $phpcsFile, $stackPtr) if ($num === 3) { $expected = trim($content.' '.$values[1][1].$values[1][2]); $error = 'Shorthand syntax not allowed here; use %s instead'; - $data = array($expected); + $data = [$expected]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotAllowed', $data); if ($fix === true) { @@ -150,10 +150,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = preg_replace('/\s+/', ' ', trim($expected)); $error = 'Size definitions must use shorthand if available; expected "%s" but found "%s"'; - $data = array( - $expected, - $content, - ); + $data = [ + $expected, + $content, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotUsed', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php index 8bf54c0355..ee04e2280b 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php @@ -33,7 +33,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // Check that this is the only class or interface in the file. - $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), ($stackPtr + 1)); + $nextClass = $phpcsFile->findNext([T_CLASS, T_INTERFACE], ($stackPtr + 1)); if ($nextClass !== false) { // We have another, so an error is thrown. $error = 'Only one interface or class is allowed in a file'; @@ -70,10 +70,10 @@ public function processOpen(File $phpcsFile, $stackPtr) if ($spaces !== 0) { $type = strtolower($tokens[$stackPtr]['content']); $error = 'Expected 0 spaces before %s keyword; %s found'; - $data = array( - $type, - $spaces, - ); + $data = [ + $type, + $spaces, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeKeyword', $data); if ($fix === true) { @@ -133,7 +133,7 @@ public function processClose(File $phpcsFile, $stackPtr) || $tokens[$lastContent]['line'] === $tokens[$closeBrace]['line'] ) { $error = 'Closing %s brace must be on a line by itself'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'CloseBraceSameLine', $data); if ($fix === true) { if ($difference === -1) { @@ -155,7 +155,7 @@ public function processClose(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $closeBrace, 'NewLineBeforeCloseBrace'); } else { $error = 'Expected 0 spaces before closing brace; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpaceBeforeCloseBrace', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($closeBrace - 1), ''); @@ -167,14 +167,14 @@ public function processClose(File $phpcsFile, $stackPtr) if ($difference !== -1 && $difference !== 1) { $error = 'Closing brace of a %s must be followed by a single blank line; found %s'; - $data = array( - $tokens[$stackPtr]['content'], - $difference, - ); + $data = [ + $tokens[$stackPtr]['content'], + $difference, + ]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); if ($fix === true) { if ($difference === 0) { - $first = $phpcsFile->findFirstOnLine(array(), $nextContent, true); + $first = $phpcsFile->findFirstOnLine([], $nextContent, true); $phpcsFile->fixer->addNewlineBefore($first); } else { $phpcsFile->fixer->beginChangeset(); diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php index ef1e8f47a9..9990ad37cc 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php @@ -23,10 +23,10 @@ class ClassFileNameSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - ); + return [ + T_CLASS, + T_INTERFACE, + ]; }//end register() @@ -54,11 +54,11 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$decName]['content'] !== $fileName) { $error = '%s name doesn\'t match filename; expected "%s %s"'; - $data = array( - ucfirst($tokens[$stackPtr]['content']), - $tokens[$stackPtr]['content'], - $fileName, - ); + $data = [ + ucfirst($tokens[$stackPtr]['content']), + $tokens[$stackPtr]['content'], + $fileName, + ]; $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); } diff --git a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php index fc55f78e39..e975b751b9 100644 --- a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php @@ -20,7 +20,7 @@ class DuplicatePropertySniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -30,7 +30,7 @@ class DuplicatePropertySniff implements Sniff */ public function register() { - return array(T_OBJECT); + return [T_OBJECT]; }//end register() @@ -48,11 +48,11 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $properties = array(); - $wantedTokens = array( - T_PROPERTY, - T_OBJECT, - ); + $properties = []; + $wantedTokens = [ + T_PROPERTY, + T_OBJECT, + ]; $next = $phpcsFile->findNext($wantedTokens, ($stackPtr + 1), $tokens[$stackPtr]['bracket_closer']); while ($next !== false && $next < $tokens[$stackPtr]['bracket_closer']) { @@ -63,10 +63,10 @@ public function process(File $phpcsFile, $stackPtr) $propName = $tokens[$next]['content']; if (isset($properties[$propName]) === true) { $error = 'Duplicate property definition found for "%s"; previously defined on line %s'; - $data = array( - $propName, - $tokens[$properties[$propName]]['line'], - ); + $data = [ + $propName, + $tokens[$properties[$propName]]['line'], + ]; $phpcsFile->addError($error, $next, 'Found', $data); } diff --git a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php index 20eedc40d7..d764e2f79f 100644 --- a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php @@ -23,17 +23,17 @@ class LowercaseClassKeywordsSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_EXTENDS, - T_IMPLEMENTS, - T_ABSTRACT, - T_FINAL, - T_VAR, - T_CONST, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_EXTENDS, + T_IMPLEMENTS, + T_ABSTRACT, + T_FINAL, + T_VAR, + T_CONST, + ]; }//end register() @@ -54,11 +54,11 @@ public function process(File $phpcsFile, $stackPtr) $content = $tokens[$stackPtr]['content']; if ($content !== strtolower($content)) { $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); + $data = [ + strtoupper($content), + strtolower($content), + $content, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundUppercase', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index b012f41e94..8b6d966fc6 100644 --- a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -26,7 +26,7 @@ class SelfMemberReferenceSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS), array(T_DOUBLE_COLON)); + parent::__construct([T_CLASS], [T_DOUBLE_COLON]); }//end __construct() @@ -48,7 +48,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($tokens[$calledClassName]['code'] === T_SELF) { if ($tokens[$calledClassName]['content'] !== 'self') { $error = 'Must use "self::" for local static member reference; found "%s::"'; - $data = array($tokens[$calledClassName]['content']); + $data = [$tokens[$calledClassName]['content']]; $fix = $phpcsFile->addFixableError($error, $calledClassName, 'IncorrectCase', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken($calledClassName, 'self'); @@ -83,7 +83,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $fix = $phpcsFile->addFixableError($error, $calledClassName, 'NotUsed'); if ($fix === true) { - $prev = $phpcsFile->findPrevious(array(T_NS_SEPARATOR, T_STRING), ($stackPtr - 1), null, true); + $prev = $phpcsFile->findPrevious([T_NS_SEPARATOR, T_STRING], ($stackPtr - 1), null, true); $phpcsFile->fixer->beginChangeset(); for ($i = ($prev + 1); $i < $stackPtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); @@ -101,7 +101,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { $found = strlen($tokens[($stackPtr - 1)]['content']); $error = 'Expected 0 spaces before double colon; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $calledClassName, 'SpaceBefore', $data); if ($fix === true) { @@ -112,7 +112,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { $found = strlen($tokens[($stackPtr + 1)]['content']); $error = 'Expected 0 spaces after double colon; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $calledClassName, 'SpaceAfter', $data); if ($fix === true) { @@ -149,7 +149,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) */ protected function getDeclarationNameWithNamespace(array $tokens, $stackPtr) { - $nameParts = array(); + $nameParts = []; $currentPointer = $stackPtr; while ($tokens[$currentPointer]['code'] === T_NS_SEPARATOR || $tokens[$currentPointer]['code'] === T_STRING diff --git a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php index 53fce2659f..67963878fb 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php @@ -24,11 +24,11 @@ class ValidClassNameSniff implements Sniff */ public function register() { - return array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - ); + return [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + ]; }//end register() @@ -48,7 +48,7 @@ public function process(File $phpcsFile, $stackPtr) if (isset($tokens[$stackPtr]['scope_opener']) === false) { $error = 'Possible parse error: %s missing opening or closing brace'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); return; } @@ -70,10 +70,10 @@ public function process(File $phpcsFile, $stackPtr) if ($valid === false) { $type = ucfirst($tokens[$stackPtr]['content']); $error = '%s name "%s" is not in camel caps format'; - $data = array( - $type, - $name, - ); + $data = [ + $type, + $name, + ]; $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no'); } else { diff --git a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index 83c4c40226..7a3fa2376a 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -31,10 +31,10 @@ class BlockCommentSniff implements Sniff */ public function register() { - return array( - T_COMMENT, - T_DOC_COMMENT_OPEN_TAG, - ); + return [ + T_COMMENT, + T_DOC_COMMENT_OPEN_TAG, + ]; }//end register() @@ -70,20 +70,20 @@ public function process(File $phpcsFile, $stackPtr) // We are only interested in inline doc block comments. if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) { $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); - $ignore = array( - T_CLASS => true, - T_INTERFACE => true, - T_TRAIT => true, - T_FUNCTION => true, - T_PUBLIC => true, - T_PRIVATE => true, - T_FINAL => true, - T_PROTECTED => true, - T_STATIC => true, - T_ABSTRACT => true, - T_CONST => true, - T_VAR => true, - ); + $ignore = [ + T_CLASS => true, + T_INTERFACE => true, + T_TRAIT => true, + T_FUNCTION => true, + T_PUBLIC => true, + T_PRIVATE => true, + T_FINAL => true, + T_PROTECTED => true, + T_STATIC => true, + T_ABSTRACT => true, + T_CONST => true, + T_VAR => true, + ]; if (isset($ignore[$tokens[$nextToken]['code']]) === true) { return; } @@ -111,7 +111,7 @@ public function process(File $phpcsFile, $stackPtr) return; }//end if - $commentLines = array($stackPtr); + $commentLines = [$stackPtr]; $nextComment = $stackPtr; $lastLine = $tokens[$stackPtr]['line']; $commentString = $tokens[$stackPtr]['content']; @@ -212,10 +212,10 @@ public function process(File $phpcsFile, $stackPtr) $expected .= 's'; } - $data = array( - $expected, - $leadingSpace, - ); + $data = [ + $expected, + $leadingSpace, + ]; $error = 'First line of comment not aligned correctly; expected %s but found %s'; $fix = $phpcsFile->addFixableError($error, $commentLines[1], 'FirstLineIndent', $data); @@ -263,10 +263,10 @@ public function process(File $phpcsFile, $stackPtr) $expected .= 's'; } - $data = array( - $expected, - $leadingSpace, - ); + $data = [ + $expected, + $leadingSpace, + ]; $error = 'Comment line indented incorrectly; expected at least %s but found %s'; $fix = $phpcsFile->addFixableError($error, $line, 'LineIndent', $data); @@ -303,10 +303,10 @@ public function process(File $phpcsFile, $stackPtr) $expected .= ' spaces'; } - $data = array( - $expected, - $leadingSpace, - ); + $data = [ + $expected, + $leadingSpace, + ]; $error = 'Last line of comment aligned incorrectly; expected %s but found %s'; $phpcsFile->addError($error, $commentLines[$lastIndex], 'LastLineIndent', $data); diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php index 4a5f526705..ca28836d6d 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php @@ -32,7 +32,7 @@ class ClassCommentSniff implements Sniff */ public function register() { - return array(T_CLASS); + return [T_CLASS]; }//end register() @@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr) $commentStart = $tokens[$commentEnd]['comment_opener']; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { $error = '%s tag is not allowed in class comment'; - $data = array($tokens[$tag]['content']); + $data = [$tokens[$tag]['content']]; $phpcsFile->addWarning($error, $tag, 'TagNotAllowed', $data); } diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index 6555270f05..63975b6077 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -23,11 +23,11 @@ class ClosingDeclarationCommentSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLASS, - T_INTERFACE, - ); + return [ + T_FUNCTION, + T_CLASS, + T_INTERFACE, + ]; }//end register() @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) if (isset($tokens[$stackPtr]['scope_closer']) === false) { $error = 'Possible parse error: %s missing opening or closing brace'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); return; } @@ -87,7 +87,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $data = array($comment); + $data = [$comment]; if (isset($tokens[($closingBracket + 1)]) === false || $tokens[($closingBracket + 1)]['code'] !== T_COMMENT) { $next = $phpcsFile->findNext(T_WHITESPACE, ($closingBracket + 1), null, true); if (rtrim($tokens[$next]['content']) === $comment) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index 17f4bfd443..f52eddeb33 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -21,10 +21,10 @@ class DocCommentAlignmentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -34,7 +34,7 @@ class DocCommentAlignmentSniff implements Sniff */ public function register() { - return array(T_DOC_COMMENT_OPEN_TAG); + return [T_DOC_COMMENT_OPEN_TAG]; }//end register() @@ -61,20 +61,20 @@ public function process(File $phpcsFile, $stackPtr) } $nextToken = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); - $ignore = array( - T_CLASS => true, - T_INTERFACE => true, - T_FUNCTION => true, - T_PUBLIC => true, - T_PRIVATE => true, - T_PROTECTED => true, - T_STATIC => true, - T_ABSTRACT => true, - T_PROPERTY => true, - T_OBJECT => true, - T_PROTOTYPE => true, - T_VAR => true, - ); + $ignore = [ + T_CLASS => true, + T_INTERFACE => true, + T_FUNCTION => true, + T_PUBLIC => true, + T_PRIVATE => true, + T_PROTECTED => true, + T_STATIC => true, + T_ABSTRACT => true, + T_PROPERTY => true, + T_OBJECT => true, + T_PROTOTYPE => true, + T_VAR => true, + ]; if (isset($ignore[$tokens[$nextToken]['code']]) === false) { // Could be a file comment. @@ -105,10 +105,10 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$i]['column'] !== $requiredColumn) { $error = 'Expected %s space(s) before asterisk; %s found'; - $data = array( - ($requiredColumn - 1), - ($tokens[$i]['column'] - 1), - ); + $data = [ + ($requiredColumn - 1), + ($tokens[$i]['column'] - 1), + ]; $fix = $phpcsFile->addFixableError($error, $i, 'SpaceBeforeStar', $data); if ($fix === true) { $padding = str_repeat(' ', ($requiredColumn - 1)); @@ -139,7 +139,7 @@ public function process(File $phpcsFile, $stackPtr) && $tokens[($i + 1)]['content'] !== ' ' ) { $error = 'Expected 1 space after asterisk; %s found'; - $data = array(strlen($tokens[($i + 1)]['content'])); + $data = [strlen($tokens[($i + 1)]['content'])]; $fix = $phpcsFile->addFixableError($error, $i, 'SpaceAfterStar', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($i + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php index 30bd1c8c39..639d84884a 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php @@ -23,7 +23,7 @@ class EmptyCatchCommentSniff implements Sniff */ public function register() { - return array(T_CATCH); + return [T_CATCH]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index c829eada1f..ce32158d8a 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -20,10 +20,10 @@ class FileCommentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,7 +33,7 @@ class FileCommentSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -73,25 +73,25 @@ public function process(File $phpcsFile, $stackPtr) true ); - $ignore = array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_FUNCTION, - T_CLOSURE, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_FINAL, - T_STATIC, - T_ABSTRACT, - T_CONST, - T_PROPERTY, - T_INCLUDE, - T_INCLUDE_ONCE, - T_REQUIRE, - T_REQUIRE_ONCE, - ); + $ignore = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + T_CLOSURE, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_FINAL, + T_STATIC, + T_ABSTRACT, + T_CONST, + T_PROPERTY, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + ]; if (in_array($tokens[$nextToken]['code'], $ignore) === true) { $phpcsFile->addError('Missing file doc comment', $stackPtr, 'Missing'); @@ -115,21 +115,21 @@ public function process(File $phpcsFile, $stackPtr) } // Required tags in correct order. - $required = array( - '@package' => true, - '@subpackage' => true, - '@author' => true, - '@copyright' => true, - ); - - $foundTags = array(); + $required = [ + '@package' => true, + '@subpackage' => true, + '@author' => true, + '@copyright' => true, + ]; + + $foundTags = []; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { $name = $tokens[$tag]['content']; $isRequired = isset($required[$name]); if ($isRequired === true && in_array($name, $foundTags) === true) { $error = 'Only one %s tag is allowed in a file comment'; - $data = array($name); + $data = [$name]; $phpcsFile->addError($error, $tag, 'Duplicate'.ucfirst(substr($name, 1)).'Tag', $data); } @@ -142,7 +142,7 @@ public function process(File $phpcsFile, $stackPtr) $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd); if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) { $error = 'Content missing for %s tag in file comment'; - $data = array($name); + $data = [$name]; $phpcsFile->addError($error, $tag, 'Empty'.ucfirst(substr($name, 1)).'Tag', $data); continue; } @@ -161,7 +161,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration'; $fix = $phpcsFile->addFixableError($error, $tag, 'IncorrectCopyright'); if ($fix === true) { - $matches = array(); + $matches = []; preg_match('/^(([0-9]{4})(-[0-9]{4})?)?.*$/', $tokens[$string]['content'], $matches); if (isset($matches[1]) === false) { $matches[1] = date('Y'); @@ -179,7 +179,7 @@ public function process(File $phpcsFile, $stackPtr) foreach ($required as $tag => $true) { if (in_array($tag, $foundTags) === false) { $error = 'Missing %s tag in file comment'; - $data = array($tag); + $data = [$tag]; $phpcsFile->addError($error, $commentEnd, 'Missing'.ucfirst(substr($tag, 1)).'Tag', $data); } @@ -189,10 +189,10 @@ public function process(File $phpcsFile, $stackPtr) if ($foundTags[$pos] !== $tag) { $error = 'The tag in position %s should be the %s tag'; - $data = array( - ($pos + 1), - $tag, - ); + $data = [ + ($pos + 1), + $tag, + ]; $phpcsFile->addError($error, $tokens[$commentStart]['comment_tags'][$pos], ucfirst(substr($tag, 1)).'TagOrder', $data); } diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index b01bbd33cc..ff902dabe0 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -76,7 +76,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) // Check return type (can be multiple, separated by '|'). $typeNames = explode('|', $returnType); - $suggestedNames = array(); + $suggestedNames = []; foreach ($typeNames as $i => $typeName) { $suggestedName = Common::suggestType($typeName); if (in_array($suggestedName, $suggestedNames) === false) { @@ -87,10 +87,10 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) $suggestedType = implode('|', $suggestedNames); if ($returnType !== $suggestedType) { $error = 'Expected "%s" but found "%s" for function return type'; - $data = array( - $suggestedType, - $returnType, - ); + $data = [ + $suggestedType, + $returnType, + ]; $fix = $phpcsFile->addFixableError($error, $return, 'InvalidReturn', $data); if ($fix === true) { $replacement = $suggestedType; @@ -190,7 +190,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); - $throws = array(); + $throws = []; foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) { if ($tokens[$tag]['content'] !== '@throws') { continue; @@ -199,7 +199,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) $exception = null; $comment = null; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = []; preg_match('/([^\s]+)(?:\s+(.*))?/', $tokens[($tag + 2)]['content'], $matches); $exception = $matches[1]; if (isset($matches[2]) === true && trim($matches[2]) !== '') { @@ -266,7 +266,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $tokens = $phpcsFile->getTokens(); - $params = array(); + $params = []; $maxType = 0; $maxVar = 0; foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) { @@ -279,9 +279,9 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $var = ''; $varSpace = 0; $comment = ''; - $commentLines = array(); + $commentLines = []; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = []; preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches); if (empty($matches) === false) { @@ -304,11 +304,11 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) if (isset($matches[4]) === true) { $varSpace = strlen($matches[3]); $comment = $matches[4]; - $commentLines[] = array( - 'comment' => $comment, - 'token' => ($tag + 2), - 'indent' => $varSpace, - ); + $commentLines[] = [ + 'comment' => $comment, + 'token' => ($tag + 2), + 'indent' => $varSpace, + ]; // Any strings until the next tag belong to this comment. if (isset($tokens[$commentStart]['comment_tags'][($pos + 1)]) === true) { @@ -325,17 +325,17 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } $comment .= ' '.$tokens[$i]['content']; - $commentLines[] = array( - 'comment' => $tokens[$i]['content'], - 'token' => $i, - 'indent' => $indent, - ); + $commentLines[] = [ + 'comment' => $tokens[$i]['content'], + 'token' => $i, + 'indent' => $indent, + ]; } } } else { $error = 'Missing parameter comment'; $phpcsFile->addError($error, $tag, 'MissingParamComment'); - $commentLines[] = array('comment' => ''); + $commentLines[] = ['comment' => '']; }//end if } else { $error = 'Missing parameter name'; @@ -346,19 +346,19 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $phpcsFile->addError($error, $tag, 'MissingParamType'); }//end if - $params[] = array( - 'tag' => $tag, - 'type' => $type, - 'var' => $var, - 'comment' => $comment, - 'commentLines' => $commentLines, - 'type_space' => $typeSpace, - 'var_space' => $varSpace, - ); + $params[] = [ + 'tag' => $tag, + 'type' => $type, + 'var' => $var, + 'comment' => $comment, + 'commentLines' => $commentLines, + 'type_space' => $typeSpace, + 'var_space' => $varSpace, + ]; }//end foreach $realParams = $phpcsFile->getMethodParameters($stackPtr); - $foundParams = array(); + $foundParams = []; // We want to use ... for all variable length arguments, so added // this prefix to the variable name so comparisons are easier. @@ -376,7 +376,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) // Check the param type value. $typeNames = explode('|', $param['type']); - $suggestedTypeNames = array(); + $suggestedTypeNames = []; foreach ($typeNames as $typeName) { // Strip nullable operator. @@ -423,10 +423,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) if ($typeHint === '') { $error = 'Type hint "%s" missing for %s'; - $data = array( - $suggestedTypeHint, - $param['var'], - ); + $data = [ + $suggestedTypeHint, + $param['var'], + ]; $errorCode = 'TypeHintMissing'; if ($suggestedTypeHint === 'string' @@ -440,21 +440,21 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $phpcsFile->addError($error, $stackPtr, $errorCode, $data); } else if ($typeHint !== $suggestedTypeHint && $typeHint !== '?'.$suggestedTypeHint) { $error = 'Expected type hint "%s"; found "%s" for %s'; - $data = array( - $suggestedTypeHint, - $typeHint, - $param['var'], - ); + $data = [ + $suggestedTypeHint, + $typeHint, + $param['var'], + ]; $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data); }//end if } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) { $typeHint = $realParams[$pos]['type_hint']; if ($typeHint !== '') { $error = 'Unknown type hint "%s" found for %s'; - $data = array( - $typeHint, - $param['var'], - ); + $data = [ + $typeHint, + $param['var'], + ]; $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data); } }//end if @@ -463,10 +463,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $suggestedType = implode($suggestedTypeNames, '|'); if ($param['type'] !== $suggestedType) { $error = 'Expected "%s" but found "%s" for parameter type'; - $data = array( - $suggestedType, - $param['type'], - ); + $data = [ + $suggestedType, + $param['type'], + ]; $fix = $phpcsFile->addFixableError($error, $param['tag'], 'IncorrectParamVarName', $data); if ($fix === true) { @@ -516,10 +516,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $realName = $realParams[$pos]['name']; if ($realName !== $param['var']) { $code = 'ParamNameNoMatch'; - $data = array( - $param['var'], - $realName, - ); + $data = [ + $param['var'], + $realName, + ]; $error = 'Doc comment for parameter %s does not match '; if (strtolower($param['var']) === strtolower($realName)) { @@ -557,7 +557,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } }//end foreach - $realNames = array(); + $realNames = []; foreach ($realParams as $realParam) { $realNames[] = $realParam['name']; } @@ -566,7 +566,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $diff = array_diff($realNames, $foundParams); foreach ($diff as $neededParam) { $error = 'Doc comment for parameter "%s" missing'; - $data = array($neededParam); + $data = [$neededParam]; $phpcsFile->addError($error, $commentStart, 'MissingParamTag', $data); } @@ -589,10 +589,10 @@ protected function checkSpacingAfterParamType(File $phpcsFile, $param, $maxType, $spaces = ($maxType - strlen($param['type']) + $spacing); if ($param['type_space'] !== $spaces) { $error = 'Expected %s spaces after parameter type; %s found'; - $data = array( - $spaces, - $param['type_space'], - ); + $data = [ + $spaces, + $param['type_space'], + ]; $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data); if ($fix === true) { @@ -644,10 +644,10 @@ protected function checkSpacingAfterParamName(File $phpcsFile, $param, $maxVar, $spaces = ($maxVar - strlen($param['var']) + $spacing); if ($param['var_space'] !== $spaces) { $error = 'Expected %s spaces after parameter name; %s found'; - $data = array( - $spaces, - $param['var_space'], - ); + $data = [ + $spaces, + $param['var_space'], + ]; $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php index c0f6bdcaaa..ef00188d5e 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php @@ -22,7 +22,7 @@ class FunctionCommentThrowTagSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_FUNCTION), array(T_THROW)); + parent::__construct([T_FUNCTION], [T_THROW]); }//end __construct() @@ -66,7 +66,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $currScopeEnd = $tokens[$currScope]['scope_closer']; // Find all the exception type token within the current scope. - $thrownExceptions = array(); + $thrownExceptions = []; $currPos = $stackPtr; $foundThrows = false; while ($currPos < $currScopeEnd && $currPos !== false) { @@ -90,10 +90,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($currPos + 1), null, true); if ($tokens[$nextToken]['code'] === T_NEW) { $currException = $phpcsFile->findNext( - array( - T_NS_SEPARATOR, - T_STRING, - ), + [ + T_NS_SEPARATOR, + T_STRING, + ], $currPos, $currScopeEnd, false, @@ -103,10 +103,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($currException !== false) { $endException = $phpcsFile->findNext( - array( - T_NS_SEPARATOR, - T_STRING, - ), + [ + T_NS_SEPARATOR, + T_STRING, + ], ($currException + 1), $currScopeEnd, true, @@ -160,7 +160,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop // Only need one @throws tag for each type of exception thrown. $thrownExceptions = array_unique($thrownExceptions); - $throwTags = array(); + $throwTags = []; $commentStart = $tokens[$commentEnd]['comment_opener']; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { if ($tokens[$tag]['content'] !== '@throws') { @@ -194,10 +194,10 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $tagCount = count($throwTags); if ($thrownCount !== $tagCount) { $error = 'Expected %s @throws tag(s) in function comment; %s found'; - $data = array( - $thrownCount, - $tagCount, - ); + $data = [ + $thrownCount, + $tagCount, + ]; $phpcsFile->addError($error, $commentEnd, 'WrongNumber', $data); return; } @@ -205,7 +205,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop foreach ($thrownExceptions as $throw) { if (isset($throwTags[$throw]) === false) { $error = 'Missing @throws tag for "%s" exception'; - $data = array($throw); + $data = [$throw]; $phpcsFile->addError($error, $commentEnd, 'Missing', $data); } } diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index 55f5e14584..dc04605e63 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -21,10 +21,10 @@ class InlineCommentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -34,10 +34,10 @@ class InlineCommentSniff implements Sniff */ public function register() { - return array( - T_COMMENT, - T_DOC_COMMENT_OPEN_TAG, - ); + return [ + T_COMMENT, + T_DOC_COMMENT_OPEN_TAG, + ]; }//end register() @@ -66,25 +66,25 @@ public function process(File $phpcsFile, $stackPtr) true ); - $ignore = array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_FUNCTION, - T_CLOSURE, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_FINAL, - T_STATIC, - T_ABSTRACT, - T_CONST, - T_PROPERTY, - T_INCLUDE, - T_INCLUDE_ONCE, - T_REQUIRE, - T_REQUIRE_ONCE, - ); + $ignore = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + T_CLOSURE, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_FINAL, + T_STATIC, + T_ABSTRACT, + T_CONST, + T_PROPERTY, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + ]; if (in_array($tokens[$nextToken]['code'], $ignore) === true) { return; @@ -180,25 +180,25 @@ public function process(File $phpcsFile, $stackPtr) $fix = false; if ($tabFound === true) { $error = 'Tab found before comment text; expected "// %s" but found "%s"'; - $data = array( - ltrim(substr($comment, 2)), - $comment, - ); + $data = [ + ltrim(substr($comment, 2)), + $comment, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TabBefore', $data); } else if ($spaceCount === 0) { $error = 'No space found before comment text; expected "// %s" but found "%s"'; - $data = array( - substr($comment, 2), - $comment, - ); + $data = [ + substr($comment, 2), + $comment, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceBefore', $data); } else if ($spaceCount > 1) { $error = 'Expected 1 space before comment text but found %s; use block comment if you need indentation'; - $data = array( - $spaceCount, - substr($comment, (2 + $spaceCount)), - $comment, - ); + $data = [ + $spaceCount, + substr($comment, (2 + $spaceCount)), + $comment, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBefore', $data); }//end if @@ -223,7 +223,7 @@ public function process(File $phpcsFile, $stackPtr) $topComment = $stackPtr; $lastComment = $stackPtr; - while (($topComment = $phpcsFile->findPrevious(array(T_COMMENT), ($lastComment - 1), null, false)) !== false) { + while (($topComment = $phpcsFile->findPrevious([T_COMMENT], ($lastComment - 1), null, false)) !== false) { if ($tokens[$topComment]['line'] !== ($tokens[$lastComment]['line'] - 1)) { break; } @@ -264,11 +264,11 @@ public function process(File $phpcsFile, $stackPtr) // is a letter, indicating that the comment is just standard text. if (preg_match('/^\p{L}/u', $commentText) === 1) { $commentCloser = $commentText[(strlen($commentText) - 1)]; - $acceptedClosers = array( - 'full-stops' => '.', - 'exclamation marks' => '!', - 'or question marks' => '?', - ); + $acceptedClosers = [ + 'full-stops' => '.', + 'exclamation marks' => '!', + 'or question marks' => '?', + ]; if (in_array($commentCloser, $acceptedClosers) === false) { $error = 'Inline comments must end in %s'; @@ -278,7 +278,7 @@ public function process(File $phpcsFile, $stackPtr) } $ender = trim($ender, ' ,'); - $data = array($ender); + $data = [$ender]; $phpcsFile->addError($error, $stackPtr, 'InvalidEndChar', $data); } } diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 3aa1b62286..6128f27a86 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -20,25 +20,25 @@ class LongConditionClosingCommentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The openers that we are interested in. * * @var integer[] */ - private static $openers = array( - T_SWITCH, - T_IF, - T_FOR, - T_FOREACH, - T_WHILE, - T_TRY, - T_CASE, - ); + private static $openers = [ + T_SWITCH, + T_IF, + T_FOR, + T_FOREACH, + T_WHILE, + T_TRY, + T_CASE, + ]; /** * The length that a code block must be before @@ -65,7 +65,7 @@ class LongConditionClosingCommentSniff implements Sniff */ public function register() { - return array(T_CLOSE_CURLY_BRACKET); + return [T_CLOSE_CURLY_BRACKET]; }//end register() @@ -157,12 +157,12 @@ public function process(File $phpcsFile, $stackPtr) $lineDifference = ($endBrace['line'] - $startBrace['line']); $expected = sprintf($this->commentFormat, $startCondition['content']); - $comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false); + $comment = $phpcsFile->findNext([T_COMMENT], $stackPtr, null, false); if (($comment === false) || ($tokens[$comment]['line'] !== $endBrace['line'])) { if ($lineDifference >= $this->lineLimit) { $error = 'End comment for long condition not found; expected "%s"'; - $data = array($expected); + $data = [$expected]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Missing', $data); if ($fix === true) { @@ -180,17 +180,17 @@ public function process(File $phpcsFile, $stackPtr) if (($comment - $stackPtr) !== 1) { $error = 'Space found before closing comment; expected "%s"'; - $data = array($expected); + $data = [$expected]; $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); } if (trim($tokens[$comment]['content']) !== $expected) { $found = trim($tokens[$comment]['content']); $error = 'Incorrect closing comment; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Invalid', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php index 8cb9ff132f..9c01a7658d 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php @@ -20,10 +20,10 @@ class PostStatementCommentSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,7 +33,7 @@ class PostStatementCommentSniff implements Sniff */ public function register() { - return array(T_COMMENT); + return [T_COMMENT]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 597d7ec854..c52d4682fe 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -29,14 +29,14 @@ class VariableCommentSniff extends AbstractVariableSniff public function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $ignore = array( - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_VAR, - T_STATIC, - T_WHITESPACE, - ); + $ignore = [ + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_VAR, + T_STATIC, + T_WHITESPACE, + ]; $commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); if ($commentEnd === false @@ -72,7 +72,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) } } else { $error = '%s tag is not allowed in member variable comment'; - $data = array($tokens[$tag]['content']); + $data = [$tokens[$tag]['content']]; $phpcsFile->addWarning($error, $tag, 'TagNotAllowed', $data); }//end if }//end foreach @@ -102,10 +102,10 @@ public function processMemberVar(File $phpcsFile, $stackPtr) $suggestedType = Common::suggestType($varType); if ($varType !== $suggestedType) { $error = 'Expected "%s" but found "%s" for @var tag in member variable comment'; - $data = array( - $suggestedType, - $varType, - ); + $data = [ + $suggestedType, + $varType, + ]; $fix = $phpcsFile->addFixableError($error, ($foundVar + 2), 'IncorrectVarType', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index 4318adac01..5a67eb0e2a 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -28,10 +28,10 @@ class ControlSignatureSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -41,18 +41,18 @@ class ControlSignatureSniff implements Sniff */ public function register() { - return array( - T_TRY, - T_CATCH, - T_DO, - T_WHILE, - T_FOR, - T_IF, - T_FOREACH, - T_ELSE, - T_ELSEIF, - T_SWITCH, - ); + return [ + T_TRY, + T_CATCH, + T_DO, + T_WHILE, + T_FOR, + T_IF, + T_FOREACH, + T_ELSE, + T_ELSEIF, + T_SWITCH, + ]; }//end register() @@ -103,11 +103,11 @@ public function process(File $phpcsFile, $stackPtr) if ($found !== $expected) { $error = 'Expected %s space(s) after %s keyword; %s found'; - $data = array( - $expected, - strtoupper($tokens[$stackPtr]['content']), - $found, - ); + $data = [ + $expected, + strtoupper($tokens[$stackPtr]['content']), + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data); if ($fix === true) { @@ -144,10 +144,10 @@ public function process(File $phpcsFile, $stackPtr) if ($found !== $expected) { $error = 'Expected %s space(s) after closing parenthesis; found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseParenthesis', $data); if ($fix === true) { @@ -241,7 +241,7 @@ public function process(File $phpcsFile, $stackPtr) if ($found !== 0) { $error = 'Expected 0 spaces before semicolon; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceBeforeSemicolon', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($closer + 1), ''); @@ -290,7 +290,7 @@ public function process(File $phpcsFile, $stackPtr) if ($found !== 1) { $error = 'Expected 1 space after closing brace; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data); if ($fix === true) { if ($found === 0) { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index bece3882e3..422b0d8569 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -23,7 +23,7 @@ class ElseIfDeclarationSniff implements Sniff */ public function register() { - return array(T_ELSEIF); + return [T_ELSEIF]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php index 2d3d41a1ea..30cb65d9e2 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php @@ -38,7 +38,7 @@ class ForEachLoopDeclarationSniff implements Sniff */ public function register() { - return array(T_FOREACH); + return [T_FOREACH]; }//end register() @@ -87,10 +87,10 @@ public function process(File $phpcsFile, $stackPtr) if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) { $error = 'Expected %s spaces after opening bracket; %s found'; - $data = array( - $this->requiredSpacesAfterOpen, - $spaceAfterOpen, - ); + $data = [ + $this->requiredSpacesAfterOpen, + $spaceAfterOpen, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterOpen', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesAfterOpen); @@ -117,10 +117,10 @@ public function process(File $phpcsFile, $stackPtr) if ($spaceBeforeClose !== $this->requiredSpacesBeforeClose) { $error = 'Expected %s spaces before closing bracket; %s found'; - $data = array( - $this->requiredSpacesBeforeClose, - $spaceBeforeClose, - ); + $data = [ + $this->requiredSpacesBeforeClose, + $spaceBeforeClose, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeClose', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesBeforeClose); @@ -144,10 +144,10 @@ public function process(File $phpcsFile, $stackPtr) if ($content !== strtolower($content)) { $expected = strtolower($content); $error = 'AS keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $content, - ); + $data = [ + $expected, + $content, + ]; $fix = $phpcsFile->addFixableError($error, $asToken, 'AsNotLower', $data); if ($fix === true) { @@ -168,7 +168,7 @@ public function process(File $phpcsFile, $stackPtr) if (strlen($tokens[($doubleArrow - 1)]['content']) !== 1) { $spaces = strlen($tokens[($doubleArrow - 1)]['content']); $error = 'Expected 1 space before "=>"; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeArrow', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($doubleArrow - 1), ' '); @@ -186,7 +186,7 @@ public function process(File $phpcsFile, $stackPtr) if (strlen($tokens[($doubleArrow + 1)]['content']) !== 1) { $spaces = strlen($tokens[($doubleArrow + 1)]['content']); $error = 'Expected 1 space after "=>"; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterArrow', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($doubleArrow + 1), ' '); @@ -205,7 +205,7 @@ public function process(File $phpcsFile, $stackPtr) if (strlen($tokens[($asToken - 1)]['content']) !== 1) { $spaces = strlen($tokens[($asToken - 1)]['content']); $error = 'Expected 1 space before "as"; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeAs', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($asToken - 1), ' '); @@ -223,7 +223,7 @@ public function process(File $phpcsFile, $stackPtr) if (strlen($tokens[($asToken + 1)]['content']) !== 1) { $spaces = strlen($tokens[($asToken + 1)]['content']); $error = 'Expected 1 space after "as"; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterAs', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($asToken + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index dd0eb5f89c..6afd8ae370 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -34,10 +34,10 @@ class ForLoopDeclarationSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -47,7 +47,7 @@ class ForLoopDeclarationSniff implements Sniff */ public function register() { - return array(T_FOR); + return [T_FOR]; }//end register() @@ -90,10 +90,10 @@ public function process(File $phpcsFile, $stackPtr) if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) { $error = 'Expected %s spaces after opening bracket; %s found'; - $data = array( - $this->requiredSpacesAfterOpen, - $spaceAfterOpen, - ); + $data = [ + $this->requiredSpacesAfterOpen, + $spaceAfterOpen, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterOpen', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesAfterOpen); @@ -120,10 +120,10 @@ public function process(File $phpcsFile, $stackPtr) if ($this->requiredSpacesBeforeClose !== $spaceBeforeClose) { $error = 'Expected %s spaces before closing bracket; %s found'; - $data = array( - $this->requiredSpacesBeforeClose, - $spaceBeforeClose, - ); + $data = [ + $this->requiredSpacesBeforeClose, + $spaceBeforeClose, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeClose', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesBeforeClose); @@ -160,7 +160,7 @@ public function process(File $phpcsFile, $stackPtr) if (strlen($tokens[($firstSemicolon + 1)]['content']) !== 1) { $spaces = strlen($tokens[($firstSemicolon + 1)]['content']); $error = 'Expected 1 space after first semicolon of FOR loop; %s found'; - $data = array($spaces); + $data = [$spaces]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterFirst', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($firstSemicolon + 1), ' '); @@ -192,7 +192,7 @@ public function process(File $phpcsFile, $stackPtr) } else { if (strlen($tokens[($secondSemicolon + 1)]['content']) !== 1) { $spaces = strlen($tokens[($secondSemicolon + 1)]['content']); - $data = array($spaces); + $data = [$spaces]; if (($secondSemicolon + 2) === $closingBracket) { $error = 'Expected no space after second semicolon of FOR loop; %s found'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterSecondNoThird', $data); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php index 4742da6fbe..f6513329d7 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php @@ -23,7 +23,7 @@ class InlineIfDeclarationSniff implements Sniff */ public function register() { - return array(T_INLINE_THEN); + return [T_INLINE_THEN]; }//end register() @@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr) // semicolon (end of statement) or comma (end of array value) // then assume the content before the closing parenthesis is the end. $else = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1)); - $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_COMMA), ($else + 1), $closeBracket); + $statementEnd = $phpcsFile->findNext([T_SEMICOLON, T_COMMA], ($else + 1), $closeBracket); if ($statementEnd === false) { $statementEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true); } @@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr) $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length'])); if ($spaceBefore !== 1) { $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found'; - $data = array($spaceBefore); + $data = [$spaceBefore]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeThen', $data); if ($fix === true) { if ($spaceBefore === 0) { @@ -105,7 +105,7 @@ public function process(File $phpcsFile, $stackPtr) $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1)); if ($spaceAfter !== 1) { $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found'; - $data = array($spaceAfter); + $data = [$spaceAfter]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterThen', $data); if ($fix === true) { if ($spaceAfter === 0) { @@ -122,7 +122,7 @@ public function process(File $phpcsFile, $stackPtr) $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length'])); if ($spaceBefore !== 1) { $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found'; - $data = array($spaceBefore); + $data = [$spaceBefore]; $fix = $phpcsFile->addFixableError($error, $inlineElse, 'SpacingBeforeElse', $data); if ($fix === true) { if ($spaceBefore === 0) { @@ -138,7 +138,7 @@ public function process(File $phpcsFile, $stackPtr) $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1)); if ($spaceAfter !== 1) { $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found'; - $data = array($spaceAfter); + $data = [$spaceAfter]; $fix = $phpcsFile->addFixableError($error, $inlineElse, 'SpacingAfterElse', $data); if ($fix === true) { if ($spaceAfter === 0) { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php index f5e1af83a3..e2ba95e233 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php @@ -23,18 +23,18 @@ class LowercaseDeclarationSniff implements Sniff */ public function register() { - return array( - T_IF, - T_ELSE, - T_ELSEIF, - T_FOREACH, - T_FOR, - T_DO, - T_SWITCH, - T_WHILE, - T_TRY, - T_CATCH, - ); + return [ + T_IF, + T_ELSE, + T_ELSEIF, + T_FOREACH, + T_FOR, + T_DO, + T_SWITCH, + T_WHILE, + T_TRY, + T_CATCH, + ]; }//end register() @@ -55,11 +55,11 @@ public function process(File $phpcsFile, $stackPtr) $content = $tokens[$stackPtr]['content']; if ($content !== strtolower($content)) { $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); + $data = [ + strtoupper($content), + strtolower($content), + $content, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundUppercase', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 5931c062c3..c1c508ee80 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -21,10 +21,10 @@ class SwitchDeclarationSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * The number of spaces code should be indented. @@ -41,7 +41,7 @@ class SwitchDeclarationSniff implements Sniff */ public function register() { - return array(T_SWITCH); + return [T_SWITCH]; }//end register() @@ -72,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr) $caseCount = 0; $foundDefault = false; - while (($nextCase = $phpcsFile->findNext(array(T_CASE, T_DEFAULT, T_SWITCH), ($nextCase + 1), $switch['scope_closer'])) !== false) { + while (($nextCase = $phpcsFile->findNext([T_CASE, T_DEFAULT, T_SWITCH], ($nextCase + 1), $switch['scope_closer'])) !== false) { // Skip nested SWITCH statements; they are handled on their own. if ($tokens[$nextCase]['code'] === T_SWITCH) { $nextCase = $tokens[$nextCase]['scope_closer']; @@ -90,10 +90,10 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) { $expected = strtolower($tokens[$nextCase]['content']); $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $tokens[$nextCase]['content'], - ); + $data = [ + $expected, + $tokens[$nextCase]['content'], + ]; $fix = $phpcsFile->addFixableError($error, $nextCase, $type.'NotLower', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index c4e1d7b045..14dc5c2988 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -21,7 +21,7 @@ class JSLintSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -31,7 +31,7 @@ class JSLintSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) if (is_array($output) === true) { foreach ($output as $finding) { - $matches = array(); + $matches = []; $numMatches = preg_match('/Lint at line ([0-9]+).*:(.*)$/', $finding, $matches); if ($numMatches === 0) { continue; diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index 539228a511..a67e3fd3b6 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -22,7 +22,7 @@ class JavaScriptLintSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -32,7 +32,7 @@ class JavaScriptLintSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php index 4cbcb3bbb3..5bc8384691 100644 --- a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php +++ b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php @@ -23,7 +23,7 @@ class FileExtensionSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -42,13 +42,13 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $fileName = $phpcsFile->getFileName(); $extension = substr($fileName, strrpos($fileName, '.')); - $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_TRAIT), $stackPtr); + $nextClass = $phpcsFile->findNext([T_CLASS, T_INTERFACE, T_TRAIT], $stackPtr); if ($nextClass !== false) { $phpcsFile->recordMetric($stackPtr, 'File extension for class files', $extension); if ($extension === '.php') { $error = '%s found in ".php" file; use ".inc" extension instead'; - $data = array(ucfirst($tokens[$nextClass]['content'])); + $data = [ucfirst($tokens[$nextClass]['content'])]; $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data); } } else { diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index 07defa4499..4b05dc1d9d 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -21,10 +21,10 @@ class OperatorBracketSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -99,14 +99,14 @@ public function process(File $phpcsFile, $stackPtr) if ($previousToken !== false) { // A list of tokens that indicate that the token is not // part of an arithmetic operation. - $invalidTokens = array( - T_COMMA, - T_COLON, - T_OPEN_PARENTHESIS, - T_OPEN_SQUARE_BRACKET, - T_OPEN_SHORT_ARRAY, - T_CASE, - ); + $invalidTokens = [ + T_COMMA, + T_COLON, + T_OPEN_PARENTHESIS, + T_OPEN_SQUARE_BRACKET, + T_OPEN_SHORT_ARRAY, + T_CASE, + ]; if (in_array($tokens[$previousToken]['code'], $invalidTokens) === true) { return; @@ -128,22 +128,22 @@ public function process(File $phpcsFile, $stackPtr) } // Tokens that are allowed inside a bracketed operation. - $allowed = array( - T_VARIABLE, - T_LNUMBER, - T_DNUMBER, - T_STRING, - T_WHITESPACE, - T_NS_SEPARATOR, - T_THIS, - T_SELF, - T_OBJECT_OPERATOR, - T_DOUBLE_COLON, - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - T_MODULUS, - T_NONE, - ); + $allowed = [ + T_VARIABLE, + T_LNUMBER, + T_DNUMBER, + T_STRING, + T_WHITESPACE, + T_NS_SEPARATOR, + T_THIS, + T_SELF, + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + T_MODULUS, + T_NONE, + ]; $allowed += Tokens::$operators; @@ -230,10 +230,10 @@ public function process(File $phpcsFile, $stackPtr) // We are enclosed in a set of bracket, so the last thing to // check is that we are not also enclosed in square brackets // like this: ($array[$index + 1]), which is invalid. - $brackets = array( - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - ); + $brackets = [ + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + ]; $squareBracket = $phpcsFile->findPrevious($brackets, ($stackPtr - 1), $lastBracket); if ($squareBracket !== false && $tokens[$squareBracket]['code'] === T_OPEN_SQUARE_BRACKET) { @@ -274,22 +274,22 @@ public function addMissingBracketsError($phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); - $allowed = array( - T_VARIABLE => true, - T_LNUMBER => true, - T_DNUMBER => true, - T_STRING => true, - T_WHITESPACE => true, - T_NS_SEPARATOR => true, - T_THIS => true, - T_SELF => true, - T_OBJECT_OPERATOR => true, - T_DOUBLE_COLON => true, - T_MODULUS => true, - T_ISSET => true, - T_ARRAY => true, - T_NONE => true, - ); + $allowed = [ + T_VARIABLE => true, + T_LNUMBER => true, + T_DNUMBER => true, + T_STRING => true, + T_WHITESPACE => true, + T_NS_SEPARATOR => true, + T_THIS => true, + T_SELF => true, + T_OBJECT_OPERATOR => true, + T_DOUBLE_COLON => true, + T_MODULUS => true, + T_ISSET => true, + T_ARRAY => true, + T_NONE => true, + ]; // Find the first token in the expression. for ($before = ($stackPtr - 1); $before > 0; $before--) { diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index 47e992475a..67eb63588b 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -44,10 +44,10 @@ class FunctionDeclarationArgumentSpacingSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -107,7 +107,7 @@ public function processBracket($phpcsFile, $openBracket) $multiLine = ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']); $nextParam = $openBracket; - $params = array(); + $params = []; while (($nextParam = $phpcsFile->findNext(T_VARIABLE, ($nextParam + 1), $closeBracket)) !== false) { $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextParam + 1), ($closeBracket + 1), true); if ($nextToken === false) { @@ -125,10 +125,10 @@ public function processBracket($phpcsFile, $openBracket) if ($spacesBefore !== $this->equalsSpacing) { $error = 'Incorrect spacing between argument "%s" and equals sign; expected '.$this->equalsSpacing.' but found %s'; - $data = array( - $tokens[$nextParam]['content'], - $spacesBefore, - ); + $data = [ + $tokens[$nextParam]['content'], + $spacesBefore, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeEquals', $data); if ($fix === true) { @@ -148,10 +148,10 @@ public function processBracket($phpcsFile, $openBracket) if ($spacesAfter !== $this->equalsSpacing) { $error = 'Incorrect spacing between default value and equals sign for argument "%s"; expected '.$this->equalsSpacing.' but found %s'; - $data = array( - $tokens[$nextParam]['content'], - $spacesAfter, - ); + $data = [ + $tokens[$nextParam]['content'], + $spacesAfter, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceAfterDefault', $data); if ($fix === true) { @@ -171,10 +171,10 @@ public function processBracket($phpcsFile, $openBracket) // Comma found. if ($tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { $error = 'Expected 0 spaces between argument "%s" and comma; %s found'; - $data = array( - $tokens[$nextParam]['content'], - strlen($tokens[($nextComma - 1)]['content']), - ); + $data = [ + $tokens[$nextParam]['content'], + strlen($tokens[($nextComma - 1)]['content']), + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data); if ($fix === true) { @@ -220,10 +220,10 @@ public function processBracket($phpcsFile, $openBracket) if ($gap !== 1) { $error = 'Expected 1 space between type hint and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); + $data = [ + $arg, + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterHint', $data); if ($fix === true) { if ($gap === 0) { @@ -237,7 +237,7 @@ public function processBracket($phpcsFile, $openBracket) if ($multiLine === false) { if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { $error = 'Expected 1 space between comma and type hint "%s"; 0 found'; - $data = array($hint); + $data = [$hint]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeHint', $data); if ($fix === true) { $phpcsFile->fixer->addContent($comma, ' '); @@ -246,10 +246,10 @@ public function processBracket($phpcsFile, $openBracket) $gap = strlen($tokens[($comma + 1)]['content']); if ($gap !== 1) { $error = 'Expected 1 space between comma and type hint "%s"; %s found'; - $data = array( - $hint, - $gap, - ); + $data = [ + $hint, + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingBeforeHint', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($comma + 1), ' '); @@ -261,7 +261,7 @@ public function processBracket($phpcsFile, $openBracket) // No type hint. if ($gap === 0) { $error = 'Expected 1 space between comma and argument "%s"; 0 found'; - $data = array($arg); + $data = [$arg]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeArg', $data); if ($fix === true) { $phpcsFile->fixer->addContent($whitespace, ' '); @@ -270,10 +270,10 @@ public function processBracket($phpcsFile, $openBracket) // Just make sure this is not actually an indent. if ($tokens[$whitespace]['line'] === $tokens[($whitespace - 1)]['line']) { $error = 'Expected 1 space between comma and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); + $data = [ + $arg, + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingBeforeArg', $data); if ($fix === true) { @@ -304,10 +304,10 @@ public function processBracket($phpcsFile, $openBracket) if ($gap !== 1) { $error = 'Expected 1 space between type hint and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); + $data = [ + $arg, + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterHint', $data); if ($fix === true) { if ($gap === 0) { @@ -325,11 +325,11 @@ public function processBracket($phpcsFile, $openBracket) if ($multiLine === false && $spaceAfterOpen !== $this->requiredSpacesAfterOpen) { $error = 'Expected %s spaces between opening bracket and type hint "%s"; %s found'; - $data = array( - $this->requiredSpacesAfterOpen, - $hint, - $spaceAfterOpen, - ); + $data = [ + $this->requiredSpacesAfterOpen, + $hint, + $spaceAfterOpen, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterOpenHint', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesAfterOpen); @@ -342,11 +342,11 @@ public function processBracket($phpcsFile, $openBracket) } } else if ($multiLine === false && $gap !== $this->requiredSpacesAfterOpen) { $error = 'Expected %s spaces between opening bracket and argument "%s"; %s found'; - $data = array( - $this->requiredSpacesAfterOpen, - $arg, - $gap, - ); + $data = [ + $this->requiredSpacesAfterOpen, + $arg, + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterOpen', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesAfterOpen); @@ -371,7 +371,7 @@ public function processBracket($phpcsFile, $openBracket) // There are no parameters for this function. if (($closeBracket - $openBracket) !== 1) { $error = 'Expected 0 spaces between brackets of function declaration; %s found'; - $data = array($gap); + $data = [$gap]; $fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingBetween', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($openBracket + 1), ''); @@ -380,11 +380,11 @@ public function processBracket($phpcsFile, $openBracket) } else if ($multiLine === false && $gap !== $this->requiredSpacesBeforeClose) { $lastParam = array_pop($params); $error = 'Expected %s spaces between argument "%s" and closing bracket; %s found'; - $data = array( - $this->requiredSpacesBeforeClose, - $tokens[$lastParam]['content'], - $gap, - ); + $data = [ + $this->requiredSpacesBeforeClose, + $tokens[$lastParam]['content'], + $gap, + ]; $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpacingBeforeClose', $data); if ($fix === true) { $padding = str_repeat(' ', $this->requiredSpacesBeforeClose); diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php index 6fcb2a2377..4b6a6acfdf 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php @@ -22,11 +22,11 @@ class FunctionDeclarationSniff extends AbstractPatternSniff */ protected function getPatterns() { - return array( - 'function abc(...);', - 'function abc(...)', - 'abstract function abc(...);', - ); + return [ + 'function abc(...);', + 'function abc(...)', + 'abstract function abc(...);', + ]; }//end getPatterns() diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php index ac82323953..da3f9249b2 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php @@ -23,7 +23,7 @@ class FunctionDuplicateArgumentSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -44,13 +44,13 @@ public function process(File $phpcsFile, $stackPtr) $openBracket = $tokens[$stackPtr]['parenthesis_opener']; $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - $foundVariables = array(); + $foundVariables = []; for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { if ($tokens[$i]['code'] === T_VARIABLE) { $variable = $tokens[$i]['content']; if (in_array($variable, $foundVariables) === true) { $error = 'Variable "%s" appears more than once in function declaration'; - $data = array($variable); + $data = [$variable]; $phpcsFile->addError($error, $i, 'Found', $data); } else { $foundVariables[] = $variable; diff --git a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php index b84a712484..25159388f6 100644 --- a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php @@ -23,7 +23,7 @@ class GlobalFunctionSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -50,7 +50,7 @@ public function process(File $phpcsFile, $stackPtr) // Special exception for __autoload as it needs to be global. if ($functionName !== '__autoload') { $error = 'Consider putting global function "%s" in a static class'; - $data = array($functionName); + $data = [$functionName]; $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); } } diff --git a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php index 7f2e7d3df6..ef595bfb8d 100644 --- a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php @@ -23,13 +23,13 @@ class LowercaseFunctionKeywordsSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_STATIC, - ); + return [ + T_FUNCTION, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_STATIC, + ]; }//end register() @@ -50,11 +50,11 @@ public function process(File $phpcsFile, $stackPtr) $content = $tokens[$stackPtr]['content']; if ($content !== strtolower($content)) { $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); + $data = [ + strtoupper($content), + strtolower($content), + $content, + ]; $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); } diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index 4fae496464..d2ca01f692 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -20,10 +20,10 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -41,7 +41,7 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff */ public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) { - $bracketsToCheck = array($stackPtr => $openBracket); + $bracketsToCheck = [$stackPtr => $openBracket]; // Closures may use the USE keyword and so be multi-line in this way. if ($tokens[$stackPtr]['code'] === T_CLOSURE) { diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 4a0b1e1ead..3f8be67f8d 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -33,7 +33,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) return; } - $errorData = array($functionName); + $errorData = [$functionName]; // Does this function claim to be magical? if (preg_match('|^__[^_]|', $functionName) !== 0) { diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php index bd5040c911..0526543c98 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -21,10 +21,10 @@ class ValidVariableNameSniff extends AbstractVariableSniff * * @var array */ - private $ignore = array( - T_WHITESPACE, - T_COMMENT, - ); + private $ignore = [ + T_WHITESPACE, + T_COMMENT, + ]; /** @@ -41,32 +41,32 @@ protected function processVariable(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $varName = ltrim($tokens[$stackPtr]['content'], '$'); - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - 'http_response_header', - 'HTTP_RAW_POST_DATA', - 'php_errormsg', - ); + $phpReservedVars = [ + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + 'http_response_header', + 'HTTP_RAW_POST_DATA', + 'php_errormsg', + ]; // If it's a php reserved var, then its ok. if (in_array($varName, $phpReservedVars) === true) { return; } - $objOperator = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); + $objOperator = $phpcsFile->findNext([T_WHITESPACE], ($stackPtr + 1), null, true); if ($tokens[$objOperator]['code'] === T_OBJECT_OPERATOR) { // Check to see if we are using a variable from an object. - $var = $phpcsFile->findNext(array(T_WHITESPACE), ($objOperator + 1), null, true); + $var = $phpcsFile->findNext([T_WHITESPACE], ($objOperator + 1), null, true); if ($tokens[$var]['code'] === T_STRING) { - $bracket = $phpcsFile->findNext(array(T_WHITESPACE), ($var + 1), null, true); + $bracket = $phpcsFile->findNext([T_WHITESPACE], ($var + 1), null, true); if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) { $objVarName = $tokens[$var]['content']; @@ -80,7 +80,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($objVarName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addError($error, $var, 'NotCamelCaps', $data); } }//end if @@ -92,13 +92,13 @@ protected function processVariable(File $phpcsFile, $stackPtr) // check the main part of the variable name. $originalVarName = $varName; if (substr($varName, 0, 1) === '_') { - $objOperator = $phpcsFile->findPrevious(array(T_WHITESPACE), ($stackPtr - 1), null, true); + $objOperator = $phpcsFile->findPrevious([T_WHITESPACE], ($stackPtr - 1), null, true); if ($tokens[$objOperator]['code'] === T_DOUBLE_COLON) { // The variable lives within a class, and is referenced like // this: MyClass::$_variable, so we don't know its scope. $inClass = true; } else { - $inClass = $phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT)); + $inClass = $phpcsFile->hasCondition($stackPtr, [T_CLASS, T_INTERFACE, T_TRAIT]); } if ($inClass === true) { @@ -108,7 +108,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($varName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); } @@ -139,15 +139,15 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) } $public = ($memberProps['scope'] !== 'private'); - $errorData = array($varName); + $errorData = [$varName]; if ($public === true) { if (substr($varName, 0, 1) === '_') { $error = '%s member variable "%s" must not contain a leading underscore'; - $data = array( - ucfirst($memberProps['scope']), - $errorData[0], - ); + $data = [ + ucfirst($memberProps['scope']), + $errorData[0], + ]; $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); return; } @@ -180,20 +180,20 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - 'http_response_header', - 'HTTP_RAW_POST_DATA', - 'php_errormsg', - ); + $phpReservedVars = [ + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + 'http_response_header', + 'HTTP_RAW_POST_DATA', + 'php_errormsg', + ]; if (preg_match_all('|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) { foreach ($matches[1] as $varName) { @@ -204,7 +204,7 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($varName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addError($error, $stackPtr, 'StringNotCamelCaps', $data); } } diff --git a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php index 88a2abe66d..93e81380e2 100644 --- a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php @@ -20,7 +20,7 @@ class DisallowObjectStringIndexSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -30,7 +30,7 @@ class DisallowObjectStringIndexSniff implements Sniff */ public function register() { - return array(T_OPEN_SQUARE_BRACKET); + return [T_OPEN_SQUARE_BRACKET]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php index a6a60df7ba..90ff1861cc 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php @@ -24,7 +24,7 @@ class ObjectInstantiationSniff implements Sniff */ public function register() { - return array(T_NEW); + return [T_NEW]; }//end register() @@ -47,14 +47,14 @@ public function process(File $phpcsFile, $stackPtr) $prev = $phpcsFile->findPrevious($allowedTokens, ($stackPtr - 1), null, true); - $allowedTokens = array( - T_EQUAL => true, - T_DOUBLE_ARROW => true, - T_THROW => true, - T_RETURN => true, - T_INLINE_THEN => true, - T_INLINE_ELSE => true, - ); + $allowedTokens = [ + T_EQUAL => true, + T_DOUBLE_ARROW => true, + T_THROW => true, + T_RETURN => true, + T_INLINE_THEN => true, + T_INLINE_ELSE => true, + ]; if (isset($allowedTokens[$tokens[$prev]['code']]) === false) { $error = 'New objects must be assigned to a variable'; diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php index 674058e932..d8667bfc35 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php @@ -21,7 +21,7 @@ class ObjectMemberCommaSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -31,7 +31,7 @@ class ObjectMemberCommaSniff implements Sniff */ public function register() { - return array(T_CLOSE_OBJECT); + return [T_CLOSE_OBJECT]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index f3b17d88bd..3b8c0840d6 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -21,42 +21,42 @@ class ComparisonOperatorUsageSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * A list of valid comparison operators. * * @var array */ - private static $validOps = array( - T_IS_IDENTICAL, - T_IS_NOT_IDENTICAL, - T_LESS_THAN, - T_GREATER_THAN, - T_IS_GREATER_OR_EQUAL, - T_IS_SMALLER_OR_EQUAL, - T_INSTANCEOF, - ); + private static $validOps = [ + T_IS_IDENTICAL, + T_IS_NOT_IDENTICAL, + T_LESS_THAN, + T_GREATER_THAN, + T_IS_GREATER_OR_EQUAL, + T_IS_SMALLER_OR_EQUAL, + T_INSTANCEOF, + ]; /** * A list of invalid operators with their alternatives. * * @var array */ - private static $invalidOps = array( - 'PHP' => array( - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - T_BOOLEAN_NOT => '=== FALSE', - ), - 'JS' => array( - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - ), - ); + private static $invalidOps = [ + 'PHP' => [ + T_IS_EQUAL => '===', + T_IS_NOT_EQUAL => '!==', + T_BOOLEAN_NOT => '=== FALSE', + ], + 'JS' => [ + T_IS_EQUAL => '===', + T_IS_NOT_EQUAL => '!==', + ], + ]; /** @@ -66,13 +66,13 @@ class ComparisonOperatorUsageSniff implements Sniff */ public function register() { - return array( - T_IF, - T_ELSEIF, - T_INLINE_THEN, - T_WHILE, - T_FOR, - ); + return [ + T_IF, + T_ELSEIF, + T_INLINE_THEN, + T_WHILE, + T_FOR, + ]; }//end register() @@ -157,10 +157,10 @@ public function process(File $phpcsFile, $stackPtr) $type = $tokens[$i]['code']; if (in_array($type, array_keys(self::$invalidOps[$tokenizer])) === true) { $error = 'Operator %s prohibited; use %s instead'; - $data = array( - $tokens[$i]['content'], - self::$invalidOps[$tokenizer][$type], - ); + $data = [ + $tokens[$i]['content'], + self::$invalidOps[$tokenizer][$type], + ]; $phpcsFile->addError($error, $i, 'NotAllowed', $data); $foundOps++; } else if (in_array($type, self::$validOps) === true) { diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index cf73ef00e7..7ffb41a4ac 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -24,13 +24,13 @@ class IncrementDecrementUsageSniff implements Sniff */ public function register() { - return array( - T_EQUAL, - T_PLUS_EQUAL, - T_MINUS_EQUAL, - T_INC, - T_DEC, - ); + return [ + T_EQUAL, + T_PLUS_EQUAL, + T_MINUS_EQUAL, + T_INC, + T_DEC, + ]; }//end register() @@ -125,10 +125,10 @@ protected function processAssignment($phpcsFile, $stackPtr) return; } - $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET), $stackPtr); + $statementEnd = $phpcsFile->findNext([T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET], $stackPtr); // If there is anything other than variables, numbers, spaces or operators we need to return. - $noiseTokens = $phpcsFile->findNext(array(T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS), ($stackPtr + 1), $statementEnd, true); + $noiseTokens = $phpcsFile->findNext([T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS], ($stackPtr + 1), $statementEnd, true); if ($noiseTokens !== false) { return; @@ -167,7 +167,7 @@ protected function processAssignment($phpcsFile, $stackPtr) $nextNumber = ($stackPtr + 1); $previousNumber = ($stackPtr + 1); $numberCount = 0; - while (($nextNumber = $phpcsFile->findNext(array(T_LNUMBER), ($nextNumber + 1), $statementEnd, false)) !== false) { + while (($nextNumber = $phpcsFile->findNext([T_LNUMBER], ($nextNumber + 1), $statementEnd, false)) !== false) { $previousNumber = $nextNumber; $numberCount++; } @@ -179,7 +179,7 @@ protected function processAssignment($phpcsFile, $stackPtr) $nextNumber = $previousNumber; if ($tokens[$nextNumber]['content'] === '1') { if ($tokens[$stackPtr]['code'] === T_EQUAL) { - $opToken = $phpcsFile->findNext(array(T_PLUS, T_MINUS), ($nextVar + 1), $statementEnd); + $opToken = $phpcsFile->findNext([T_PLUS, T_MINUS], ($nextVar + 1), $statementEnd); if ($opToken === false) { // Operator was before the variable, like: // $var = 1 + $var; diff --git a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php index dc16a25329..e78ed3746f 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php @@ -23,10 +23,10 @@ class ValidLogicalOperatorsSniff implements Sniff */ public function register() { - return array( - T_LOGICAL_AND, - T_LOGICAL_OR, - ); + return [ + T_LOGICAL_AND, + T_LOGICAL_OR, + ]; }//end register() @@ -44,10 +44,10 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $replacements = array( - 'and' => '&&', - 'or' => '||', - ); + $replacements = [ + 'and' => '&&', + 'or' => '||', + ]; $operator = strtolower($tokens[$stackPtr]['content']); if (isset($replacements[$operator]) === false) { @@ -55,10 +55,10 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Logical operator "%s" is prohibited; use "%s" instead'; - $data = array( - $operator, - $replacements[$operator], - ); + $data = [ + $operator, + $replacements[$operator], + ]; $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); }//end process() diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index 3a3ec28bf3..f1d545bbce 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -22,10 +22,10 @@ class CommentedOutCodeSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'CSS', + ]; /** * If a comment is more than $maxPercentage% code, a warning will be shown. @@ -42,7 +42,7 @@ class CommentedOutCodeSniff implements Sniff */ public function register() { - return array(T_COMMENT); + return [T_COMMENT]; }//end register() @@ -144,14 +144,14 @@ public function process(File $phpcsFile, $stackPtr) ini_set('error_reporting', $oldErrors); - $emptyTokens = array( - T_WHITESPACE => true, - T_STRING => true, - T_STRING_CONCAT => true, - T_ENCAPSED_AND_WHITESPACE => true, - T_NONE => true, - T_COMMENT => true, - ); + $emptyTokens = [ + T_WHITESPACE => true, + T_STRING => true, + T_STRING_CONCAT => true, + T_ENCAPSED_AND_WHITESPACE => true, + T_NONE => true, + T_COMMENT => true, + ]; $numTokens = count($stringTokens); @@ -220,7 +220,7 @@ public function process(File $phpcsFile, $stackPtr) $percentCode = min(100, $percentCode); $error = 'This comment is %s%% valid code; is this commented out code?'; - $data = array($percentCode); + $data = [$percentCode]; $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); } diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php index a09afdb86f..d79627e8aa 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php @@ -24,7 +24,7 @@ class DisallowComparisonAssignmentSniff implements Sniff */ public function register() { - return array(T_EQUAL); + return [T_EQUAL]; }//end register() @@ -67,11 +67,11 @@ public function process(File $phpcsFile, $stackPtr) } // Ignore function calls. - $ignore = array( - T_STRING, - T_WHITESPACE, - T_OBJECT_OPERATOR, - ); + $ignore = [ + T_STRING, + T_WHITESPACE, + T_OBJECT_OPERATOR, + ]; $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php index 325e98bb73..7327006ed2 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php @@ -20,10 +20,10 @@ class DisallowInlineIfSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,7 +33,7 @@ class DisallowInlineIfSniff implements Sniff */ public function register() { - return array(T_INLINE_THEN); + return [T_INLINE_THEN]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php index 6205f8f6d7..a873c29119 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php @@ -24,7 +24,7 @@ class DisallowMultipleAssignmentsSniff implements Sniff */ public function register() { - return array(T_EQUAL); + return [T_EQUAL]; }//end register() @@ -43,7 +43,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // Ignore default value assignments in function definitions. - $function = $phpcsFile->findPrevious(array(T_FUNCTION, T_CLOSURE), ($stackPtr - 1), null, false, null, true); + $function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE], ($stackPtr - 1), null, false, null, true); if ($function !== false) { $opener = $tokens[$function]['parenthesis_opener']; $closer = $tokens[$function]['parenthesis_closer']; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php index 11ac21e72d..55236e9a04 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php @@ -23,7 +23,7 @@ class DisallowObEndFlushSniff implements Sniff */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index 3f4dbe3619..e901447c57 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -20,24 +20,24 @@ class DisallowSizeFunctionsInLoopsSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * An array of functions we don't want in the condition of loops. * * @var array */ - protected $forbiddenFunctions = array( - 'PHP' => array( - 'sizeof' => true, - 'strlen' => true, - 'count' => true, - ), - 'JS' => array('length' => true), - ); + protected $forbiddenFunctions = [ + 'PHP' => [ + 'sizeof' => true, + 'strlen' => true, + 'count' => true, + ], + 'JS' => ['length' => true], + ]; /** @@ -47,10 +47,10 @@ class DisallowSizeFunctionsInLoopsSniff implements Sniff */ public function register() { - return array( - T_WHILE, - T_FOR, - ); + return [ + T_WHILE, + T_FOR, + ]; }//end register() @@ -103,7 +103,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'The use of %s inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead'; - $data = array($functionName); + $data = [$functionName]; $phpcsFile->addError($error, $i, 'Found', $data); }//end if }//end for diff --git a/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php index d47949aade..9f86a1798c 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php @@ -22,11 +22,11 @@ class DiscouragedFunctionsSniff extends GenericForbiddenFunctionsSniff * * @var array */ - public $forbiddenFunctions = array( - 'error_log' => null, - 'print_r' => null, - 'var_dump' => null, - ); + public $forbiddenFunctions = [ + 'error_log' => null, + 'print_r' => null, + 'var_dump' => null, + ]; /** * If true, an error will be thrown; otherwise a warning. diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index c3fe3d5b33..8d816c908f 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -24,7 +24,7 @@ class EmbeddedPhpSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() @@ -152,10 +152,10 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) $contentColumn = ($tokens[$firstContent]['column'] - 1); if ($contentColumn !== $indent) { $error = 'First line of embedded PHP code must be indented %s spaces; %s found'; - $data = array( - $indent, - $contentColumn, - ); + $data = [ + $indent, + $contentColumn, + ]; $fix = $phpcsFile->addFixableError($error, $firstContent, 'Indent', $data); if ($fix === true) { $padding = str_repeat(' ', $indent); @@ -192,7 +192,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) if ($tokens[$first]['line'] === $tokens[$stackPtr]['line']) { continue; } else if (trim($tokens[$first]['content']) !== '') { - $first = $phpcsFile->findFirstOnLine(array(), $first, true); + $first = $phpcsFile->findFirstOnLine([], $first, true); break; } } @@ -210,10 +210,10 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) $found = ($tokens[$stackPtr]['column'] - 1); if ($found > $expected) { $error = 'Opening PHP tag indent incorrect; expected no more than %s spaces but found %s'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'OpenTagIndent', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr - 1), str_repeat(' ', $expected)); @@ -333,7 +333,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr) if ($leadingSpace !== 1) { $error = 'Expected 1 space after opening PHP tag; %s found'; - $data = array($leadingSpace); + $data = [$leadingSpace]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterOpen', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); @@ -363,7 +363,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr) if ($statementCount > 1) { $error = 'Inline PHP statement must contain a single statement; %s found'; - $data = array($statementCount); + $data = [$statementCount]; $phpcsFile->addError($error, $stackPtr, 'MultipleStatements', $data); } } @@ -380,7 +380,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr) if ($trailingSpace !== 1) { $error = 'Expected 1 space before closing PHP tag; %s found'; - $data = array($trailingSpace); + $data = [$trailingSpace]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeClose', $data); if ($fix === true) { if ($trailingSpace === 0) { diff --git a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php index ef701495a6..af1ea1012b 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php @@ -23,7 +23,7 @@ class EvalSniff implements Sniff */ public function register() { - return array(T_EVAL); + return [T_EVAL]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php index 23728ddfe6..ca6fc0e998 100644 --- a/src/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -22,12 +22,12 @@ class ForbiddenFunctionsSniff extends GenericForbiddenFunctionsSniff * * @var array */ - public $forbiddenFunctions = array( - 'sizeof' => 'count', - 'delete' => 'unset', - 'print' => 'echo', - 'is_null' => null, - 'create_function' => null, - ); + public $forbiddenFunctions = [ + 'sizeof' => 'count', + 'delete' => 'unset', + 'print' => 'echo', + 'is_null' => null, + 'create_function' => null, + ]; }//end class diff --git a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php index 282f9d4921..dfa25d7a56 100644 --- a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php @@ -23,7 +23,7 @@ class GlobalKeywordSniff implements Sniff */ public function register() { - return array(T_GLOBAL); + return [T_GLOBAL]; }//end register() @@ -41,10 +41,10 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)]; + $nextVar = $tokens[$phpcsFile->findNext([T_VARIABLE], $stackPtr)]; $varName = str_replace('$', '', $nextVar['content']); $error = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); }//end process() diff --git a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php index 557ced425d..3d0c5e7fec 100644 --- a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php @@ -23,10 +23,10 @@ class HeredocSniff implements Sniff */ public function register() { - return array( - T_START_HEREDOC, - T_START_NOWDOC, - ); + return [ + T_START_HEREDOC, + T_START_NOWDOC, + ]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php index 3eea6c156c..5df214db03 100644 --- a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php @@ -23,7 +23,7 @@ class InnerFunctionsSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php index 16bf2dbc84..715b4e4e65 100644 --- a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php @@ -42,7 +42,7 @@ public function __construct() */ public function register() { - return array(T_STRING); + return [T_STRING]; }//end register() @@ -72,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $prev = $phpcsFile->findPrevious(array(T_WHITESPACE, T_BITWISE_AND), ($stackPtr - 1), null, true); + $prev = $phpcsFile->findPrevious([T_WHITESPACE, T_BITWISE_AND], ($stackPtr - 1), null, true); if ($tokens[$prev]['code'] === T_FUNCTION) { // Function declaration, not a function call. return; @@ -108,10 +108,10 @@ public function process(File $phpcsFile, $stackPtr) if ($content !== strtolower($content)) { $error = 'Calls to inbuilt PHP functions must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtolower($content), - $content, - ); + $data = [ + strtolower($content), + $content, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'CallUppercase', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 470bacad7a..34363cca5d 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -24,13 +24,13 @@ class NonExecutableCodeSniff implements Sniff */ public function register() { - return array( - T_BREAK, - T_CONTINUE, - T_RETURN, - T_THROW, - T_EXIT, - ); + return [ + T_BREAK, + T_CONTINUE, + T_RETURN, + T_THROW, + T_EXIT, + ]; }//end register() @@ -100,11 +100,11 @@ public function process(File $phpcsFile, $stackPtr) // end of SWITCH token will not be executable. $end = $phpcsFile->findEndOfStatement($stackPtr); $next = $phpcsFile->findNext( - array( - T_CASE, - T_DEFAULT, - T_CLOSE_CURLY_BRACKET, - ), + [ + T_CASE, + T_DEFAULT, + T_CLOSE_CURLY_BRACKET, + ], ($end + 1) ); @@ -119,7 +119,7 @@ public function process(File $phpcsFile, $stackPtr) if ($line > $lastLine) { $type = substr($tokens[$stackPtr]['type'], 2); $warning = 'Code after %s statement cannot be executed'; - $data = array($type); + $data = [$type]; $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); $lastLine = $line; } @@ -137,11 +137,11 @@ public function process(File $phpcsFile, $stackPtr) $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if (isset($tokens[$prev]['parenthesis_owner']) === true) { $owner = $tokens[$prev]['parenthesis_owner']; - $ignore = array( - T_IF => true, - T_ELSE => true, - T_ELSEIF => true, - ); + $ignore = [ + T_IF => true, + T_ELSE => true, + T_ELSEIF => true, + ]; if (isset($ignore[$tokens[$owner]['code']]) === true) { return; } @@ -243,7 +243,7 @@ public function process(File $phpcsFile, $stackPtr) if ($line > $lastLine) { $type = substr($tokens[$stackPtr]['type'], 2); $warning = 'Code after %s statement cannot be executed'; - $data = array($type); + $data = [$type]; $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); $lastLine = $line; } diff --git a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php index 6ae3df76b2..91241987bd 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php @@ -41,7 +41,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) if ($modifier === null) { $error = 'Scope modifier not specified for member variable "%s"'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addError($error, $stackPtr, 'Missing', $data); } diff --git a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php index 6739ab400e..2b854c8dfb 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php @@ -22,7 +22,7 @@ class MethodScopeSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION)); + parent::__construct([T_CLASS, T_INTERFACE, T_TRAIT], [T_FUNCTION]); }//end __construct() @@ -63,7 +63,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop if ($modifier === null) { $error = 'Visibility must be declared on method "%s"'; - $data = array($methodName); + $data = [$methodName]; $phpcsFile->addError($error, $stackPtr, 'Missing', $data); } diff --git a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php index da732047e9..986c1df6a7 100644 --- a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php @@ -21,7 +21,7 @@ class StaticThisUsageSniff extends AbstractScopeSniff */ public function __construct() { - parent::__construct(array(T_CLASS), array(T_FUNCTION)); + parent::__construct([T_CLASS], [T_FUNCTION]); }//end __construct() @@ -59,7 +59,7 @@ public function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) } $thisUsage = $stackPtr; - while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) { + while (($thisUsage = $phpcsFile->findNext([T_VARIABLE], ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) { if ($thisUsage === false) { return; } diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php index e9f60ae5d2..9e7c245a58 100644 --- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php @@ -38,7 +38,7 @@ class ConcatenationSpacingSniff implements Sniff */ public function register() { - return array(T_STRING_CONCAT); + return [T_STRING_CONCAT]; }//end register() @@ -104,7 +104,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->spacing === 0) { $message = 'Concat operator must not be surrounded by spaces'; - $data = array(); + $data = []; } else { if ($this->spacing > 1) { $message = 'Concat operator must be surrounded by %s spaces'; @@ -112,7 +112,7 @@ public function process(File $phpcsFile, $stackPtr) $message = 'Concat operator must be surrounded by a single space'; } - $data = array($this->spacing); + $data = [$this->spacing]; } $fix = $phpcsFile->addFixableError($message, $stackPtr, 'PaddingFound', $data); diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 8077fa355c..e687eab697 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -23,10 +23,10 @@ class DoubleQuoteUsageSniff implements Sniff */ public function register() { - return array( - T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING, - ); + return [ + T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING, + ]; }//end register() @@ -83,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr) foreach ($stringTokens as $token) { if (is_array($token) === true && $token[0] === T_VARIABLE) { $error = 'Variable "%s" not allowed in double quoted string; use concatenation instead'; - $data = array($token[1]); + $data = [$token[1]]; $phpcsFile->addError($error, $stackPtr, 'ContainsVar', $data); } } @@ -91,26 +91,26 @@ public function process(File $phpcsFile, $stackPtr) return $skipTo; }//end if - $allowedChars = array( - '\0', - '\1', - '\2', - '\3', - '\4', - '\5', - '\6', - '\7', - '\n', - '\r', - '\f', - '\t', - '\v', - '\x', - '\b', - '\e', - '\u', - '\'', - ); + $allowedChars = [ + '\0', + '\1', + '\2', + '\3', + '\4', + '\5', + '\6', + '\7', + '\n', + '\r', + '\f', + '\t', + '\v', + '\x', + '\b', + '\e', + '\u', + '\'', + ]; foreach ($allowedChars as $testChar) { if (strpos($workingString, $testChar) !== false) { @@ -119,7 +119,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'String %s does not require double quotes; use single quotes instead'; - $data = array(str_replace(array("\r", "\n"), array('\r', '\n'), $workingString)); + $data = [str_replace(["\r", "\n"], ['\r', '\n'], $workingString)]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php index af1a798ee5..92a569c8b2 100644 --- a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php @@ -24,7 +24,7 @@ class EchoedStringsSniff implements Sniff */ public function register() { - return array(T_ECHO); + return [T_ECHO]; }//end register() @@ -49,7 +49,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - $end = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), $stackPtr, null, false); + $end = $phpcsFile->findNext([T_SEMICOLON, T_CLOSE_TAG], $stackPtr, null, false); // If the token before the semi-colon is not a closing parenthesis, then we are not concerned. $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($end - 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php index d946861134..8f6ac1f28f 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php @@ -48,10 +48,10 @@ public function process(File $phpcsFile, $stackPtr) if ($content !== $expected) { $error = 'Cast statements must not contain whitespace; expected "%s" but found "%s"'; - $data = array( - $expected, - $content, - ); + $data = [ + $expected, + $content, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContainsWhiteSpace', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index f3e319d223..46dac3daf6 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -21,10 +21,10 @@ class ControlStructureSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -34,18 +34,18 @@ class ControlStructureSpacingSniff implements Sniff */ public function register() { - return array( - T_IF, - T_WHILE, - T_FOREACH, - T_FOR, - T_SWITCH, - T_DO, - T_ELSE, - T_ELSEIF, - T_TRY, - T_CATCH, - ); + return [ + T_IF, + T_WHILE, + T_FOREACH, + T_FOR, + T_SWITCH, + T_DO, + T_ELSE, + T_ELSEIF, + T_TRY, + T_CATCH, + ]; }//end register() @@ -79,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Expected 0 spaces after opening bracket; %s found'; - $data = array($gap); + $data = [$gap]; $fix = $phpcsFile->addFixableError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($parenOpener + 1), ''); @@ -93,7 +93,7 @@ public function process(File $phpcsFile, $stackPtr) ) { $gap = $tokens[($parenCloser - 1)]['length']; $error = 'Expected 0 spaces before closing bracket; %s found'; - $data = array($gap); + $data = [$gap]; $fix = $phpcsFile->addFixableError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($parenCloser - 1), ''); @@ -138,13 +138,13 @@ public function process(File $phpcsFile, $stackPtr) } // We ignore spacing for some structures that tend to have their own rules. - $ignore = array( - T_FUNCTION => true, - T_CLASS => true, - T_INTERFACE => true, - T_TRAIT => true, - T_DOC_COMMENT_OPEN_TAG => true, - ); + $ignore = [ + T_FUNCTION => true, + T_CLASS => true, + T_INTERFACE => true, + T_TRAIT => true, + T_DOC_COMMENT_OPEN_TAG => true, + ]; if (isset($ignore[$tokens[$firstContent]['code']]) === false && $tokens[$firstContent]['line'] >= ($tokens[$scopeOpener]['line'] + 2) diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index e0f31287c0..54502bac45 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -20,10 +20,10 @@ class FunctionClosingBraceSpaceSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,10 +33,10 @@ class FunctionClosingBraceSpaceSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -105,7 +105,7 @@ public function process(File $phpcsFile, $stackPtr) } } else if ($found > 0) { $error = 'Expected 0 blank lines before closing brace of nested function; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeNestedClose', $data); if ($fix === true) { @@ -137,7 +137,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'Expected 1 blank line before closing function brace; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeClose', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index 3ab6677864..ce6727c4ef 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -20,10 +20,10 @@ class FunctionOpeningBraceSpaceSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -33,10 +33,10 @@ class FunctionOpeningBraceSpaceSniff implements Sniff */ public function register() { - return array( - T_FUNCTION, - T_CLOSURE, - ); + return [ + T_FUNCTION, + T_CLOSURE, + ]; }//end register() @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) $found = ($nextLine - $braceLine - 1); if ($found > 0) { $error = 'Expected 0 blank lines after opening function brace; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $openBrace, 'SpacingAfter', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 1699a251a6..ce2d43aeb3 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -30,7 +30,7 @@ class FunctionSpacingSniff implements Sniff */ public function register() { - return array(T_FUNCTION); + return [T_FUNCTION]; }//end register() @@ -93,10 +93,10 @@ public function process(File $phpcsFile, $stackPtr) } $error .= ' after function; %s found'; - $data = array( - $this->spacing, - $foundLines, - ); + $data = [ + $this->spacing, + $foundLines, + ]; $fix = $phpcsFile->addFixableError($error, $closer, 'After', $data); if ($fix === true) { @@ -192,10 +192,10 @@ public function process(File $phpcsFile, $stackPtr) } $error .= ' before function; %s found'; - $data = array( - $this->spacing, - $foundLines, - ); + $data = [ + $this->spacing, + $foundLines, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index 13b717a4ff..e2c0403ade 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -23,16 +23,16 @@ class LanguageConstructSpacingSniff implements Sniff */ public function register() { - return array( - T_ECHO, - T_PRINT, - T_RETURN, - T_INCLUDE, - T_INCLUDE_ONCE, - T_REQUIRE, - T_REQUIRE_ONCE, - T_NEW, - ); + return [ + T_ECHO, + T_PRINT, + T_RETURN, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + T_NEW, + ]; }//end register() @@ -60,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr) $contentLength = strlen($content); if ($contentLength !== 1) { $error = 'Language constructs must be followed by a single space; expected 1 space but found %s'; - $data = array($contentLength); + $data = [$contentLength]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectSingle', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); @@ -68,10 +68,10 @@ public function process(File $phpcsFile, $stackPtr) } } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) { $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"'; - $data = array( - $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'], - $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'], - ); + $data = [ + $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'], + $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'], + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data); if ($fix === true) { $phpcsFile->fixer->addContent($stackPtr, ' '); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php index f3257b78bb..8e15768502 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php @@ -21,10 +21,10 @@ class LogicalOperatorSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -66,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr) ) { $found = strlen($tokens[($stackPtr - 1)]['content']); $error = 'Expected 1 space before logical operator; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TooMuchSpaceBefore', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); @@ -88,7 +88,7 @@ public function process(File $phpcsFile, $stackPtr) ) { $found = strlen($tokens[($stackPtr + 1)]['content']); $error = 'Expected 1 space after logical operator; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TooMuchSpaceAfter', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index e89b49b9cf..9d75540f14 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -57,7 +57,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) $foundLines = ($tokens[$stackPtr]['line'] - $tokens[$prev]['line'] - 1); if ($foundLines > 0) { $error = 'Expected 0 blank lines after member var comment; %s found'; - $data = array($foundLines); + $data = [$foundLines]; $fix = $phpcsFile->addFixableError($error, $prev, 'AfterComment', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); @@ -117,10 +117,10 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) return; } - $data = array( - $spacing, - $foundLines, - ); + $data = [ + $spacing, + $foundLines, + ]; $fix = $phpcsFile->addFixableError($errorMsg, $stackPtr, $errorCode, $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index 5b667ad2b6..e35c89d583 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -30,10 +30,10 @@ class ObjectOperatorSpacingSniff implements Sniff */ public function register() { - return array( - T_OBJECT_OPERATOR, - T_DOUBLE_COLON, - ); + return [ + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + ]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index c7345c5d4e..4c42529a77 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -21,10 +21,10 @@ class OperatorSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** * Allow newlines instead of spaces. @@ -44,10 +44,10 @@ public function register() $comparison = Tokens::$comparisonTokens; $operators = Tokens::$operators; $assignment = Tokens::$assignmentTokens; - $inlineIf = array( - T_INLINE_THEN, - T_INLINE_ELSE, - ); + $inlineIf = [ + T_INLINE_THEN, + T_INLINE_ELSE, + ]; return array_unique( array_merge($comparison, $operators, $assignment, $inlineIf) @@ -126,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr) && ($found !== 'newline' || $this->ignoreNewlines === false) ) { $error = 'Expected 1 space before "&" operator; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeAmp', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); @@ -155,7 +155,7 @@ public function process(File $phpcsFile, $stackPtr) && ($found !== 'newline' || $this->ignoreNewlines === false) ) { $error = 'Expected 1 space after "&" operator; %s found'; - $data = array($found); + $data = [$found]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterAmp', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); @@ -197,17 +197,17 @@ public function process(File $phpcsFile, $stackPtr) // A list of tokens that indicate that the token is not // part of an arithmetic operation. - $invalidTokens = array( - T_COMMA => true, - T_OPEN_PARENTHESIS => true, - T_OPEN_SQUARE_BRACKET => true, - T_OPEN_SHORT_ARRAY => true, - T_DOUBLE_ARROW => true, - T_COLON => true, - T_INLINE_THEN => true, - T_INLINE_ELSE => true, - T_CASE => true, - ); + $invalidTokens = [ + T_COMMA => true, + T_OPEN_PARENTHESIS => true, + T_OPEN_SQUARE_BRACKET => true, + T_OPEN_SHORT_ARRAY => true, + T_DOUBLE_ARROW => true, + T_COLON => true, + T_INLINE_THEN => true, + T_INLINE_ELSE => true, + T_CASE => true, + ]; if (isset($invalidTokens[$tokens[$prev]['code']]) === true) { // Just trying to use a negative value; eg. myFunction($var, -2). @@ -242,10 +242,10 @@ public function process(File $phpcsFile, $stackPtr) && ($found !== 'newline' || $this->ignoreNewlines === false) ) { $error = 'Expected 1 space before "%s"; %s found'; - $data = array( - $operator, - $found, - ); + $data = [ + $operator, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBefore', $data); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); @@ -296,10 +296,10 @@ public function process(File $phpcsFile, $stackPtr) && ($found !== 'newline' || $this->ignoreNewlines === false) ) { $error = 'Expected 1 space after "%s"; %s found'; - $data = array( - $operator, - $found, - ); + $data = [ + $operator, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfter', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php index bf99f21968..661c65aeee 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php @@ -20,7 +20,7 @@ class PropertyLabelSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array('JS'); + public $supportedTokenizers = ['JS']; /** @@ -30,10 +30,10 @@ class PropertyLabelSpacingSniff implements Sniff */ public function register() { - return array( - T_PROPERTY, - T_LABEL, - ); + return [ + T_PROPERTY, + T_LABEL, + ]; }//end register() diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 4c22a59b8b..6cb25afd9b 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -52,11 +52,11 @@ public function process(File $phpcsFile, $stackPtr) // as if this is a method with tokens before it (public, static etc) // or an if with an else before it, then we need to start the scope // checking from there, rather than the current token. - $lineStart = $phpcsFile->findFirstOnLine(array(T_WHITESPACE, T_INLINE_HTML), $stackPtr, true); + $lineStart = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $stackPtr, true); while ($tokens[$lineStart]['code'] === T_CONSTANT_ENCAPSED_STRING && $tokens[($lineStart - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING ) { - $lineStart = $phpcsFile->findFirstOnLine(array(T_WHITESPACE, T_INLINE_HTML), ($lineStart - 1), true); + $lineStart = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], ($lineStart - 1), true); } $startColumn = $tokens[$lineStart]['column']; @@ -64,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) $scopeEnd = $tokens[$stackPtr]['scope_closer']; // Check that the closing brace is on it's own line. - $lastContent = $phpcsFile->findPrevious(array(T_INLINE_HTML, T_WHITESPACE, T_OPEN_TAG), ($scopeEnd - 1), $scopeStart, true); + $lastContent = $phpcsFile->findPrevious([T_INLINE_HTML, T_WHITESPACE, T_OPEN_TAG], ($scopeEnd - 1), $scopeStart, true); if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { $error = 'Closing brace must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $scopeEnd, 'ContentBefore'); @@ -76,17 +76,17 @@ public function process(File $phpcsFile, $stackPtr) } // Check now that the closing brace is lined up correctly. - $lineStart = $phpcsFile->findFirstOnLine(array(T_WHITESPACE, T_INLINE_HTML), $scopeEnd, true); + $lineStart = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $scopeEnd, true); $braceIndent = $tokens[$lineStart]['column']; if ($tokens[$stackPtr]['code'] !== T_DEFAULT && $tokens[$stackPtr]['code'] !== T_CASE && $braceIndent !== $startColumn ) { $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($startColumn - 1), - ($braceIndent - 1), - ); + $data = [ + ($startColumn - 1), + ($braceIndent - 1), + ]; $fix = $phpcsFile->addFixableError($error, $scopeEnd, 'Indent', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 26d589bc3e..031b6bac6b 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -65,7 +65,7 @@ public function process(File $phpcsFile, $stackPtr) || $nextToken['content'] === $phpcsFile->eolChar ) { $error = 'Scope keyword "%s" must be followed by a single space'; - $data = array($tokens[$stackPtr]['content']); + $data = [$tokens[$stackPtr]['content']]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data); if ($fix === true) { $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index feb271ea8d..6851a54601 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -21,10 +21,10 @@ class SemicolonSpacingSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + ]; /** @@ -34,7 +34,7 @@ class SemicolonSpacingSniff implements Sniff */ public function register() { - return array(T_SEMICOLON); + return [T_SEMICOLON]; }//end register() @@ -84,10 +84,10 @@ public function process(File $phpcsFile, $stackPtr) $expected = $tokens[$nonSpace]['content'].';'; $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).';'; $error = 'Space found before semicolon; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); + $data = [ + $expected, + $found, + ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data); if ($fix === true) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index 9d040a30cb..554b8b39f4 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -24,11 +24,11 @@ class SuperfluousWhitespaceSniff implements Sniff * * @var array */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); + public $supportedTokenizers = [ + 'PHP', + 'JS', + 'CSS', + ]; /** * If TRUE, whitespace rules are not checked for blank lines. @@ -47,14 +47,14 @@ class SuperfluousWhitespaceSniff implements Sniff */ public function register() { - return array( - T_OPEN_TAG, - T_CLOSE_TAG, - T_WHITESPACE, - T_COMMENT, - T_DOC_COMMENT_WHITESPACE, - T_CLOSURE, - ); + return [ + T_OPEN_TAG, + T_CLOSE_TAG, + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT_WHITESPACE, + T_CLOSURE, + ]; }//end register() @@ -230,7 +230,7 @@ public function process(File $phpcsFile, $stackPtr) $lines = ($tokens[$next]['line'] - $tokens[$stackPtr]['line']); if ($lines > 1) { $error = 'Functions must not contain multiple empty lines in a row; found %s empty lines'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'EmptyLines', array($lines)); + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'EmptyLines', [$lines]); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $i = $stackPtr; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php index 545e801d1e..304a0d4245 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php @@ -25,16 +25,16 @@ class ArrayBracketSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 3, - 7 => 3, - 17 => 2, - 20 => 2, - 23 => 2, - 24 => 2, - 30 => 1, - 31 => 2, - ); + return [ + 5 => 3, + 7 => 3, + 17 => 2, + 20 => 2, + 23 => 2, + 24 => 2, + 30 => 1, + 31 => 2, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index e9a5fa88dc..8f81de5184 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -29,138 +29,138 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'ArrayDeclarationUnitTest.1.inc': - return array( - 7 => 2, - 9 => 2, - 22 => 1, - 23 => 1, - 24 => 1, - 25 => 1, - 31 => 1, - 35 => 1, - 36 => 1, - 41 => 1, - 46 => 1, - 47 => 1, - 50 => 1, - 51 => 1, - 53 => 1, - 56 => 1, - 58 => 1, - 61 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 65 => 1, - 66 => 3, - 70 => 1, - 76 => 2, - 77 => 1, - 78 => 7, - 79 => 2, - 81 => 2, - 82 => 4, - 87 => 1, - 88 => 1, - 92 => 1, - 97 => 1, - 100 => 1, - 101 => 1, - 102 => 1, - 105 => 1, - 106 => 1, - 107 => 1, - 125 => 1, - 126 => 1, - 141 => 1, - 144 => 1, - 146 => 1, - 148 => 1, - 151 => 1, - 157 => 1, - 174 => 3, - 179 => 1, - 182 => 1, - 188 => 1, - 207 => 1, - 212 => 1, - 214 => 1, - 218 => 2, - 219 => 2, - 223 => 1, - 255 => 1, - 294 => 1, - 295 => 1, - 296 => 1, - 311 => 1, - 317 => 1, - 339 => 2, - 348 => 2, - 352 => 2, - ); + return [ + 7 => 2, + 9 => 2, + 22 => 1, + 23 => 1, + 24 => 1, + 25 => 1, + 31 => 1, + 35 => 1, + 36 => 1, + 41 => 1, + 46 => 1, + 47 => 1, + 50 => 1, + 51 => 1, + 53 => 1, + 56 => 1, + 58 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 3, + 70 => 1, + 76 => 2, + 77 => 1, + 78 => 7, + 79 => 2, + 81 => 2, + 82 => 4, + 87 => 1, + 88 => 1, + 92 => 1, + 97 => 1, + 100 => 1, + 101 => 1, + 102 => 1, + 105 => 1, + 106 => 1, + 107 => 1, + 125 => 1, + 126 => 1, + 141 => 1, + 144 => 1, + 146 => 1, + 148 => 1, + 151 => 1, + 157 => 1, + 174 => 3, + 179 => 1, + 182 => 1, + 188 => 1, + 207 => 1, + 212 => 1, + 214 => 1, + 218 => 2, + 219 => 2, + 223 => 1, + 255 => 1, + 294 => 1, + 295 => 1, + 296 => 1, + 311 => 1, + 317 => 1, + 339 => 2, + 348 => 2, + 352 => 2, + ]; case 'ArrayDeclarationUnitTest.2.inc': - return array( - 9 => 1, - 23 => 1, - 24 => 1, - 25 => 1, - 31 => 1, - 36 => 1, - 41 => 1, - 46 => 1, - 47 => 1, - 51 => 1, - 53 => 1, - 56 => 1, - 61 => 1, - 63 => 1, - 64 => 1, - 65 => 1, - 66 => 2, - 70 => 1, - 76 => 1, - 77 => 1, - 78 => 7, - 79 => 2, - 81 => 2, - 82 => 4, - 87 => 1, - 88 => 1, - 92 => 1, - 97 => 1, - 100 => 1, - 101 => 1, - 102 => 1, - 105 => 1, - 106 => 1, - 107 => 1, - 125 => 1, - 126 => 1, - 141 => 1, - 144 => 1, - 146 => 1, - 148 => 1, - 151 => 1, - 157 => 1, - 174 => 3, - 179 => 1, - 190 => 1, - 191 => 1, - 192 => 1, - 207 => 1, - 210 => 1, - 211 => 1, - 215 => 1, - 247 => 1, - 286 => 1, - 287 => 1, - 288 => 1, - 303 => 1, - 309 => 1, - 331 => 2, - ); + return [ + 9 => 1, + 23 => 1, + 24 => 1, + 25 => 1, + 31 => 1, + 36 => 1, + 41 => 1, + 46 => 1, + 47 => 1, + 51 => 1, + 53 => 1, + 56 => 1, + 61 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 2, + 70 => 1, + 76 => 1, + 77 => 1, + 78 => 7, + 79 => 2, + 81 => 2, + 82 => 4, + 87 => 1, + 88 => 1, + 92 => 1, + 97 => 1, + 100 => 1, + 101 => 1, + 102 => 1, + 105 => 1, + 106 => 1, + 107 => 1, + 125 => 1, + 126 => 1, + 141 => 1, + 144 => 1, + 146 => 1, + 148 => 1, + 151 => 1, + 157 => 1, + 174 => 3, + 179 => 1, + 190 => 1, + 191 => 1, + 192 => 1, + 207 => 1, + 210 => 1, + 211 => 1, + 215 => 1, + 247 => 1, + 286 => 1, + 287 => 1, + 288 => 1, + 303 => 1, + 309 => 1, + 331 => 2, + ]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -176,7 +176,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php index 75dffa28b6..433f7b9c07 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php @@ -25,12 +25,12 @@ class ClassDefinitionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 11 => 1, - 44 => 1, - 47 => 1, - ); + return [ + 2 => 1, + 11 => 1, + 44 => 1, + 47 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php index 95c3e04087..41202bc8d1 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php @@ -25,10 +25,10 @@ class ClassDefinitionNameSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 19 => 1, - ); + return [ + 7 => 1, + 19 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php index c22017cace..f4cd757e06 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php @@ -25,14 +25,14 @@ class ClassDefinitionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 7 => 1, - 10 => 1, - 26 => 1, - 33 => 1, - 43 => 1, - ); + return [ + 4 => 1, + 7 => 1, + 10 => 1, + 26 => 1, + 33 => 1, + 43 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php index 249f0cc4d0..067cf121ea 100644 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php @@ -25,18 +25,18 @@ class ColonSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 4 => 2, - 5 => 1, - 6 => 1, - 8 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 32 => 1, - ); + return [ + 3 => 1, + 4 => 2, + 5 => 1, + 6 => 1, + 8 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 32 => 1, + ]; }//end getErrorList() @@ -51,7 +51,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php index 170bcabc14..d535fdc2ed 100644 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php @@ -25,11 +25,11 @@ class ColourDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 5 => 1, - 6 => 1, - ); + return [ + 2 => 1, + 5 => 1, + 6 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php index 7bd0f92e12..45e880df35 100644 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php @@ -25,11 +25,11 @@ class DisallowMultipleStyleDefinitionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 2, - 10 => 4, - ); + return [ + 3 => 1, + 5 => 2, + 10 => 4, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php index e006f1ce26..48702859b1 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php @@ -25,11 +25,11 @@ class DuplicateClassDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 29 => 1, - 57 => 1, - ); + return [ + 9 => 1, + 29 => 1, + 57 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php index 600403d051..c555461b18 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php @@ -25,7 +25,7 @@ class DuplicateStyleDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(7 => 1); + return [7 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php index a564066b69..b3fd318c92 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php @@ -25,13 +25,13 @@ class EmptyClassDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 1 => 1, - 2 => 1, - 4 => 1, - 7 => 1, - 10 => 1, - ); + return [ + 1 => 1, + 2 => 1, + 4 => 1, + 7 => 1, + 10 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php index 83c1942bc3..263909850e 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php @@ -25,10 +25,10 @@ class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 4 => 1, - ); + return [ + 3 => 1, + 4 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php index cb3147d22c..28aa8ec304 100644 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php @@ -25,16 +25,16 @@ class ForbiddenStylesUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 15 => 1, - 16 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 15 => 1, + 16 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php index 47e0d07d7f..c05b6ed266 100644 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php @@ -25,26 +25,26 @@ class IndentationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 12 => 1, - 30 => 1, - 32 => 1, - 50 => 1, - 52 => 1, - 53 => 1, - 66 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 12 => 1, + 30 => 1, + 32 => 1, + 50 => 1, + 52 => 1, + 53 => 1, + 66 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + ]; }//end getErrorList() @@ -59,7 +59,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php index 980e003bea..1a25aaac88 100644 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php @@ -25,12 +25,12 @@ class LowercaseStyleDefinitionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - 5 => 2, - 11 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 5 => 2, + 11 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php index a546f3ecb2..dc0809e26a 100644 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php @@ -25,12 +25,12 @@ class MissingColonUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 4 => 1, - 6 => 1, - 12 => 1, - ); + return [ + 2 => 1, + 4 => 1, + 6 => 1, + 12 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php index 293db93863..a8032fad3b 100644 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php @@ -25,13 +25,13 @@ class NamedColoursUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 6 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - ); + return [ + 2 => 1, + 6 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php index 7181c41af2..9332298470 100644 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php @@ -25,16 +25,16 @@ class OpacityUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 26 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 26 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php index 4a45109a20..d715dbff32 100644 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php @@ -25,10 +25,10 @@ class SemicolonSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 7 => 1, - ); + return [ + 2 => 1, + 7 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php index ff9c2a40ea..850bc30572 100644 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php @@ -25,17 +25,17 @@ class ShorthandSizeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 8 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - ); + return [ + 8 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php index dc488ffea8..8a474bb650 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php @@ -25,42 +25,42 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 6 => 1, - 10 => 1, - 15 => 2, - 18 => 1, - 22 => 4, - 23 => 4, - 24 => 4, - 27 => 2, - 30 => 2, - 34 => 1, - 35 => 1, - 39 => 1, - 42 => 1, - 45 => 1, - 48 => 1, - 50 => 2, - 51 => 1, - 55 => 1, - 59 => 4, - 63 => 1, - 65 => 1, - 69 => 3, - 74 => 2, - 77 => 1, - 80 => 1, - 85 => 3, - 89 => 1, - 92 => 1, - 97 => 1, - 103 => 1, - 105 => 1, - 107 => 1, - 110 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 10 => 1, + 15 => 2, + 18 => 1, + 22 => 4, + 23 => 4, + 24 => 4, + 27 => 2, + 30 => 2, + 34 => 1, + 35 => 1, + 39 => 1, + 42 => 1, + 45 => 1, + 48 => 1, + 50 => 2, + 51 => 1, + 55 => 1, + 59 => 4, + 63 => 1, + 65 => 1, + 69 => 3, + 74 => 2, + 77 => 1, + 80 => 1, + 85 => 3, + 89 => 1, + 92 => 1, + 97 => 1, + 103 => 1, + 105 => 1, + 107 => 1, + 110 => 1, + ]; }//end getErrorList() @@ -75,7 +75,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 7f113ca22f..da28dd8bf2 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -25,15 +25,15 @@ class ClassFileNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 10 => 1, - 11 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 1, - ); + return [ + 9 => 1, + 10 => 1, + 11 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 1, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php index c0834b5c7c..1b71eb2c6a 100644 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php @@ -25,11 +25,11 @@ class DuplicatePropertyUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 8 => 1, - 28 => 1, - ); + return [ + 4 => 1, + 8 => 1, + 28 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php index 95a432eddc..8ee4a6fe8a 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php @@ -25,14 +25,14 @@ class LowercaseClassKeywordsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - $errors = array( - 2 => 3, - 3 => 3, - 4 => 1, - 5 => 1, - 9 => 1, - 10 => 1, - ); + $errors = [ + 2 => 3, + 3 => 3, + 4 => 1, + 5 => 1, + 9 => 1, + 10 => 1, + ]; return $errors; @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php index 0d6ac95987..67e65a5653 100644 --- a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php @@ -25,17 +25,17 @@ class SelfMemberReferenceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 24 => 1, - 25 => 1, - 26 => 1, - 30 => 1, - 31 => 1, - 32 => 2, - 79 => 1, - 108 => 1, - 119 => 1, - ); + return [ + 24 => 1, + 25 => 1, + 26 => 1, + 30 => 1, + 31 => 1, + 32 => 2, + 79 => 1, + 108 => 1, + 119 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php index cff835642b..70777c541b 100644 --- a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php @@ -25,29 +25,29 @@ class ValidClassNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 10 => 1, - 14 => 1, - 15 => 1, - 20 => 1, - 30 => 1, - 32 => 1, - 57 => 1, - 58 => 1, - 62 => 1, - 63 => 1, - 68 => 1, - 78 => 1, - 80 => 1, - 97 => 1, - 98 => 1, - 102 => 1, - 103 => 1, - 108 => 1, - 118 => 1, - 120 => 1, - ); + return [ + 9 => 1, + 10 => 1, + 14 => 1, + 15 => 1, + 20 => 1, + 30 => 1, + 32 => 1, + 57 => 1, + 58 => 1, + 62 => 1, + 63 => 1, + 68 => 1, + 78 => 1, + 80 => 1, + 97 => 1, + 98 => 1, + 102 => 1, + 103 => 1, + 108 => 1, + 118 => 1, + 120 => 1, + ]; }//end getErrorList() @@ -62,7 +62,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php index 569e45ac55..94f31769d7 100644 --- a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php @@ -40,39 +40,39 @@ public function setCliValues($testFile, $config) */ public function getErrorList() { - $errors = array( - 8 => 1, - 20 => 1, - 24 => 1, - 30 => 1, - 31 => 1, - 34 => 1, - 40 => 1, - 45 => 1, - 49 => 1, - 51 => 1, - 53 => 1, - 57 => 1, - 60 => 1, - 61 => 1, - 63 => 1, - 65 => 1, - 68 => 1, - 70 => 1, - 72 => 1, - 75 => 1, - 84 => 1, - 87 => 1, - 89 => 1, - 92 => 1, - 111 => 1, - 159 => 1, - 181 => 1, - 188 => 1, - 206 => 1, - 207 => 1, - 214 => 1, - ); + $errors = [ + 8 => 1, + 20 => 1, + 24 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 40 => 1, + 45 => 1, + 49 => 1, + 51 => 1, + 53 => 1, + 57 => 1, + 60 => 1, + 61 => 1, + 63 => 1, + 65 => 1, + 68 => 1, + 70 => 1, + 72 => 1, + 75 => 1, + 84 => 1, + 87 => 1, + 89 => 1, + 92 => 1, + 111 => 1, + 159 => 1, + 181 => 1, + 188 => 1, + 206 => 1, + 207 => 1, + 214 => 1, + ]; return $errors; @@ -89,7 +89,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php index 2052e29cab..80a404be07 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php @@ -25,12 +25,12 @@ class ClassCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 15 => 1, - 31 => 1, - 54 => 1, - ); + return [ + 2 => 1, + 15 => 1, + 31 => 1, + 54 => 1, + ]; }//end getErrorList() @@ -45,13 +45,13 @@ public function getErrorList() */ public function getWarningList() { - return array( - 29 => 1, - 30 => 1, - 50 => 1, - 66 => 1, - 67 => 1, - ); + return [ + 29 => 1, + 30 => 1, + 50 => 1, + 66 => 1, + 67 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php index 06d0cb332c..cdc89ba670 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php @@ -25,16 +25,16 @@ class ClosingDeclarationCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 13 => 1, - 17 => 1, - 31 => 1, - 41 => 1, - 59 => 1, - 63 => 1, - 67 => 1, - 79 => 1, - ); + return [ + 13 => 1, + 17 => 1, + 31 => 1, + 41 => 1, + 59 => 1, + 63 => 1, + 67 => 1, + 79 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(71 => 1); + return [71 => 1]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index 82ccdfcfef..974951ce42 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -27,21 +27,21 @@ class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='DocCommentAlignmentUnitTest.inc') { - $errors = array( - 3 => 1, - 11 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - 23 => 2, - 24 => 1, - 25 => 2, - 26 => 1, - 32 => 1, - 33 => 1, - 38 => 1, - 39 => 1, - ); + $errors = [ + 3 => 1, + 11 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 23 => 2, + 24 => 1, + 25 => 2, + 26 => 1, + 32 => 1, + 33 => 1, + 38 => 1, + 39 => 1, + ]; if ($testFile === 'DocCommentAlignmentUnitTest.inc') { $errors[75] = 1; @@ -62,7 +62,7 @@ public function getErrorList($testFile='DocCommentAlignmentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php index 5448b4f0d9..3c1668e440 100644 --- a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php @@ -25,14 +25,14 @@ class EmptyCatchCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 13 => 1, - 33 => 1, - 49 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - ); + return [ + 13 => 1, + 33 => 1, + 49 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index e22a360ea3..53d40c232f 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -30,19 +30,19 @@ public function getErrorList($testFile='FileCommentUnitTest.inc') switch ($testFile) { case 'FileCommentUnitTest.inc': case 'FileCommentUnitTest.js': - return array( - 1 => 1, - 22 => 2, - 23 => 1, - 24 => 2, - 25 => 2, - 26 => 1, - 27 => 2, - 28 => 2, - 32 => 2, - ); + return [ + 1 => 1, + 22 => 2, + 23 => 1, + 24 => 2, + 25 => 2, + 26 => 1, + 27 => 2, + 28 => 2, + 32 => 2, + ]; default: - return array(); + return []; } }//end getErrorList() @@ -58,7 +58,7 @@ public function getErrorList($testFile='FileCommentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php index 27d984b24d..3a8848f2f6 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php @@ -25,18 +25,18 @@ class FunctionCommentThrowTagUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 9 => 1, - 21 => 1, - 35 => 1, - 47 => 1, - 61 => 2, - 106 => 1, - 123 => 1, - 200 => 1, - 219 => 1, - 287 => 1, - ); + return [ + 9 => 1, + 21 => 1, + 35 => 1, + 47 => 1, + 61 => 2, + 106 => 1, + 123 => 1, + 200 => 1, + 219 => 1, + 287 => 1, + ]; }//end getErrorList() @@ -51,7 +51,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index a6feadc828..affe31c079 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -25,94 +25,94 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - $errors = array( - 5 => 1, - 10 => 3, - 12 => 2, - 13 => 2, - 14 => 1, - 15 => 1, - 28 => 1, - 43 => 1, - 76 => 1, - 87 => 1, - 103 => 1, - 109 => 1, - 112 => 1, - 122 => 1, - 123 => 3, - 124 => 2, - 125 => 1, - 126 => 1, - 137 => 4, - 138 => 4, - 139 => 4, - 143 => 2, - 152 => 1, - 155 => 2, - 159 => 1, - 166 => 1, - 173 => 1, - 183 => 1, - 190 => 2, - 193 => 2, - 196 => 1, - 199 => 2, - 210 => 1, - 211 => 1, - 222 => 1, - 223 => 1, - 224 => 1, - 225 => 1, - 226 => 1, - 227 => 1, - 230 => 2, - 232 => 2, - 246 => 1, - 248 => 4, - 261 => 1, - 263 => 1, - 276 => 1, - 277 => 1, - 278 => 1, - 279 => 1, - 280 => 1, - 281 => 1, - 284 => 1, - 286 => 7, - 294 => 1, - 302 => 1, - 312 => 1, - 358 => 1, - 359 => 2, - 372 => 1, - 373 => 1, - 387 => 1, - 407 => 1, - 441 => 1, - 500 => 1, - 526 => 1, - 548 => 1, - 641 => 1, - 669 => 1, - 688 => 1, - 744 => 1, - 748 => 1, - 767 => 1, - 789 => 1, - 792 => 1, - 794 => 1, - 797 => 1, - 801 => 1, - 828 => 1, - 840 => 1, - 852 => 1, - 864 => 1, - 886 => 1, - 888 => 1, - 890 => 1, - 978 => 1, - ); + $errors = [ + 5 => 1, + 10 => 3, + 12 => 2, + 13 => 2, + 14 => 1, + 15 => 1, + 28 => 1, + 43 => 1, + 76 => 1, + 87 => 1, + 103 => 1, + 109 => 1, + 112 => 1, + 122 => 1, + 123 => 3, + 124 => 2, + 125 => 1, + 126 => 1, + 137 => 4, + 138 => 4, + 139 => 4, + 143 => 2, + 152 => 1, + 155 => 2, + 159 => 1, + 166 => 1, + 173 => 1, + 183 => 1, + 190 => 2, + 193 => 2, + 196 => 1, + 199 => 2, + 210 => 1, + 211 => 1, + 222 => 1, + 223 => 1, + 224 => 1, + 225 => 1, + 226 => 1, + 227 => 1, + 230 => 2, + 232 => 2, + 246 => 1, + 248 => 4, + 261 => 1, + 263 => 1, + 276 => 1, + 277 => 1, + 278 => 1, + 279 => 1, + 280 => 1, + 281 => 1, + 284 => 1, + 286 => 7, + 294 => 1, + 302 => 1, + 312 => 1, + 358 => 1, + 359 => 2, + 372 => 1, + 373 => 1, + 387 => 1, + 407 => 1, + 441 => 1, + 500 => 1, + 526 => 1, + 548 => 1, + 641 => 1, + 669 => 1, + 688 => 1, + 744 => 1, + 748 => 1, + 767 => 1, + 789 => 1, + 792 => 1, + 794 => 1, + 797 => 1, + 801 => 1, + 828 => 1, + 840 => 1, + 852 => 1, + 864 => 1, + 886 => 1, + 888 => 1, + 890 => 1, + 978 => 1, + ]; // Scalar type hints only work from PHP 7 onwards. if (PHP_VERSION_ID >= 70000) { @@ -148,7 +148,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index d821b2e5ef..a1cfde3efa 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -29,44 +29,44 @@ public function getErrorList($testFile='InlineCommentUnitTest.inc') { switch ($testFile) { case 'InlineCommentUnitTest.inc': - $errors = array( - 17 => 1, - 27 => 1, - 28 => 1, - 32 => 2, - 36 => 1, - 44 => 2, - 58 => 1, - 61 => 1, - 64 => 1, - 67 => 1, - 95 => 1, - 96 => 1, - 97 => 3, - 118 => 1, - 126 => 2, - 130 => 2, - ); + $errors = [ + 17 => 1, + 27 => 1, + 28 => 1, + 32 => 2, + 36 => 1, + 44 => 2, + 58 => 1, + 61 => 1, + 64 => 1, + 67 => 1, + 95 => 1, + 96 => 1, + 97 => 3, + 118 => 1, + 126 => 2, + 130 => 2, + ]; return $errors; case 'InlineCommentUnitTest.js': - return array( - 31 => 1, - 36 => 2, - 48 => 1, - 51 => 1, - 54 => 1, - 57 => 1, - 102 => 1, - 103 => 1, - 104 => 3, - 118 => 1, - 121 => 1, - 125 => 2, - 129 => 2, - ); + return [ + 31 => 1, + 36 => 2, + 48 => 1, + 51 => 1, + 54 => 1, + 57 => 1, + 102 => 1, + 103 => 1, + 104 => 3, + 118 => 1, + 121 => 1, + 125 => 2, + 129 => 2, + ]; default: - return array(); + return []; }//end switch }//end getErrorList() @@ -82,7 +82,7 @@ public function getErrorList($testFile='InlineCommentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index 457222ef1e..60d0292d23 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -29,53 +29,53 @@ public function getErrorList($testFile='LongConditionClosingCommentUnitTest.inc' { switch ($testFile) { case 'LongConditionClosingCommentUnitTest.inc': - return array( - 49 => 1, - 99 => 1, - 146 => 1, - 192 => 1, - 215 => 1, - 238 => 1, - 261 => 1, - 286 => 1, - 309 => 1, - 332 => 1, - 355 => 1, - 378 => 1, - 493 => 1, - 531 => 1, - 536 => 1, - 540 => 1, - 562 => 1, - 601 => 1, - 629 => 1, - 663 => 1, - 765 => 1, - 798 => 1, - 811 => 1, - 897 => 1, - 931 => 1, - 962 => 1, - ); + return [ + 49 => 1, + 99 => 1, + 146 => 1, + 192 => 1, + 215 => 1, + 238 => 1, + 261 => 1, + 286 => 1, + 309 => 1, + 332 => 1, + 355 => 1, + 378 => 1, + 493 => 1, + 531 => 1, + 536 => 1, + 540 => 1, + 562 => 1, + 601 => 1, + 629 => 1, + 663 => 1, + 765 => 1, + 798 => 1, + 811 => 1, + 897 => 1, + 931 => 1, + 962 => 1, + ]; break; case 'LongConditionClosingCommentUnitTest.js': - return array( - 47 => 1, - 97 => 1, - 144 => 1, - 190 => 1, - 213 => 1, - 238 => 1, - 261 => 1, - 284 => 1, - 307 => 1, - 401 => 1, - 439 => 1, - 444 => 1, - ); + return [ + 47 => 1, + 97 => 1, + 144 => 1, + 190 => 1, + 213 => 1, + 238 => 1, + 261 => 1, + 284 => 1, + 307 => 1, + 401 => 1, + 439 => 1, + 444 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -92,7 +92,7 @@ public function getErrorList($testFile='LongConditionClosingCommentUnitTest.inc' */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index 9ef7079bc7..d009dc6751 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -29,21 +29,21 @@ public function getErrorList($testFile='PostStatementCommentUnitTest.inc') { switch ($testFile) { case 'PostStatementCommentUnitTest.inc': - return array( - 6 => 1, - 10 => 1, - 18 => 1, - ); + return [ + 6 => 1, + 10 => 1, + 18 => 1, + ]; break; case 'PostStatementCommentUnitTest.js': - return array( - 1 => 1, - 4 => 1, - 9 => 1, - ); + return [ + 1 => 1, + 4 => 1, + 9 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -60,7 +60,7 @@ public function getErrorList($testFile='PostStatementCommentUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php index 934a3f98bd..b3d05846cb 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php @@ -25,37 +25,37 @@ class VariableCommentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 21 => 1, - 24 => 1, - 56 => 1, - 64 => 1, - 73 => 1, - 84 => 1, - 130 => 1, - 136 => 1, - 144 => 1, - 152 => 1, - 160 => 1, - 168 => 1, - 176 => 1, - 184 => 1, - 192 => 1, - 200 => 1, - 208 => 1, - 216 => 1, - 224 => 1, - 232 => 1, - 240 => 1, - 248 => 1, - 256 => 1, - 264 => 1, - 272 => 1, - 280 => 1, - 290 => 1, - 305 => 1, - 330 => 1, - ); + return [ + 21 => 1, + 24 => 1, + 56 => 1, + 64 => 1, + 73 => 1, + 84 => 1, + 130 => 1, + 136 => 1, + 144 => 1, + 152 => 1, + 160 => 1, + 168 => 1, + 176 => 1, + 184 => 1, + 192 => 1, + 200 => 1, + 208 => 1, + 216 => 1, + 224 => 1, + 232 => 1, + 240 => 1, + 248 => 1, + 256 => 1, + 264 => 1, + 272 => 1, + 280 => 1, + 290 => 1, + 305 => 1, + 330 => 1, + ]; }//end getErrorList() @@ -70,7 +70,7 @@ public function getErrorList() */ public function getWarningList() { - return array(93 => 1); + return [93 => 1]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 6f3da6432c..98bad5f5ca 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -27,28 +27,28 @@ class ControlSignatureUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='ControlSignatureUnitTest.inc') { - $errors = array( - 7 => 1, - 12 => 1, - 15 => 1, - 18 => 1, - 20 => 1, - 22 => 2, - 28 => 2, - 32 => 1, - 38 => 2, - 42 => 1, - 48 => 2, - 52 => 1, - 62 => 2, - 66 => 2, - 76 => 4, - 80 => 2, - 94 => 1, - 99 => 1, - 108 => 1, - 112 => 1, - ); + $errors = [ + 7 => 1, + 12 => 1, + 15 => 1, + 18 => 1, + 20 => 1, + 22 => 2, + 28 => 2, + 32 => 1, + 38 => 2, + 42 => 1, + 48 => 2, + 52 => 1, + 62 => 2, + 66 => 2, + 76 => 4, + 80 => 2, + 94 => 1, + 99 => 1, + 108 => 1, + 112 => 1, + ]; if ($testFile === 'ControlSignatureUnitTest.inc') { $errors[122] = 1; @@ -86,7 +86,7 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index 7948e9d1c9..f0d9210f38 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -25,10 +25,10 @@ class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 8 => 1, - 13 => 1, - ); + return [ + 8 => 1, + 13 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php index 9d44815520..6957ff6781 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php @@ -25,15 +25,15 @@ class ForEachLoopDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 8 => 2, - 11 => 2, - 14 => 2, - 17 => 5, - 21 => 7, - 26 => 2, - 28 => 2, - ); + return [ + 8 => 2, + 11 => 2, + 14 => 2, + 17 => 5, + 21 => 7, + 26 => 2, + 28 => 2, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 8387a34f02..c6ed9135ab 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -29,33 +29,33 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc') { switch ($testFile) { case 'ForLoopDeclarationUnitTest.inc': - return array( - 8 => 2, - 11 => 2, - 14 => 2, - 17 => 2, - 21 => 6, - 27 => 1, - 30 => 1, - 37 => 2, - 39 => 2, - ); + return [ + 8 => 2, + 11 => 2, + 14 => 2, + 17 => 2, + 21 => 6, + 27 => 1, + 30 => 1, + 37 => 2, + 39 => 2, + ]; break; case 'ForLoopDeclarationUnitTest.js': - return array( - 6 => 2, - 9 => 2, - 12 => 2, - 15 => 2, - 19 => 6, - 33 => 1, - 36 => 1, - 43 => 2, - 45 => 2, - ); + return [ + 6 => 2, + 9 => 2, + 12 => 2, + 15 => 2, + 19 => 6, + 33 => 1, + 36 => 1, + 43 => 2, + 45 => 2, + ]; break; default: - return array(); + return []; break; }//end switch @@ -72,7 +72,7 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php index ae37bb994b..d0e4cad4f8 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php @@ -24,7 +24,7 @@ class InlineIfDeclarationUnitTest extends AbstractSniffUnitTest */ public function getCliValues($testFile) { - return array('--encoding=utf-8'); + return ['--encoding=utf-8']; }//end getCliValues() @@ -39,20 +39,20 @@ public function getCliValues($testFile) */ public function getErrorList() { - return array( - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 10 => 1, - 13 => 1, - 20 => 1, - 24 => 4, - 44 => 1, - 47 => 1, - ); + return [ + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 10 => 1, + 13 => 1, + 20 => 1, + 24 => 4, + 44 => 1, + 47 => 1, + ]; }//end getErrorList() @@ -67,7 +67,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php index 750b541841..758119084f 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php @@ -25,19 +25,19 @@ class LowercaseDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 7 => 1, - 9 => 1, - 10 => 1, - 12 => 1, - 14 => 1, - 15 => 1, - 16 => 1, - 20 => 1, - 21 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 7 => 1, + 9 => 1, + 10 => 1, + 12 => 1, + 14 => 1, + 15 => 1, + 16 => 1, + 20 => 1, + 21 => 1, + ]; }//end getErrorList() @@ -52,7 +52,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 85df3069db..ab392c6181 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -27,48 +27,48 @@ class SwitchDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='SwitchDeclarationUnitTest.inc') { - return array( - 27 => 1, - 29 => 1, - 34 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 52 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 62 => 1, - 79 => 1, - 85 => 2, - 88 => 2, - 89 => 2, - 92 => 1, - 95 => 3, - 99 => 1, - 116 => 1, - 122 => 1, - 127 => 2, - 134 => 2, - 135 => 1, - 138 => 1, - 143 => 1, - 144 => 1, - 147 => 1, - 165 => 1, - 172 => 1, - 176 => 2, - 180 => 1, - 192 => 2, - 196 => 1, - 223 => 1, - 266 => 1, - 282 => 1, - 284 => 2, - ); + return [ + 27 => 1, + 29 => 1, + 34 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 52 => 1, + 54 => 1, + 55 => 1, + 56 => 1, + 58 => 1, + 59 => 1, + 61 => 1, + 62 => 1, + 79 => 1, + 85 => 2, + 88 => 2, + 89 => 2, + 92 => 1, + 95 => 3, + 99 => 1, + 116 => 1, + 122 => 1, + 127 => 2, + 134 => 2, + 135 => 1, + 138 => 1, + 143 => 1, + 144 => 1, + 147 => 1, + 165 => 1, + 172 => 1, + 176 => 2, + 180 => 1, + 192 => 2, + 196 => 1, + 223 => 1, + 266 => 1, + 282 => 1, + 284 => 2, + ]; }//end getErrorList() @@ -86,10 +86,10 @@ public function getErrorList($testFile='SwitchDeclarationUnitTest.inc') public function getWarningList($testFile='SwitchDeclarationUnitTest.inc') { if ($testFile === 'SwitchDeclarationUnitTest.js') { - return array(273 => 1); + return [273 => 1]; } - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php index 0658e2839b..6c5bdb6393 100644 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php @@ -39,7 +39,7 @@ protected function shouldSkipTest() */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -54,10 +54,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 1 => 2, - 2 => 1, - ); + return [ + 1 => 2, + 2 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php index aed0593cb7..15b2acd658 100644 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php @@ -39,7 +39,7 @@ protected function shouldSkipTest() */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList() */ public function getWarningList() { - return array(2 => 1); + return [2 => 1]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php index 4efa0aee17..7e613b330b 100644 --- a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php +++ b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php @@ -29,9 +29,9 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'FileExtensionUnitTest.1.inc': - return array(1 => 1); + return [1 => 1]; default: - return array(); + return []; } }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index f903e523c5..5d7dd5d603 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -29,61 +29,61 @@ public function getErrorList($testFile='OperatorBracketUnitTest.inc') { switch ($testFile) { case 'OperatorBracketUnitTest.inc': - return array( - 3 => 1, - 6 => 1, - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 2, - 20 => 1, - 25 => 1, - 28 => 1, - 31 => 1, - 34 => 1, - 37 => 1, - 40 => 1, - 43 => 2, - 45 => 1, - 47 => 5, - 48 => 1, - 50 => 2, - 55 => 2, - 56 => 1, - 63 => 2, - 64 => 1, - 67 => 1, - 86 => 1, - 90 => 1, - 109 => 1, - 130 => 1, - 134 => 1, - 135 => 2, - 137 => 1, - 139 => 1, - 150 => 1, - 161 => 1, - ); + return [ + 3 => 1, + 6 => 1, + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 2, + 20 => 1, + 25 => 1, + 28 => 1, + 31 => 1, + 34 => 1, + 37 => 1, + 40 => 1, + 43 => 2, + 45 => 1, + 47 => 5, + 48 => 1, + 50 => 2, + 55 => 2, + 56 => 1, + 63 => 2, + 64 => 1, + 67 => 1, + 86 => 1, + 90 => 1, + 109 => 1, + 130 => 1, + 134 => 1, + 135 => 2, + 137 => 1, + 139 => 1, + 150 => 1, + 161 => 1, + ]; break; case 'OperatorBracketUnitTest.js': - return array( - 5 => 1, - 8 => 1, - 11 => 1, - 14 => 1, - 24 => 1, - 30 => 1, - 33 => 1, - 36 => 1, - 39 => 1, - 46 => 1, - 47 => 1, - 63 => 1, - 108 => 1, - ); + return [ + 5 => 1, + 8 => 1, + 11 => 1, + 14 => 1, + 24 => 1, + 30 => 1, + 33 => 1, + 36 => 1, + 39 => 1, + 46 => 1, + 47 => 1, + 63 => 1, + 108 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -100,7 +100,7 @@ public function getErrorList($testFile='OperatorBracketUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 3c85c763c0..dd1619ccd1 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -25,31 +25,31 @@ class FunctionDeclarationArgumentSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 2, - 7 => 2, - 8 => 2, - 9 => 2, - 11 => 2, - 13 => 7, - 14 => 2, - 15 => 2, - 16 => 4, - 18 => 2, - 35 => 2, - 36 => 3, - 44 => 2, - 45 => 1, - 46 => 1, - 51 => 2, - 53 => 2, - 55 => 1, - 56 => 1, - 58 => 1, - 73 => 7, - 76 => 1, - ); + return [ + 3 => 1, + 5 => 2, + 7 => 2, + 8 => 2, + 9 => 2, + 11 => 2, + 13 => 7, + 14 => 2, + 15 => 2, + 16 => 4, + 18 => 2, + 35 => 2, + 36 => 3, + 44 => 2, + 45 => 1, + 46 => 1, + 51 => 2, + 53 => 2, + 55 => 1, + 56 => 1, + 58 => 1, + 73 => 7, + 76 => 1, + ]; }//end getErrorList() @@ -64,7 +64,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php index 6ab31e4556..a939a9051f 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php @@ -25,10 +25,10 @@ class FunctionDeclarationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 55 => 1, - 68 => 1, - ); + return [ + 55 => 1, + 68 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php index c8ca923562..da09cef348 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php @@ -25,11 +25,11 @@ class FunctionDuplicateArgumentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 4 => 2, - 5 => 1, - ); + return [ + 2 => 1, + 4 => 2, + 5 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php index ca93fc94fa..7be76488e6 100644 --- a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php @@ -25,7 +25,7 @@ class GlobalFunctionUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(2 => 1); + return [2 => 1]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php index d1529b4c15..3952147a8b 100644 --- a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php @@ -25,13 +25,13 @@ class LowercaseFunctionKeywordsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index 23004759dd..24259a5e79 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -28,46 +28,46 @@ class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc') { if ($testFile === 'MultiLineFunctionDeclarationUnitTest.inc') { - $errors = array( - 2 => 1, - 3 => 1, - 4 => 2, - 5 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 36 => 1, - 43 => 2, - 48 => 1, - 81 => 1, - 82 => 2, - 88 => 1, - 102 => 2, - 137 => 1, - 141 => 2, - 142 => 1, - 158 => 1, - 160 => 1, - ); + $errors = [ + 2 => 1, + 3 => 1, + 4 => 2, + 5 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 36 => 1, + 43 => 2, + 48 => 1, + 81 => 1, + 82 => 2, + 88 => 1, + 102 => 2, + 137 => 1, + 141 => 2, + 142 => 1, + 158 => 1, + 160 => 1, + ]; } else { - $errors = array( - 2 => 1, - 3 => 1, - 4 => 2, - 5 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 26 => 1, - 36 => 1, - 43 => 2, - 48 => 1, - 65 => 1, - ); + $errors = [ + 2 => 1, + 3 => 1, + 4 => 2, + 5 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 26 => 1, + 36 => 1, + 43 => 2, + 48 => 1, + 65 => 1, + ]; }//end if return $errors; @@ -85,7 +85,7 @@ public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php index bad979e8a8..9fd927cf16 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -25,18 +25,18 @@ class ValidFunctionNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ); + return [ + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + ]; }//end getErrorList() @@ -51,7 +51,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index 5e14e7333f..4e6a22ed67 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -25,36 +25,36 @@ class ValidVariableNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - $errors = array( - 3 => 1, - 5 => 1, - 10 => 1, - 12 => 1, - 15 => 1, - 17 => 1, - 20 => 1, - 22 => 1, - 25 => 1, - 27 => 1, - 31 => 1, - 33 => 1, - 36 => 1, - 37 => 1, - 39 => 1, - 42 => 1, - 44 => 1, - 53 => 1, - 58 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 67 => 1, - 81 => 1, - 106 => 1, - 107 => 1, - 108 => 1, - 117 => 1, - ); + $errors = [ + 3 => 1, + 5 => 1, + 10 => 1, + 12 => 1, + 15 => 1, + 17 => 1, + 20 => 1, + 22 => 1, + 25 => 1, + 27 => 1, + 31 => 1, + 33 => 1, + 36 => 1, + 37 => 1, + 39 => 1, + 42 => 1, + 44 => 1, + 53 => 1, + 58 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 67 => 1, + 81 => 1, + 106 => 1, + 107 => 1, + 108 => 1, + 117 => 1, + ]; return $errors; @@ -71,7 +71,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php index 9f24318722..cb2d58e543 100644 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php @@ -28,15 +28,15 @@ class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='DisallowObjectStringIndexUnitTest.js') { if ($testFile !== 'DisallowObjectStringIndexUnitTest.js') { - return array(); + return []; } - return array( - 13 => 1, - 17 => 1, - 25 => 1, - 35 => 1, - ); + return [ + 13 => 1, + 17 => 1, + 25 => 1, + 35 => 1, + ]; }//end getErrorList() @@ -51,7 +51,7 @@ public function getErrorList($testFile='DisallowObjectStringIndexUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php index 8524f79864..fa32521c85 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php @@ -25,10 +25,10 @@ class ObjectInstantiationUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 8 => 1, - ); + return [ + 5 => 1, + 8 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php index 2fba3341af..ab712da264 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php @@ -28,14 +28,14 @@ class ObjectMemberCommaUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='ObjectMemberCommaUnitTest.js') { if ($testFile !== 'ObjectMemberCommaUnitTest.js') { - return array(); + return []; } - return array( - 1 => 1, - 22 => 1, - 38 => 1, - ); + return [ + 1 => 1, + 22 => 1, + 38 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList($testFile='ObjectMemberCommaUnitTest.js') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index cd7808431f..ee6773fe76 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -29,53 +29,53 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') { switch ($testFile) { case 'ComparisonOperatorUsageUnitTest.inc': - return array( - 6 => 1, - 7 => 1, - 10 => 1, - 11 => 1, - 18 => 1, - 19 => 1, - 22 => 1, - 23 => 1, - 29 => 2, - 32 => 2, - 38 => 4, - 47 => 2, - 69 => 1, - 72 => 1, - 75 => 1, - 78 => 1, - 80 => 1, - 82 => 1, - 83 => 1, - 89 => 1, - 92 => 1, - 100 => 1, - 106 => 1, - 112 => 1, - 123 => 1, - 127 => 1, - 131 => 1, - ); + return [ + 6 => 1, + 7 => 1, + 10 => 1, + 11 => 1, + 18 => 1, + 19 => 1, + 22 => 1, + 23 => 1, + 29 => 2, + 32 => 2, + 38 => 4, + 47 => 2, + 69 => 1, + 72 => 1, + 75 => 1, + 78 => 1, + 80 => 1, + 82 => 1, + 83 => 1, + 89 => 1, + 92 => 1, + 100 => 1, + 106 => 1, + 112 => 1, + 123 => 1, + 127 => 1, + 131 => 1, + ]; break; case 'ComparisonOperatorUsageUnitTest.js': - return array( - 5 => 1, - 6 => 1, - 17 => 1, - 18 => 1, - 28 => 2, - 40 => 1, - 47 => 1, - 52 => 1, - 63 => 1, - 67 => 1, - 71 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 17 => 1, + 18 => 1, + 28 => 2, + 40 => 1, + 47 => 1, + 52 => 1, + 63 => 1, + 67 => 1, + 71 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -92,7 +92,7 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index 915a133e8f..768911b508 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -25,17 +25,17 @@ class IncrementDecrementUsageUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 6 => 1, - 12 => 1, - 16 => 1, - 25 => 1, - 26 => 1, - 27 => 1, - 29 => 1, - 31 => 1, - ); + return [ + 2 => 1, + 6 => 1, + 12 => 1, + 16 => 1, + 25 => 1, + 26 => 1, + 27 => 1, + 29 => 1, + 31 => 1, + ]; }//end getErrorList() @@ -50,7 +50,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php index d810a50f15..fc35131982 100644 --- a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php @@ -25,11 +25,11 @@ class ValidLogicalOperatorsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 11 => 1, - 17 => 2, - ); + return [ + 5 => 1, + 11 => 1, + 17 => 2, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index c7217c1df9..079cd96c92 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -25,7 +25,7 @@ class CommentedOutCodeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -44,22 +44,22 @@ public function getWarningList($testFile='CommentedOutCodeUnitTest.inc') { switch ($testFile) { case 'CommentedOutCodeUnitTest.inc': - return array( - 6 => 1, - 8 => 1, - 15 => 1, - 19 => 1, - 87 => 1, - ); + return [ + 6 => 1, + 8 => 1, + 15 => 1, + 19 => 1, + 87 => 1, + ]; break; case 'CommentedOutCodeUnitTest.css': - return array( - 7 => 1, - 16 => 1, - ); + return [ + 7 => 1, + 16 => 1, + ]; break; default: - return array(); + return []; break; }//end switch diff --git a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php index 5fa63a5ddc..6439b63237 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php @@ -25,12 +25,12 @@ class DisallowBooleanStatementUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 8 => 1, - 13 => 1, - 15 => 1, - ); + return [ + 3 => 1, + 8 => 1, + 13 => 1, + 15 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php index a608bb42b3..c9bb3da60f 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php @@ -25,16 +25,16 @@ class DisallowComparisonAssignmentUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 10 => 1, - 52 => 1, - 53 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 10 => 1, + 52 => 1, + 53 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index 6af03dbb24..35310727d9 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -29,13 +29,13 @@ public function getErrorList($testFile='DisallowInlineIfUnitTest.inc') { switch ($testFile) { case 'DisallowInlineIfUnitTest.inc': - return array(8 => 1); + return [8 => 1]; break; case 'DisallowInlineIfUnitTest.js': - return array(1 => 1); + return [1 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -52,7 +52,7 @@ public function getErrorList($testFile='DisallowInlineIfUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php index 0b2315ad9e..b619b7bcee 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php @@ -25,14 +25,14 @@ class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 5 => 2, - 7 => 1, - 9 => 1, - 12 => 1, - 14 => 1, - ); + return [ + 4 => 1, + 5 => 2, + 7 => 1, + 9 => 1, + 12 => 1, + 14 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php index f67f41bb5e..0b8215cd5e 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php @@ -25,7 +25,7 @@ class DisallowObEndFlushUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(9 => 1); + return [9 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 908f865086..21260ad718 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -29,26 +29,26 @@ public function getErrorList($testFile='DisallowSizeFunctionsInLoopsUnitTest.inc { switch ($testFile) { case 'DisallowSizeFunctionsInLoopsUnitTest.inc': - return array( - 2 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 18 => 1, - 23 => 1, - 27 => 1, - 29 => 1, - 35 => 1, - 40 => 1, - 44 => 1, - 46 => 1, - ); + return [ + 2 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 18 => 1, + 23 => 1, + 27 => 1, + 29 => 1, + 35 => 1, + 40 => 1, + 44 => 1, + 46 => 1, + ]; break; case 'DisallowSizeFunctionsInLoopsUnitTest.js': - return array(1 => 1); + return [1 => 1]; break; default: - return array(); + return []; break; }//end switch @@ -65,7 +65,7 @@ public function getErrorList($testFile='DisallowSizeFunctionsInLoopsUnitTest.inc */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php index 6e992254d3..2b2ff5b4aa 100644 --- a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php @@ -25,7 +25,7 @@ class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,11 +40,11 @@ public function getErrorList() */ public function getWarningList() { - return array( - 2 => 1, - 3 => 1, - 4 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index c507287978..f8cf4cc799 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -25,37 +25,37 @@ class EmbeddedPhpUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 12 => 1, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 3, - 24 => 1, - 26 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 34 => 1, - 36 => 1, - 40 => 1, - 41 => 1, - 44 => 1, - 45 => 1, - 49 => 1, - 59 => 1, - 63 => 1, - 93 => 1, - 94 => 2, - 100 => 1, - 102 => 1, - 112 => 1, - 113 => 1, - 116 => 1, - 117 => 1, - ); + return [ + 7 => 1, + 12 => 1, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 3, + 24 => 1, + 26 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 36 => 1, + 40 => 1, + 41 => 1, + 44 => 1, + 45 => 1, + 49 => 1, + 59 => 1, + 63 => 1, + 93 => 1, + 94 => 2, + 100 => 1, + 102 => 1, + 112 => 1, + 113 => 1, + 116 => 1, + 117 => 1, + ]; }//end getErrorList() @@ -70,7 +70,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php index 7f96ea03e2..adee788268 100644 --- a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php @@ -25,7 +25,7 @@ class EvalUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,10 +40,10 @@ public function getErrorList() */ public function getWarningList() { - return array( - 2 => 1, - 4 => 1, - ); + return [ + 2 => 1, + 4 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php index 7772fd3c08..0116cc1652 100644 --- a/src/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php @@ -25,12 +25,12 @@ class ForbiddenFunctionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - ); + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php index e3404e7493..52f6a00a55 100644 --- a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php @@ -25,10 +25,10 @@ class GlobalKeywordUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 8 => 1, - 9 => 1, - ); + return [ + 8 => 1, + 9 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index 41369ca18c..2f06f0b083 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -25,10 +25,10 @@ class HeredocUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 8 => 1, - ); + return [ + 2 => 1, + 8 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php index 482c02c571..595ea10b9d 100644 --- a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php @@ -25,7 +25,7 @@ class InnerFunctionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(5 => 1); + return [5 => 1]; }//end getErrorList() @@ -40,7 +40,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php index f818ef163c..2f35f703fc 100644 --- a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php @@ -25,10 +25,10 @@ class LowercasePHPFunctionsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 4 => 1, - ); + return [ + 2 => 1, + 4 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index f1ef5c015e..a81f14d915 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -25,7 +25,7 @@ class NonExecutableCodeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -40,36 +40,36 @@ public function getErrorList() */ public function getWarningList() { - return array( - 5 => 1, - 11 => 1, - 17 => 1, - 18 => 1, - 19 => 2, - 28 => 1, - 32 => 1, - 33 => 2, - 34 => 2, - 42 => 1, - 45 => 1, - 54 => 1, - 58 => 1, - 73 => 1, - 83 => 1, - 95 => 1, - 105 => 1, - 123 => 1, - 147 => 1, - 150 => 1, - 153 => 1, - 166 => 1, - 180 => 1, - 232 => 1, - 233 => 1, - 234 => 1, - 235 => 2, - 239 => 1, - ); + return [ + 5 => 1, + 11 => 1, + 17 => 1, + 18 => 1, + 19 => 2, + 28 => 1, + 32 => 1, + 33 => 2, + 34 => 2, + 42 => 1, + 45 => 1, + 54 => 1, + 58 => 1, + 73 => 1, + 83 => 1, + 95 => 1, + 105 => 1, + 123 => 1, + 147 => 1, + 150 => 1, + 153 => 1, + 166 => 1, + 180 => 1, + 232 => 1, + 233 => 1, + 234 => 1, + 235 => 2, + 239 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php index fa1d9ca494..e293d1367a 100644 --- a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php @@ -25,14 +25,14 @@ class MemberVarScopeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 25 => 1, - 29 => 1, - 33 => 1, - 39 => 1, - 41 => 1, - ); + return [ + 7 => 1, + 25 => 1, + 29 => 1, + 33 => 1, + 39 => 1, + 41 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php index 4e8010ee05..6625ad2e82 100644 --- a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php @@ -25,10 +25,10 @@ class MethodScopeUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 6 => 1, - 30 => 1, - ); + return [ + 6 => 1, + 30 => 1, + ]; }//end getErrorList() @@ -43,7 +43,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php index 894d937177..69b925ef89 100644 --- a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php @@ -25,11 +25,11 @@ class StaticThisUsageUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 1, - 8 => 1, - 9 => 1, - ); + return [ + 7 => 1, + 8 => 1, + 9 => 1, + ]; }//end getErrorList() @@ -44,7 +44,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php index 2dc063247f..862af7d203 100644 --- a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php @@ -25,25 +25,25 @@ class ConcatenationSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 5, - 5 => 1, - 6 => 1, - 9 => 1, - 10 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 16 => 5, - 22 => 1, - 27 => 5, - 29 => 1, - 30 => 1, - 31 => 1, - 47 => 2, - 49 => 1, - ); + return [ + 3 => 5, + 5 => 1, + 6 => 1, + 9 => 1, + 10 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 16 => 5, + 22 => 1, + 27 => 5, + 29 => 1, + 30 => 1, + 31 => 1, + 47 => 2, + 49 => 1, + ]; }//end getErrorList() @@ -58,7 +58,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php index e0fda07bdf..a95d1888b2 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php @@ -25,21 +25,21 @@ class DoubleQuoteUsageUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 5 => 1, - 6 => 1, - 8 => 2, - 14 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 20 => 1, - 22 => 1, - 29 => 1, - 30 => 1, - 32 => 1, - ); + return [ + 4 => 1, + 5 => 1, + 6 => 1, + 8 => 2, + 14 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 20 => 1, + 22 => 1, + 29 => 1, + 30 => 1, + 32 => 1, + ]; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php index 95954d01a7..0d9af1e936 100644 --- a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php @@ -25,14 +25,14 @@ class EchoedStringsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 13 => 1, - ); + return [ + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 13 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php index ee54cdabb4..28b594d652 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php @@ -25,12 +25,12 @@ class CastSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - ); + return [ + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + ]; }//end getErrorList() @@ -45,7 +45,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index 987fecf622..0352353153 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -29,51 +29,51 @@ public function getErrorList($testFile='ControlStructureSpacingUnitTest.inc') { switch ($testFile) { case 'ControlStructureSpacingUnitTest.inc': - return array( - 3 => 1, - 5 => 1, - 8 => 1, - 15 => 1, - 23 => 1, - 74 => 1, - 79 => 1, - 82 => 1, - 83 => 1, - 87 => 1, - 103 => 1, - 113 => 2, - 114 => 2, - 118 => 1, - 150 => 1, - 153 => 1, - 154 => 1, - 157 => 1, - 170 => 1, - 176 => 2, - 179 => 1, - 189 => 1, - 222 => 1, - 233 => 1, - 235 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 8 => 1, + 15 => 1, + 23 => 1, + 74 => 1, + 79 => 1, + 82 => 1, + 83 => 1, + 87 => 1, + 103 => 1, + 113 => 2, + 114 => 2, + 118 => 1, + 150 => 1, + 153 => 1, + 154 => 1, + 157 => 1, + 170 => 1, + 176 => 2, + 179 => 1, + 189 => 1, + 222 => 1, + 233 => 1, + 235 => 1, + ]; break; case 'ControlStructureSpacingUnitTest.js': - return array( - 3 => 1, - 9 => 1, - 15 => 1, - 21 => 1, - 56 => 1, - 61 => 1, - 64 => 1, - 65 => 1, - 68 => 1, - 74 => 2, - 75 => 2, - ); + return [ + 3 => 1, + 9 => 1, + 15 => 1, + 21 => 1, + 56 => 1, + 61 => 1, + 64 => 1, + 65 => 1, + 68 => 1, + 74 => 2, + 75 => 2, + ]; break; default: - return array(); + return []; break; }//end switch @@ -90,7 +90,7 @@ public function getErrorList($testFile='ControlStructureSpacingUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index b08253d66a..2e18f875b3 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -29,29 +29,29 @@ public function getErrorList($testFile='FunctionClosingBraceSpaceUnitTest.inc') { switch ($testFile) { case 'FunctionClosingBraceSpaceUnitTest.inc': - return array( - 10 => 1, - 21 => 1, - 28 => 1, - 29 => 1, - 31 => 1, - 39 => 1, - ); + return [ + 10 => 1, + 21 => 1, + 28 => 1, + 29 => 1, + 31 => 1, + 39 => 1, + ]; break; case 'FunctionClosingBraceSpaceUnitTest.js': - return array( - 13 => 1, - 25 => 1, - 32 => 1, - 53 => 1, - 59 => 1, - 67 => 1, - 84 => 1, - 128 => 1, - ); + return [ + 13 => 1, + 25 => 1, + 32 => 1, + 53 => 1, + 59 => 1, + 67 => 1, + 84 => 1, + 128 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -68,7 +68,7 @@ public function getErrorList($testFile='FunctionClosingBraceSpaceUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index f6ff6e44a2..adeb76723f 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -29,21 +29,21 @@ public function getErrorList($testFile='FunctionOpeningBraceSpaceUnitTest.inc') { switch ($testFile) { case 'FunctionOpeningBraceSpaceUnitTest.inc': - return array( - 10 => 1, - 25 => 1, - ); + return [ + 10 => 1, + 25 => 1, + ]; break; case 'FunctionOpeningBraceSpaceUnitTest.js': - return array( - 11 => 1, - 31 => 1, - 38 => 1, - 88 => 1, - ); + return [ + 11 => 1, + 31 => 1, + 38 => 1, + 88 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -60,7 +60,7 @@ public function getErrorList($testFile='FunctionOpeningBraceSpaceUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index 38c2fdf54e..223321d402 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -25,33 +25,33 @@ class FunctionSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 20 => 1, - 29 => 1, - 38 => 1, - 45 => 1, - 49 => 1, - 55 => 1, - 58 => 1, - 60 => 1, - 75 => 1, - 94 => 1, - 105 => 1, - 107 => 1, - 113 => 2, - 135 => 1, - 154 => 1, - 167 => 2, - 184 => 1, - 218 => 1, - 233 => 1, - 252 => 1, - 275 => 1, - 276 => 1, - 289 => 1, - 291 => 1, - 297 => 1, - ); + return [ + 20 => 1, + 29 => 1, + 38 => 1, + 45 => 1, + 49 => 1, + 55 => 1, + 58 => 1, + 60 => 1, + 75 => 1, + 94 => 1, + 105 => 1, + 107 => 1, + 113 => 2, + 135 => 1, + 154 => 1, + 167 => 2, + 184 => 1, + 218 => 1, + 233 => 1, + 252 => 1, + 275 => 1, + 276 => 1, + 289 => 1, + 291 => 1, + 297 => 1, + ]; }//end getErrorList() @@ -66,7 +66,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index c442050b97..e4ba303793 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -25,16 +25,16 @@ class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 7 => 1, - 11 => 1, - 15 => 1, - 19 => 1, - 23 => 1, - 27 => 1, - 31 => 1, - ); + return [ + 3 => 1, + 7 => 1, + 11 => 1, + 15 => 1, + 19 => 1, + 23 => 1, + 27 => 1, + 31 => 1, + ]; }//end getErrorList() @@ -49,7 +49,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php index ccdd0a23e9..62b74e369f 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php @@ -27,13 +27,13 @@ class LogicalOperatorSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='LogicalOperatorSpacingUnitTest.inc') { - return array( - 4 => 2, - 5 => 3, - 6 => 3, - 15 => 1, - 17 => 1, - ); + return [ + 4 => 2, + 5 => 3, + 6 => 3, + 15 => 1, + 17 => 1, + ]; }//end getErrorList() @@ -48,7 +48,7 @@ public function getErrorList($testFile='LogicalOperatorSpacingUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index 765f75e422..0424eedf66 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -25,27 +25,27 @@ class MemberVarSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 4 => 1, - 7 => 1, - 20 => 1, - 30 => 1, - 35 => 1, - 44 => 1, - 50 => 1, - 73 => 1, - 86 => 1, - 106 => 1, - 115 => 1, - 150 => 1, - 160 => 1, - 165 => 1, - 177 => 1, - 186 => 1, - 200 => 1, - 209 => 1, - 211 => 1, - ); + return [ + 4 => 1, + 7 => 1, + 20 => 1, + 30 => 1, + 35 => 1, + 44 => 1, + 50 => 1, + 73 => 1, + 86 => 1, + 106 => 1, + 115 => 1, + 150 => 1, + 160 => 1, + 165 => 1, + 177 => 1, + 186 => 1, + 200 => 1, + 209 => 1, + 211 => 1, + ]; }//end getErrorList() @@ -60,7 +60,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 745344f72a..3bc2c08a85 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -25,24 +25,24 @@ class ObjectOperatorSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 4 => 2, - 6 => 2, - 8 => 1, - 9 => 1, - 15 => 1, - 16 => 2, - 18 => 2, - 27 => 1, - 28 => 2, - 30 => 2, - 32 => 1, - 33 => 1, - 39 => 1, - 40 => 2, - 42 => 2, - ); + return [ + 3 => 1, + 4 => 2, + 6 => 2, + 8 => 1, + 9 => 1, + 15 => 1, + 16 => 2, + 18 => 2, + 27 => 1, + 28 => 2, + 30 => 2, + 32 => 1, + 33 => 1, + 39 => 1, + 40 => 2, + 42 => 2, + ]; }//end getErrorList() @@ -57,7 +57,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index dc0c9f4811..46d2774cc6 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -29,117 +29,117 @@ public function getErrorList($testFile='OperatorSpacingUnitTest.inc') { switch ($testFile) { case 'OperatorSpacingUnitTest.inc': - return array( - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 8 => 2, - 11 => 1, - 12 => 2, - 13 => 1, - 14 => 1, - 15 => 2, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 2, - 25 => 1, - 26 => 2, - 27 => 1, - 28 => 1, - 29 => 2, - 32 => 1, - 33 => 2, - 34 => 1, - 35 => 1, - 36 => 2, - 40 => 2, - 42 => 2, - 44 => 2, - 45 => 1, - 46 => 2, - 53 => 4, - 54 => 3, - 59 => 10, - 64 => 1, - 77 => 4, - 78 => 1, - 79 => 1, - 80 => 2, - 81 => 1, - 84 => 6, - 85 => 6, - 87 => 4, - 88 => 5, - 90 => 4, - 91 => 5, - 128 => 4, - 132 => 1, - 133 => 1, - 135 => 1, - 136 => 1, - 140 => 1, - 141 => 1, - 174 => 1, - 177 => 1, - 178 => 1, - 179 => 1, - 185 => 2, - 191 => 4, - 194 => 1, - 195 => 1, - 196 => 2, - 199 => 1, - 200 => 1, - 201 => 2, - ); + return [ + 4 => 1, + 5 => 2, + 6 => 1, + 7 => 1, + 8 => 2, + 11 => 1, + 12 => 2, + 13 => 1, + 14 => 1, + 15 => 2, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 2, + 25 => 1, + 26 => 2, + 27 => 1, + 28 => 1, + 29 => 2, + 32 => 1, + 33 => 2, + 34 => 1, + 35 => 1, + 36 => 2, + 40 => 2, + 42 => 2, + 44 => 2, + 45 => 1, + 46 => 2, + 53 => 4, + 54 => 3, + 59 => 10, + 64 => 1, + 77 => 4, + 78 => 1, + 79 => 1, + 80 => 2, + 81 => 1, + 84 => 6, + 85 => 6, + 87 => 4, + 88 => 5, + 90 => 4, + 91 => 5, + 128 => 4, + 132 => 1, + 133 => 1, + 135 => 1, + 136 => 1, + 140 => 1, + 141 => 1, + 174 => 1, + 177 => 1, + 178 => 1, + 179 => 1, + 185 => 2, + 191 => 4, + 194 => 1, + 195 => 1, + 196 => 2, + 199 => 1, + 200 => 1, + 201 => 2, + ]; break; case 'OperatorSpacingUnitTest.js': - return array( - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 8 => 2, - 11 => 1, - 12 => 2, - 13 => 1, - 14 => 1, - 15 => 2, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 2, - 25 => 1, - 26 => 2, - 27 => 1, - 28 => 1, - 29 => 2, - 32 => 1, - 33 => 2, - 34 => 1, - 35 => 1, - 36 => 2, - 40 => 2, - 42 => 2, - 44 => 2, - 45 => 1, - 46 => 2, - 55 => 4, - 65 => 1, - 66 => 1, - 68 => 1, - 69 => 1, - 73 => 1, - 74 => 1, - 100 => 1, - ); + return [ + 4 => 1, + 5 => 2, + 6 => 1, + 7 => 1, + 8 => 2, + 11 => 1, + 12 => 2, + 13 => 1, + 14 => 1, + 15 => 2, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 2, + 25 => 1, + 26 => 2, + 27 => 1, + 28 => 1, + 29 => 2, + 32 => 1, + 33 => 2, + 34 => 1, + 35 => 1, + 36 => 2, + 40 => 2, + 42 => 2, + 44 => 2, + 45 => 1, + 46 => 2, + 55 => 4, + 65 => 1, + 66 => 1, + 68 => 1, + 69 => 1, + 73 => 1, + 74 => 1, + 100 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -156,7 +156,7 @@ public function getErrorList($testFile='OperatorSpacingUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php index 1cff360a91..e80f93670e 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php @@ -25,14 +25,14 @@ class PropertyLabelSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 2 => 1, - 4 => 1, - 9 => 2, - 10 => 1, - 12 => 1, - 18 => 1, - ); + return [ + 2 => 1, + 4 => 1, + 9 => 2, + 10 => 1, + 12 => 1, + 18 => 1, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 4212e3b4d8..53b473bdef 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -25,13 +25,13 @@ class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 11 => 1, - 13 => 1, - 24 => 1, - 80 => 1, - 102 => 1, - ); + return [ + 11 => 1, + 13 => 1, + 24 => 1, + 80 => 1, + 102 => 1, + ]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 7f733c4675..9e8b30a642 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -25,14 +25,14 @@ class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 7 => 2, - 8 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 17 => 2, - ); + return [ + 7 => 2, + 8 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 17 => 2, + ]; }//end getErrorList() @@ -47,7 +47,7 @@ public function getErrorList() */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 13f73214e4..c27958de25 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -29,35 +29,35 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc') { switch ($testFile) { case 'SemicolonSpacingUnitTest.inc': - return array( - 3 => 1, - 4 => 1, - 5 => 2, - 6 => 1, - 8 => 1, - 9 => 1, - 14 => 1, - 16 => 1, - 18 => 1, - 29 => 1, - 30 => 2, - ); + return [ + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 1, + 8 => 1, + 9 => 1, + 14 => 1, + 16 => 1, + 18 => 1, + 29 => 1, + 30 => 2, + ]; break; case 'SemicolonSpacingUnitTest.js': - return array( - 3 => 1, - 4 => 1, - 6 => 1, - 10 => 2, - 11 => 1, - 13 => 1, - 19 => 1, - 22 => 1, - 25 => 1, - ); + return [ + 3 => 1, + 4 => 1, + 6 => 1, + 10 => 2, + 11 => 1, + 13 => 1, + 19 => 1, + 22 => 1, + 25 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -74,7 +74,7 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index 7d9081630d..686cfcc4a5 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -29,44 +29,44 @@ public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc') { switch ($testFile) { case 'SuperfluousWhitespaceUnitTest.inc': - return array( - 2 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 16 => 1, - 23 => 1, - 28 => 1, - 33 => 1, - 53 => 1, - ); + return [ + 2 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 16 => 1, + 23 => 1, + 28 => 1, + 33 => 1, + 53 => 1, + ]; break; case 'SuperfluousWhitespaceUnitTest.1.js': - return array( - 1 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - 15 => 1, - 22 => 1, - 29 => 1, - 38 => 1, - 56 => 1, - ); + return [ + 1 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + 15 => 1, + 22 => 1, + 29 => 1, + 38 => 1, + 56 => 1, + ]; break; case 'SuperfluousWhitespaceUnitTest.1.css': - return array( - 1 => 1, - 8 => 1, - 9 => 1, - 11 => 1, - 25 => 1, - ); + return [ + 1 => 1, + 8 => 1, + 9 => 1, + 11 => 1, + 25 => 1, + ]; break; default: - return array(); + return []; break; }//end switch @@ -83,7 +83,7 @@ public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index 20a1a7c7aa..fd13c0d06e 100644 --- a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -26,7 +26,7 @@ class CodeAnalyzerSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index 82413f5f03..c4d844eab9 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -23,7 +23,7 @@ class ClosingTagSniff implements Sniff */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; }//end register() diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php index 47654382fa..de3a6e1073 100644 --- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -21,10 +21,10 @@ class ValidVariableNameSniff extends AbstractVariableSniff * * @var array */ - private $ignore = array( - T_WHITESPACE, - T_COMMENT, - ); + private $ignore = [ + T_WHITESPACE, + T_COMMENT, + ]; /** @@ -41,33 +41,33 @@ protected function processVariable(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $varName = ltrim($tokens[$stackPtr]['content'], '$'); - $phpReservedVars = array( - '_SERVER' => true, - '_GET' => true, - '_POST' => true, - '_REQUEST' => true, - '_SESSION' => true, - '_ENV' => true, - '_COOKIE' => true, - '_FILES' => true, - 'GLOBALS' => true, - 'http_response_header' => true, - 'HTTP_RAW_POST_DATA' => true, - 'php_errormsg' => true, - ); + $phpReservedVars = [ + '_SERVER' => true, + '_GET' => true, + '_POST' => true, + '_REQUEST' => true, + '_SESSION' => true, + '_ENV' => true, + '_COOKIE' => true, + '_FILES' => true, + 'GLOBALS' => true, + 'http_response_header' => true, + 'HTTP_RAW_POST_DATA' => true, + 'php_errormsg' => true, + ]; // If it's a php reserved var, then its ok. if (isset($phpReservedVars[$varName]) === true) { return; } - $objOperator = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); + $objOperator = $phpcsFile->findNext([T_WHITESPACE], ($stackPtr + 1), null, true); if ($tokens[$objOperator]['code'] === T_OBJECT_OPERATOR) { // Check to see if we are using a variable from an object. - $var = $phpcsFile->findNext(array(T_WHITESPACE), ($objOperator + 1), null, true); + $var = $phpcsFile->findNext([T_WHITESPACE], ($objOperator + 1), null, true); if ($tokens[$var]['code'] === T_STRING) { // Either a var name or a function call, so check for bracket. - $bracket = $phpcsFile->findNext(array(T_WHITESPACE), ($var + 1), null, true); + $bracket = $phpcsFile->findNext([T_WHITESPACE], ($var + 1), null, true); if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) { $objVarName = $tokens[$var]['content']; @@ -82,11 +82,11 @@ protected function processVariable(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($objVarName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addError($error, $var, 'NotCamelCaps', $data); } else if (preg_match('|\d|', $objVarName) === 1) { $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data); } }//end if @@ -98,13 +98,13 @@ protected function processVariable(File $phpcsFile, $stackPtr) // check the main part of the variable name. $originalVarName = $varName; if (substr($varName, 0, 1) === '_') { - $objOperator = $phpcsFile->findPrevious(array(T_WHITESPACE), ($stackPtr - 1), null, true); + $objOperator = $phpcsFile->findPrevious([T_WHITESPACE], ($stackPtr - 1), null, true); if ($tokens[$objOperator]['code'] === T_DOUBLE_COLON) { // The variable lives within a class, and is referenced like // this: MyClass::$_variable, so we don't know its scope. $inClass = true; } else { - $inClass = $phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT)); + $inClass = $phpcsFile->hasCondition($stackPtr, [T_CLASS, T_INTERFACE, T_TRAIT]); } if ($inClass === true) { @@ -114,11 +114,11 @@ protected function processVariable(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($varName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); } else if (preg_match('|\d|', $varName) === 1) { $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($originalVarName); + $data = [$originalVarName]; $phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data); } @@ -144,7 +144,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) if ($public === true) { if (substr($varName, 0, 1) === '_') { $error = 'Public member variable "%s" must not contain a leading underscore'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); return; } @@ -152,10 +152,10 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) if (substr($varName, 0, 1) !== '_') { $scope = ucfirst($memberProps['scope']); $error = '%s member variable "%s" must contain a leading underscore'; - $data = array( - $scope, - $varName, - ); + $data = [ + $scope, + $varName, + ]; $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); return; } @@ -163,11 +163,11 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($varName, false, $public, false) === false) { $error = 'Member variable "%s" is not in valid camel caps format'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data); } else if (preg_match('|\d|', $varName) === 1) { $warning = 'Member variable "%s" contains numbers but this is discouraged'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addWarning($warning, $stackPtr, 'MemberVarContainsNumbers', $data); } @@ -187,20 +187,20 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - 'http_response_header', - 'HTTP_RAW_POST_DATA', - 'php_errormsg', - ); + $phpReservedVars = [ + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + 'http_response_header', + 'HTTP_RAW_POST_DATA', + 'php_errormsg', + ]; if (preg_match_all('|[^\\\]\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) { foreach ($matches[1] as $varName) { @@ -211,11 +211,11 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) if (Common::isCamelCaps($varName, false, true, false) === false) { $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data); } else if (preg_match('|\d|', $varName) === 1) { $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($varName); + $data = [$varName]; $phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data); } }//end foreach diff --git a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php index a24eaff437..d5b80143fa 100644 --- a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +++ b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php @@ -39,7 +39,7 @@ protected function shouldSkipTest() */ public function getErrorList() { - return array(); + return []; }//end getErrorList() @@ -54,7 +54,7 @@ public function getErrorList() */ public function getWarningList() { - return array(2 => 1); + return [2 => 1]; }//end getWarningList() diff --git a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php index 4d3dd6dd8d..8d89953c27 100644 --- a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php @@ -28,10 +28,10 @@ class ClosingTagUnitTest extends AbstractSniffUnitTest public function getErrorList($testFile='') { if ($testFile !== 'ClosingTagUnitTest.1.inc') { - return array(); + return []; } - return array(11 => 1); + return [11 => 1]; }//end getErrorList() @@ -46,7 +46,7 @@ public function getErrorList($testFile='') */ public function getWarningList() { - return array(); + return []; }//end getWarningList() diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index ebd0a6ffd5..4e1eb9a4ee 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -25,33 +25,33 @@ class ValidVariableNameUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return array( - 3 => 1, - 5 => 1, - 11 => 1, - 13 => 1, - 17 => 1, - 19 => 1, - 23 => 1, - 25 => 1, - 29 => 1, - 31 => 1, - 36 => 1, - 38 => 1, - 42 => 1, - 44 => 1, - 48 => 1, - 50 => 1, - 61 => 1, - 67 => 1, - 72 => 1, - 74 => 1, - 75 => 1, - 76 => 1, - 79 => 1, - 96 => 1, - 99 => 1, - ); + return [ + 3 => 1, + 5 => 1, + 11 => 1, + 13 => 1, + 17 => 1, + 19 => 1, + 23 => 1, + 25 => 1, + 29 => 1, + 31 => 1, + 36 => 1, + 38 => 1, + 42 => 1, + 44 => 1, + 48 => 1, + 50 => 1, + 61 => 1, + 67 => 1, + 72 => 1, + 74 => 1, + 75 => 1, + 76 => 1, + 79 => 1, + 96 => 1, + 99 => 1, + ]; }//end getErrorList() @@ -66,23 +66,23 @@ public function getErrorList() */ public function getWarningList() { - return array( - 6 => 1, - 14 => 1, - 20 => 1, - 26 => 1, - 32 => 1, - 39 => 1, - 45 => 1, - 51 => 1, - 64 => 1, - 70 => 1, - 73 => 1, - 76 => 1, - 79 => 1, - 82 => 1, - 94 => 1, - ); + return [ + 6 => 1, + 14 => 1, + 20 => 1, + 26 => 1, + 32 => 1, + 39 => 1, + 45 => 1, + 51 => 1, + 64 => 1, + 70 => 1, + 73 => 1, + 76 => 1, + 79 => 1, + 82 => 1, + 94 => 1, + ]; }//end getWarningList() diff --git a/src/Tokenizers/CSS.php b/src/Tokenizers/CSS.php index ea701ad00d..7c8fdeed4c 100644 --- a/src/Tokenizers/CSS.php +++ b/src/Tokenizers/CSS.php @@ -67,12 +67,12 @@ public function tokenize($string) $string = str_replace('?>', '^PHPCS_CSS_T_CLOSE_TAG^', $string); $tokens = parent::tokenize(''); - $finalTokens = array(); - $finalTokens[0] = array( - 'code' => T_OPEN_TAG, - 'type' => 'T_OPEN_TAG', - 'content' => '', - ); + $finalTokens = []; + $finalTokens[0] = [ + 'code' => T_OPEN_TAG, + 'type' => 'T_OPEN_TAG', + 'content' => '', + ]; $newStackPtr = 1; $numTokens = count($tokens); @@ -125,11 +125,11 @@ public function tokenize($string) echo $cleanContent.PHP_EOL; } - $finalTokens[$newStackPtr] = array( - 'type' => 'T_EMBEDDED_PHP', - 'code' => T_EMBEDDED_PHP, - 'content' => $content, - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_EMBEDDED_PHP', + 'code' => T_EMBEDDED_PHP, + 'content' => $content, + ]; $newStackPtr++; continue; @@ -138,28 +138,28 @@ public function tokenize($string) if ($token['code'] === T_GOTO_LABEL) { // Convert these back to T_STRING followed by T_COLON so we can // more easily process style definitions. - $finalTokens[$newStackPtr] = array( - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => substr($token['content'], 0, -1), - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_STRING', + 'code' => T_STRING, + 'content' => substr($token['content'], 0, -1), + ]; $newStackPtr++; - $finalTokens[$newStackPtr] = array( - 'type' => 'T_COLON', - 'code' => T_COLON, - 'content' => ':', - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_COLON', + 'code' => T_COLON, + 'content' => ':', + ]; $newStackPtr++; continue; } if ($token['code'] === T_FUNCTION) { // There are no functions in CSS, so convert this to a string. - $finalTokens[$newStackPtr] = array( - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => $token['content'], - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_STRING', + 'code' => T_STRING, + 'content' => $token['content'], + ]; $newStackPtr++; continue; @@ -222,24 +222,24 @@ public function tokenize($string) array_shift($commentTokens); // Work out what we trimmed off above and remember to re-add it. $trimmed = substr($token['content'], 0, (strlen($token['content']) - strlen($content))); - $finalTokens[$newStackPtr] = array( - 'type' => 'T_COLOUR', - 'code' => T_COLOUR, - 'content' => $trimmed.$firstContent, - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_COLOUR', + 'code' => T_COLOUR, + 'content' => $trimmed.$firstContent, + ]; } else { - $finalTokens[$newStackPtr] = array( - 'type' => 'T_HASH', - 'code' => T_HASH, - 'content' => '#', - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_HASH', + 'code' => T_HASH, + 'content' => '#', + ]; } } else { - $finalTokens[$newStackPtr] = array( - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => '//', - ); + $finalTokens[$newStackPtr] = [ + 'type' => 'T_STRING', + 'code' => T_STRING, + 'content' => '//', + ]; }//end if $newStackPtr++; diff --git a/src/Tokenizers/Comment.php b/src/Tokenizers/Comment.php index aee87e34d3..26ae1dd095 100644 --- a/src/Tokenizers/Comment.php +++ b/src/Tokenizers/Comment.php @@ -33,7 +33,7 @@ public function tokenizeString($string, $eolChar, $stackPtr) echo "\t\t*** START COMMENT TOKENIZING ***".PHP_EOL; } - $tokens = array(); + $tokens = []; $numChars = strlen($string); /* @@ -45,12 +45,12 @@ public function tokenizeString($string, $eolChar, $stackPtr) $openTag = substr($string, 0, $char); $string = ltrim($string, '/*'); - $tokens[$stackPtr] = array( - 'content' => $openTag, - 'code' => T_DOC_COMMENT_OPEN_TAG, - 'type' => 'T_DOC_COMMENT_OPEN_TAG', - 'comment_tags' => array(), - ); + $tokens[$stackPtr] = [ + 'content' => $openTag, + 'code' => T_DOC_COMMENT_OPEN_TAG, + 'type' => 'T_DOC_COMMENT_OPEN_TAG', + 'comment_tags' => [], + ]; $openPtr = $stackPtr; $stackPtr++; @@ -66,12 +66,12 @@ public function tokenizeString($string, $eolChar, $stackPtr) stack just before we return it. */ - $closeTag = array( - 'content' => substr($string, strlen(rtrim($string, '/*'))), - 'code' => T_DOC_COMMENT_CLOSE_TAG, - 'type' => 'T_DOC_COMMENT_CLOSE_TAG', - 'comment_opener' => $openPtr, - ); + $closeTag = [ + 'content' => substr($string, strlen(rtrim($string, '/*'))), + 'code' => T_DOC_COMMENT_CLOSE_TAG, + 'type' => 'T_DOC_COMMENT_CLOSE_TAG', + 'comment_opener' => $openPtr, + ]; if ($closeTag['content'] === false) { $closeTag['content'] = ''; @@ -116,11 +116,11 @@ public function tokenizeString($string, $eolChar, $stackPtr) if ($string[$char] === '*') { // This is a function or class doc block line. $char++; - $tokens[$stackPtr] = array( - 'content' => '*', - 'code' => T_DOC_COMMENT_STAR, - 'type' => 'T_DOC_COMMENT_STAR', - ); + $tokens[$stackPtr] = [ + 'content' => '*', + 'code' => T_DOC_COMMENT_STAR, + 'type' => 'T_DOC_COMMENT_STAR', + ]; $stackPtr++; @@ -175,7 +175,7 @@ public function tokenizeString($string, $eolChar, $stackPtr) */ private function processLine($string, $eolChar, $start, $end) { - $tokens = array(); + $tokens = []; // Collect content padding. $space = $this->collectWhitespace($string, $start, $end); @@ -190,16 +190,16 @@ private function processLine($string, $eolChar, $start, $end) if ($string[$start] === '@') { // The content up until the first whitespace is the tag name. - $matches = array(); + $matches = []; preg_match('/@[^\s]+/', $string, $matches, 0, $start); if (isset($matches[0]) === true) { $tagName = $matches[0]; $start += strlen($tagName); - $tokens[] = array( - 'content' => $tagName, - 'code' => T_DOC_COMMENT_TAG, - 'type' => 'T_DOC_COMMENT_TAG', - ); + $tokens[] = [ + 'content' => $tagName, + 'code' => T_DOC_COMMENT_TAG, + 'type' => 'T_DOC_COMMENT_TAG', + ]; // Then there will be some whitespace. $space = $this->collectWhitespace($string, $start, $end); @@ -217,19 +217,19 @@ private function processLine($string, $eolChar, $start, $end) } if ($eol > $start) { - $tokens[] = array( - 'content' => substr($string, $start, ($eol - $start)), - 'code' => T_DOC_COMMENT_STRING, - 'type' => 'T_DOC_COMMENT_STRING', - ); + $tokens[] = [ + 'content' => substr($string, $start, ($eol - $start)), + 'code' => T_DOC_COMMENT_STRING, + 'type' => 'T_DOC_COMMENT_STRING', + ]; } if ($eol !== $end) { - $tokens[] = array( - 'content' => substr($string, $eol, strlen($eolChar)), - 'code' => T_DOC_COMMENT_WHITESPACE, - 'type' => 'T_DOC_COMMENT_WHITESPACE', - ); + $tokens[] = [ + 'content' => substr($string, $eol, strlen($eolChar)), + 'code' => T_DOC_COMMENT_WHITESPACE, + 'type' => 'T_DOC_COMMENT_WHITESPACE', + ]; } return $tokens; @@ -261,11 +261,11 @@ private function collectWhitespace($string, $start, $end) return null; } - $token = array( - 'content' => $space, - 'code' => T_DOC_COMMENT_WHITESPACE, - 'type' => 'T_DOC_COMMENT_WHITESPACE', - ); + $token = [ + 'content' => $space, + 'code' => T_DOC_COMMENT_WHITESPACE, + 'type' => 'T_DOC_COMMENT_WHITESPACE', + ]; return $token; diff --git a/src/Tokenizers/JS.php b/src/Tokenizers/JS.php index a8dfe04e3d..d11141dc0a 100644 --- a/src/Tokenizers/JS.php +++ b/src/Tokenizers/JS.php @@ -27,109 +27,109 @@ class JS extends Tokenizer * * @var array */ - public $scopeOpeners = array( - T_IF => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_TRY => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CATCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_ELSE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FOR => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_CLASS => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_FUNCTION => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_WHILE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_DO => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_SWITCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CASE => array( - 'start' => array(T_COLON => T_COLON), - 'end' => array( - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - ), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_DEFAULT => T_DEFAULT, - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ), - ), - T_DEFAULT => array( - 'start' => array(T_COLON => T_COLON), - 'end' => array( - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - ), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ), - ), - ); + public $scopeOpeners = [ + T_IF => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_TRY => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_CATCH => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_ELSE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_FOR => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_CLASS => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_FUNCTION => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_WHILE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_DO => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_SWITCH => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_CASE => [ + 'start' => [T_COLON => T_COLON], + 'end' => [ + T_BREAK => T_BREAK, + T_RETURN => T_RETURN, + T_CONTINUE => T_CONTINUE, + T_THROW => T_THROW, + ], + 'strict' => true, + 'shared' => true, + 'with' => [ + T_DEFAULT => T_DEFAULT, + T_CASE => T_CASE, + T_SWITCH => T_SWITCH, + ], + ], + T_DEFAULT => [ + 'start' => [T_COLON => T_COLON], + 'end' => [ + T_BREAK => T_BREAK, + T_RETURN => T_RETURN, + T_CONTINUE => T_CONTINUE, + T_THROW => T_THROW, + ], + 'strict' => true, + 'shared' => true, + 'with' => [ + T_CASE => T_CASE, + T_SWITCH => T_SWITCH, + ], + ], + ]; /** * A list of tokens that end the scope. @@ -140,111 +140,111 @@ class JS extends Tokenizer * * @var array */ - public $endScopeTokens = array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_BREAK => T_BREAK, - ); + public $endScopeTokens = [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_BREAK => T_BREAK, + ]; /** * A list of special JS tokens and their types. * * @var array */ - protected $tokenValues = array( - 'class' => 'T_CLASS', - 'function' => 'T_FUNCTION', - 'prototype' => 'T_PROTOTYPE', - 'try' => 'T_TRY', - 'catch' => 'T_CATCH', - 'return' => 'T_RETURN', - 'throw' => 'T_THROW', - 'break' => 'T_BREAK', - 'switch' => 'T_SWITCH', - 'continue' => 'T_CONTINUE', - 'if' => 'T_IF', - 'else' => 'T_ELSE', - 'do' => 'T_DO', - 'while' => 'T_WHILE', - 'for' => 'T_FOR', - 'var' => 'T_VAR', - 'case' => 'T_CASE', - 'default' => 'T_DEFAULT', - 'true' => 'T_TRUE', - 'false' => 'T_FALSE', - 'null' => 'T_NULL', - 'this' => 'T_THIS', - 'typeof' => 'T_TYPEOF', - '(' => 'T_OPEN_PARENTHESIS', - ')' => 'T_CLOSE_PARENTHESIS', - '{' => 'T_OPEN_CURLY_BRACKET', - '}' => 'T_CLOSE_CURLY_BRACKET', - '[' => 'T_OPEN_SQUARE_BRACKET', - ']' => 'T_CLOSE_SQUARE_BRACKET', - '?' => 'T_INLINE_THEN', - '.' => 'T_OBJECT_OPERATOR', - '+' => 'T_PLUS', - '-' => 'T_MINUS', - '*' => 'T_MULTIPLY', - '%' => 'T_MODULUS', - '/' => 'T_DIVIDE', - '^' => 'T_LOGICAL_XOR', - ',' => 'T_COMMA', - ';' => 'T_SEMICOLON', - ':' => 'T_COLON', - '<' => 'T_LESS_THAN', - '>' => 'T_GREATER_THAN', - '<<' => 'T_SL', - '>>' => 'T_SR', - '>>>' => 'T_ZSR', - '<<=' => 'T_SL_EQUAL', - '>>=' => 'T_SR_EQUAL', - '>>>=' => 'T_ZSR_EQUAL', - '<=' => 'T_IS_SMALLER_OR_EQUAL', - '>=' => 'T_IS_GREATER_OR_EQUAL', - '=>' => 'T_DOUBLE_ARROW', - '!' => 'T_BOOLEAN_NOT', - '||' => 'T_BOOLEAN_OR', - '&&' => 'T_BOOLEAN_AND', - '|' => 'T_BITWISE_OR', - '&' => 'T_BITWISE_AND', - '!=' => 'T_IS_NOT_EQUAL', - '!==' => 'T_IS_NOT_IDENTICAL', - '=' => 'T_EQUAL', - '==' => 'T_IS_EQUAL', - '===' => 'T_IS_IDENTICAL', - '-=' => 'T_MINUS_EQUAL', - '+=' => 'T_PLUS_EQUAL', - '*=' => 'T_MUL_EQUAL', - '/=' => 'T_DIV_EQUAL', - '%=' => 'T_MOD_EQUAL', - '++' => 'T_INC', - '--' => 'T_DEC', - '//' => 'T_COMMENT', - '/*' => 'T_COMMENT', - '/**' => 'T_DOC_COMMENT', - '*/' => 'T_COMMENT', - ); + protected $tokenValues = [ + 'class' => 'T_CLASS', + 'function' => 'T_FUNCTION', + 'prototype' => 'T_PROTOTYPE', + 'try' => 'T_TRY', + 'catch' => 'T_CATCH', + 'return' => 'T_RETURN', + 'throw' => 'T_THROW', + 'break' => 'T_BREAK', + 'switch' => 'T_SWITCH', + 'continue' => 'T_CONTINUE', + 'if' => 'T_IF', + 'else' => 'T_ELSE', + 'do' => 'T_DO', + 'while' => 'T_WHILE', + 'for' => 'T_FOR', + 'var' => 'T_VAR', + 'case' => 'T_CASE', + 'default' => 'T_DEFAULT', + 'true' => 'T_TRUE', + 'false' => 'T_FALSE', + 'null' => 'T_NULL', + 'this' => 'T_THIS', + 'typeof' => 'T_TYPEOF', + '(' => 'T_OPEN_PARENTHESIS', + ')' => 'T_CLOSE_PARENTHESIS', + '{' => 'T_OPEN_CURLY_BRACKET', + '}' => 'T_CLOSE_CURLY_BRACKET', + '[' => 'T_OPEN_SQUARE_BRACKET', + ']' => 'T_CLOSE_SQUARE_BRACKET', + '?' => 'T_INLINE_THEN', + '.' => 'T_OBJECT_OPERATOR', + '+' => 'T_PLUS', + '-' => 'T_MINUS', + '*' => 'T_MULTIPLY', + '%' => 'T_MODULUS', + '/' => 'T_DIVIDE', + '^' => 'T_LOGICAL_XOR', + ',' => 'T_COMMA', + ';' => 'T_SEMICOLON', + ':' => 'T_COLON', + '<' => 'T_LESS_THAN', + '>' => 'T_GREATER_THAN', + '<<' => 'T_SL', + '>>' => 'T_SR', + '>>>' => 'T_ZSR', + '<<=' => 'T_SL_EQUAL', + '>>=' => 'T_SR_EQUAL', + '>>>=' => 'T_ZSR_EQUAL', + '<=' => 'T_IS_SMALLER_OR_EQUAL', + '>=' => 'T_IS_GREATER_OR_EQUAL', + '=>' => 'T_DOUBLE_ARROW', + '!' => 'T_BOOLEAN_NOT', + '||' => 'T_BOOLEAN_OR', + '&&' => 'T_BOOLEAN_AND', + '|' => 'T_BITWISE_OR', + '&' => 'T_BITWISE_AND', + '!=' => 'T_IS_NOT_EQUAL', + '!==' => 'T_IS_NOT_IDENTICAL', + '=' => 'T_EQUAL', + '==' => 'T_IS_EQUAL', + '===' => 'T_IS_IDENTICAL', + '-=' => 'T_MINUS_EQUAL', + '+=' => 'T_PLUS_EQUAL', + '*=' => 'T_MUL_EQUAL', + '/=' => 'T_DIV_EQUAL', + '%=' => 'T_MOD_EQUAL', + '++' => 'T_INC', + '--' => 'T_DEC', + '//' => 'T_COMMENT', + '/*' => 'T_COMMENT', + '/**' => 'T_DOC_COMMENT', + '*/' => 'T_COMMENT', + ]; /** * A list string delimiters. * * @var array */ - protected $stringTokens = array( - '\'' => '\'', - '"' => '"', - ); + protected $stringTokens = [ + '\'' => '\'', + '"' => '"', + ]; /** * A list tokens that start and end comments. * * @var array */ - protected $commentTokens = array( - '//' => null, - '/*' => '*/', - '/**' => '*/', - ); + protected $commentTokens = [ + '//' => null, + '/*' => '*/', + '/**' => '*/', + ]; /** @@ -290,7 +290,7 @@ public function tokenize($string) } } - $tokens = array(); + $tokens = []; $inString = ''; $stringChar = null; $inComment = ''; @@ -300,11 +300,11 @@ public function tokenize($string) $commentTokenizer = new Comment(); - $tokens[] = array( - 'code' => T_OPEN_TAG, - 'type' => 'T_OPEN_TAG', - 'content' => '', - ); + $tokens[] = [ + 'code' => T_OPEN_TAG, + 'type' => 'T_OPEN_TAG', + 'content' => '', + ]; // Convert newlines to single characters for ease of // processing. We will change them back later. @@ -334,11 +334,11 @@ public function tokenize($string) // If the buffer only has whitespace and we are about to // add a character, store the whitespace first. if (trim($char) !== '' && trim($buffer) === '') { - $tokens[] = array( - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ); + $tokens[] = [ + 'code' => T_WHITESPACE, + 'type' => 'T_WHITESPACE', + 'content' => str_replace("\n", $this->eolChar, $buffer), + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -355,11 +355,11 @@ public function tokenize($string) && trim($char) === '' && trim($buffer) !== '' ) { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ); + $tokens[] = [ + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => str_replace("\n", $this->eolChar, $buffer), + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -387,11 +387,11 @@ public function tokenize($string) if ($escapes === 0 || ($escapes % 2) === 0) { // There is an even number escape chars, // so this is not escaped, it is the end of the string. - $tokens[] = array( - 'code' => T_CONSTANT_ENCAPSED_STRING, - 'type' => 'T_CONSTANT_ENCAPSED_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer).$char, - ); + $tokens[] = [ + 'code' => T_CONSTANT_ENCAPSED_STRING, + 'type' => 'T_CONSTANT_ENCAPSED_STRING', + 'content' => str_replace("\n", $this->eolChar, $buffer).$char, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* found end of string *".PHP_EOL; @@ -455,11 +455,11 @@ public function tokenize($string) ); if ($regex !== null) { - $tokens[] = array( - 'code' => T_REGULAR_EXPRESSION, - 'type' => 'T_REGULAR_EXPRESSION', - 'content' => $regex['content'], - ); + $tokens[] = [ + 'code' => T_REGULAR_EXPRESSION, + 'type' => 'T_REGULAR_EXPRESSION', + 'content' => $regex['content'], + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($regex['content']); @@ -544,11 +544,11 @@ public function tokenize($string) $value = 'T_STRING'; } - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $buffer, - ); + $tokens[] = [ + 'code' => constant($value), + 'type' => $value, + 'content' => $buffer, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -563,11 +563,11 @@ public function tokenize($string) // found a valid token. $newContent = substr(str_replace("\n", $this->eolChar, $buffer), 0, -1); if ($newContent !== '') { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => $newContent, - ); + $tokens[] = [ + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => $newContent, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput(substr($buffer, 0, -1)); @@ -611,11 +611,11 @@ public function tokenize($string) if ($matchedToken === false) { $value = $this->tokenValues[strtolower($char)]; - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $char, - ); + $tokens[] = [ + 'code' => constant($value), + 'type' => $value, + 'content' => $char, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* look ahead found nothing *".PHP_EOL; @@ -649,11 +649,11 @@ public function tokenize($string) for ($x = 0; $x < $lastNumChars; $x++) { $lastChar = $lastChars[$x]; $value = $this->tokenValues[strtolower($lastChar)]; - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $lastChar, - ); + $tokens[] = [ + 'code' => constant($value), + 'type' => $value, + 'content' => $lastChar, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($lastChar); @@ -687,11 +687,11 @@ public function tokenize($string) } if ($inComment === '' && $cleanBuffer === false) { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ); + $tokens[] = [ + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => str_replace("\n", $this->eolChar, $buffer), + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -712,11 +712,11 @@ public function tokenize($string) if ($inString !== '') { // The string did not end before the end of the file, // which means there was probably a syntax error somewhere. - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ); + $tokens[] = [ + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => str_replace("\n", $this->eolChar, $buffer), + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -724,11 +724,11 @@ public function tokenize($string) } } else { // Buffer contains whitespace from the end of the file. - $tokens[] = array( - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ); + $tokens[] = [ + 'code' => T_WHITESPACE, + 'type' => 'T_WHITESPACE', + 'content' => str_replace("\n", $this->eolChar, $buffer), + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $content = Util\Common::prepareForOutput($buffer); @@ -737,11 +737,11 @@ public function tokenize($string) }//end if }//end if - $tokens[] = array( - 'code' => T_CLOSE_TAG, - 'type' => 'T_CLOSE_TAG', - 'content' => '', - ); + $tokens[] = [ + 'code' => T_CLOSE_TAG, + 'type' => 'T_CLOSE_TAG', + 'content' => '', + ]; /* Now that we have done some basic tokenizing, we need to @@ -749,7 +749,7 @@ public function tokenize($string) so they match what the PHP tokenizer does. */ - $finalTokens = array(); + $finalTokens = []; $newStackPtr = 0; $numTokens = count($tokens); for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { @@ -922,35 +922,35 @@ public function tokenize($string) */ public function getRegexToken($char, $string, $chars, $tokens) { - $beforeTokens = array( - T_EQUAL => true, - T_IS_NOT_EQUAL => true, - T_IS_IDENTICAL => true, - T_IS_NOT_IDENTICAL => true, - T_OPEN_PARENTHESIS => true, - T_OPEN_SQUARE_BRACKET => true, - T_RETURN => true, - T_BOOLEAN_OR => true, - T_BOOLEAN_AND => true, - T_BITWISE_OR => true, - T_BITWISE_AND => true, - T_COMMA => true, - T_COLON => true, - T_TYPEOF => true, - T_INLINE_THEN => true, - T_INLINE_ELSE => true, - ); - - $afterTokens = array( - ',' => true, - ')' => true, - ']' => true, - ';' => true, - ' ' => true, - '.' => true, - ':' => true, - $this->eolChar => true, - ); + $beforeTokens = [ + T_EQUAL => true, + T_IS_NOT_EQUAL => true, + T_IS_IDENTICAL => true, + T_IS_NOT_IDENTICAL => true, + T_OPEN_PARENTHESIS => true, + T_OPEN_SQUARE_BRACKET => true, + T_RETURN => true, + T_BOOLEAN_OR => true, + T_BOOLEAN_AND => true, + T_BITWISE_OR => true, + T_BITWISE_AND => true, + T_COMMA => true, + T_COLON => true, + T_TYPEOF => true, + T_INLINE_THEN => true, + T_INLINE_ELSE => true, + ]; + + $afterTokens = [ + ',' => true, + ')' => true, + ']' => true, + ';' => true, + ' ' => true, + '.' => true, + ':' => true, + $this->eolChar => true, + ]; // Find the last non-whitespace token that was added // to the tokens array. @@ -1038,11 +1038,11 @@ public function getRegexToken($char, $string, $chars, $tokens) $content .= $chars[$x]; } - $token = array( - 'start' => $char, - 'end' => $regexEnd, - 'content' => $content, - ); + $token = [ + 'start' => $char, + 'end' => $regexEnd, + 'content' => $content, + ]; return $token; @@ -1063,7 +1063,7 @@ public function processAdditional() } $numTokens = count($this->tokens); - $classStack = array(); + $classStack = []; for ($i = 0; $i < $numTokens; $i++) { if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -1143,7 +1143,7 @@ public function processAdditional() $this->tokens[$name]['code'] = T_FUNCTION; $this->tokens[$name]['type'] = 'T_FUNCTION'; - foreach (array($name, $i, $closer) as $token) { + foreach ([$name, $i, $closer] as $token) { $this->tokens[$token]['scope_condition'] = $name; $this->tokens[$token]['scope_opener'] = $i; $this->tokens[$token]['scope_closer'] = $closer; diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index e348476410..ec12e05bb0 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -25,242 +25,242 @@ class PHP extends Tokenizer * * @var array */ - public $scopeOpeners = array( - T_IF => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDIF => T_ENDIF, - T_ELSE => T_ELSE, - T_ELSEIF => T_ELSEIF, - ), - 'strict' => false, - 'shared' => false, - 'with' => array( - T_ELSE => T_ELSE, - T_ELSEIF => T_ELSEIF, - ), - ), - T_TRY => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CATCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_FINALLY => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_ELSE => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDIF => T_ENDIF, - ), - 'strict' => false, - 'shared' => false, - 'with' => array( - T_IF => T_IF, - T_ELSEIF => T_ELSEIF, - ), - ), - T_ELSEIF => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDIF => T_ENDIF, - T_ELSE => T_ELSE, - T_ELSEIF => T_ELSEIF, - ), - 'strict' => false, - 'shared' => false, - 'with' => array( - T_IF => T_IF, - T_ELSE => T_ELSE, - ), - ), - T_FOR => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDFOR => T_ENDFOR, - ), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FOREACH => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDFOREACH => T_ENDFOREACH, - ), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_INTERFACE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_FUNCTION => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CLASS => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_TRAIT => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_USE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_DECLARE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_NAMESPACE => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_WHILE => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDWHILE => T_ENDWHILE, - ), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_DO => array( - 'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_SWITCH => array( - 'start' => array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_COLON => T_COLON, - ), - 'end' => array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDSWITCH => T_ENDSWITCH, - ), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CASE => array( - 'start' => array( - T_COLON => T_COLON, - T_SEMICOLON => T_SEMICOLON, - ), - 'end' => array( - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - T_EXIT => T_EXIT, - ), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_DEFAULT => T_DEFAULT, - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ), - ), - T_DEFAULT => array( - 'start' => array( - T_COLON => T_COLON, - T_SEMICOLON => T_SEMICOLON, - ), - 'end' => array( - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - T_EXIT => T_EXIT, - ), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ), - ), - T_START_HEREDOC => array( - 'start' => array(T_START_HEREDOC => T_START_HEREDOC), - 'end' => array(T_END_HEREDOC => T_END_HEREDOC), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_START_NOWDOC => array( - 'start' => array(T_START_NOWDOC => T_START_NOWDOC), - 'end' => array(T_END_NOWDOC => T_END_NOWDOC), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - ); + public $scopeOpeners = [ + T_IF => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDIF => T_ENDIF, + T_ELSE => T_ELSE, + T_ELSEIF => T_ELSEIF, + ], + 'strict' => false, + 'shared' => false, + 'with' => [ + T_ELSE => T_ELSE, + T_ELSEIF => T_ELSEIF, + ], + ], + T_TRY => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_CATCH => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_FINALLY => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_ELSE => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDIF => T_ENDIF, + ], + 'strict' => false, + 'shared' => false, + 'with' => [ + T_IF => T_IF, + T_ELSEIF => T_ELSEIF, + ], + ], + T_ELSEIF => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDIF => T_ENDIF, + T_ELSE => T_ELSE, + T_ELSEIF => T_ELSEIF, + ], + 'strict' => false, + 'shared' => false, + 'with' => [ + T_IF => T_IF, + T_ELSE => T_ELSE, + ], + ], + T_FOR => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDFOR => T_ENDFOR, + ], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_FOREACH => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDFOREACH => T_ENDFOREACH, + ], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_INTERFACE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_FUNCTION => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_CLASS => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_TRAIT => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_USE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_DECLARE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_NAMESPACE => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_WHILE => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDWHILE => T_ENDWHILE, + ], + 'strict' => false, + 'shared' => false, + 'with' => [], + ], + T_DO => [ + 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], + 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_SWITCH => [ + 'start' => [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_COLON => T_COLON, + ], + 'end' => [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDSWITCH => T_ENDSWITCH, + ], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_CASE => [ + 'start' => [ + T_COLON => T_COLON, + T_SEMICOLON => T_SEMICOLON, + ], + 'end' => [ + T_BREAK => T_BREAK, + T_RETURN => T_RETURN, + T_CONTINUE => T_CONTINUE, + T_THROW => T_THROW, + T_EXIT => T_EXIT, + ], + 'strict' => true, + 'shared' => true, + 'with' => [ + T_DEFAULT => T_DEFAULT, + T_CASE => T_CASE, + T_SWITCH => T_SWITCH, + ], + ], + T_DEFAULT => [ + 'start' => [ + T_COLON => T_COLON, + T_SEMICOLON => T_SEMICOLON, + ], + 'end' => [ + T_BREAK => T_BREAK, + T_RETURN => T_RETURN, + T_CONTINUE => T_CONTINUE, + T_THROW => T_THROW, + T_EXIT => T_EXIT, + ], + 'strict' => true, + 'shared' => true, + 'with' => [ + T_CASE => T_CASE, + T_SWITCH => T_SWITCH, + ], + ], + T_START_HEREDOC => [ + 'start' => [T_START_HEREDOC => T_START_HEREDOC], + 'end' => [T_END_HEREDOC => T_END_HEREDOC], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + T_START_NOWDOC => [ + 'start' => [T_START_NOWDOC => T_START_NOWDOC], + 'end' => [T_END_NOWDOC => T_END_NOWDOC], + 'strict' => true, + 'shared' => false, + 'with' => [], + ], + ]; /** * A list of tokens that end the scope. @@ -271,168 +271,168 @@ class PHP extends Tokenizer * * @var array */ - public $endScopeTokens = array( - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_ENDIF => T_ENDIF, - T_ENDFOR => T_ENDFOR, - T_ENDFOREACH => T_ENDFOREACH, - T_ENDWHILE => T_ENDWHILE, - T_ENDSWITCH => T_ENDSWITCH, - T_BREAK => T_BREAK, - T_END_HEREDOC => T_END_HEREDOC, - ); + public $endScopeTokens = [ + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_ENDIF => T_ENDIF, + T_ENDFOR => T_ENDFOR, + T_ENDFOREACH => T_ENDFOREACH, + T_ENDWHILE => T_ENDWHILE, + T_ENDSWITCH => T_ENDSWITCH, + T_BREAK => T_BREAK, + T_END_HEREDOC => T_END_HEREDOC, + ]; /** * Known lengths of tokens. * * @var array */ - public $knownLengths = array( - T_ABSTRACT => 8, - T_AND_EQUAL => 2, - T_ARRAY => 5, - T_AS => 2, - T_BOOLEAN_AND => 2, - T_BOOLEAN_OR => 2, - T_BREAK => 5, - T_CALLABLE => 8, - T_CASE => 4, - T_CATCH => 5, - T_CLASS => 5, - T_CLASS_C => 9, - T_CLONE => 5, - T_CONCAT_EQUAL => 2, - T_CONST => 5, - T_CONTINUE => 8, - T_CURLY_OPEN => 2, - T_DEC => 2, - T_DECLARE => 7, - T_DEFAULT => 7, - T_DIR => 7, - T_DIV_EQUAL => 2, - T_DO => 2, - T_DOLLAR_OPEN_CURLY_BRACES => 2, - T_DOUBLE_ARROW => 2, - T_DOUBLE_COLON => 2, - T_ECHO => 4, - T_ELSE => 4, - T_ELSEIF => 6, - T_EMPTY => 5, - T_ENDDECLARE => 10, - T_ENDFOR => 6, - T_ENDFOREACH => 10, - T_ENDIF => 5, - T_ENDSWITCH => 9, - T_ENDWHILE => 8, - T_EVAL => 4, - T_EXTENDS => 7, - T_FILE => 8, - T_FINAL => 5, - T_FINALLY => 7, - T_FOR => 3, - T_FOREACH => 7, - T_FUNCTION => 8, - T_FUNC_C => 12, - T_GLOBAL => 6, - T_GOTO => 4, - T_HALT_COMPILER => 15, - T_IF => 2, - T_IMPLEMENTS => 10, - T_INC => 2, - T_INCLUDE => 7, - T_INCLUDE_ONCE => 12, - T_INSTANCEOF => 10, - T_INSTEADOF => 9, - T_INTERFACE => 9, - T_ISSET => 5, - T_IS_EQUAL => 2, - T_IS_GREATER_OR_EQUAL => 2, - T_IS_IDENTICAL => 3, - T_IS_NOT_EQUAL => 2, - T_IS_NOT_IDENTICAL => 3, - T_IS_SMALLER_OR_EQUAL => 2, - T_LINE => 8, - T_LIST => 4, - T_LOGICAL_AND => 3, - T_LOGICAL_OR => 2, - T_LOGICAL_XOR => 3, - T_METHOD_C => 10, - T_MINUS_EQUAL => 2, - T_POW_EQUAL => 3, - T_MOD_EQUAL => 2, - T_MUL_EQUAL => 2, - T_NAMESPACE => 9, - T_NS_C => 13, - T_NS_SEPARATOR => 1, - T_NEW => 3, - T_OBJECT_OPERATOR => 2, - T_OPEN_TAG_WITH_ECHO => 3, - T_OR_EQUAL => 2, - T_PLUS_EQUAL => 2, - T_PRINT => 5, - T_PRIVATE => 7, - T_PUBLIC => 6, - T_PROTECTED => 9, - T_REQUIRE => 7, - T_REQUIRE_ONCE => 12, - T_RETURN => 6, - T_STATIC => 6, - T_SWITCH => 6, - T_THROW => 5, - T_TRAIT => 5, - T_TRAIT_C => 9, - T_TRY => 3, - T_UNSET => 5, - T_USE => 3, - T_VAR => 3, - T_WHILE => 5, - T_XOR_EQUAL => 2, - T_YIELD => 5, - T_OPEN_CURLY_BRACKET => 1, - T_CLOSE_CURLY_BRACKET => 1, - T_OPEN_SQUARE_BRACKET => 1, - T_CLOSE_SQUARE_BRACKET => 1, - T_OPEN_PARENTHESIS => 1, - T_CLOSE_PARENTHESIS => 1, - T_COLON => 1, - T_STRING_CONCAT => 1, - T_INLINE_THEN => 1, - T_INLINE_ELSE => 1, - T_NULLABLE => 1, - T_NULL => 4, - T_FALSE => 5, - T_TRUE => 4, - T_SEMICOLON => 1, - T_EQUAL => 1, - T_MULTIPLY => 1, - T_DIVIDE => 1, - T_PLUS => 1, - T_MINUS => 1, - T_MODULUS => 1, - T_POW => 2, - T_SPACESHIP => 3, - T_COALESCE => 2, - T_COALESCE_EQUAL => 3, - T_BITWISE_AND => 1, - T_BITWISE_OR => 1, - T_BITWISE_XOR => 1, - T_SL => 2, - T_SR => 2, - T_SL_EQUAL => 3, - T_SR_EQUAL => 3, - T_ARRAY_HINT => 5, - T_GREATER_THAN => 1, - T_LESS_THAN => 1, - T_BOOLEAN_NOT => 1, - T_SELF => 4, - T_PARENT => 6, - T_COMMA => 1, - T_THIS => 4, - T_CLOSURE => 8, - T_BACKTICK => 1, - T_OPEN_SHORT_ARRAY => 1, - T_CLOSE_SHORT_ARRAY => 1, - ); + public $knownLengths = [ + T_ABSTRACT => 8, + T_AND_EQUAL => 2, + T_ARRAY => 5, + T_AS => 2, + T_BOOLEAN_AND => 2, + T_BOOLEAN_OR => 2, + T_BREAK => 5, + T_CALLABLE => 8, + T_CASE => 4, + T_CATCH => 5, + T_CLASS => 5, + T_CLASS_C => 9, + T_CLONE => 5, + T_CONCAT_EQUAL => 2, + T_CONST => 5, + T_CONTINUE => 8, + T_CURLY_OPEN => 2, + T_DEC => 2, + T_DECLARE => 7, + T_DEFAULT => 7, + T_DIR => 7, + T_DIV_EQUAL => 2, + T_DO => 2, + T_DOLLAR_OPEN_CURLY_BRACES => 2, + T_DOUBLE_ARROW => 2, + T_DOUBLE_COLON => 2, + T_ECHO => 4, + T_ELSE => 4, + T_ELSEIF => 6, + T_EMPTY => 5, + T_ENDDECLARE => 10, + T_ENDFOR => 6, + T_ENDFOREACH => 10, + T_ENDIF => 5, + T_ENDSWITCH => 9, + T_ENDWHILE => 8, + T_EVAL => 4, + T_EXTENDS => 7, + T_FILE => 8, + T_FINAL => 5, + T_FINALLY => 7, + T_FOR => 3, + T_FOREACH => 7, + T_FUNCTION => 8, + T_FUNC_C => 12, + T_GLOBAL => 6, + T_GOTO => 4, + T_HALT_COMPILER => 15, + T_IF => 2, + T_IMPLEMENTS => 10, + T_INC => 2, + T_INCLUDE => 7, + T_INCLUDE_ONCE => 12, + T_INSTANCEOF => 10, + T_INSTEADOF => 9, + T_INTERFACE => 9, + T_ISSET => 5, + T_IS_EQUAL => 2, + T_IS_GREATER_OR_EQUAL => 2, + T_IS_IDENTICAL => 3, + T_IS_NOT_EQUAL => 2, + T_IS_NOT_IDENTICAL => 3, + T_IS_SMALLER_OR_EQUAL => 2, + T_LINE => 8, + T_LIST => 4, + T_LOGICAL_AND => 3, + T_LOGICAL_OR => 2, + T_LOGICAL_XOR => 3, + T_METHOD_C => 10, + T_MINUS_EQUAL => 2, + T_POW_EQUAL => 3, + T_MOD_EQUAL => 2, + T_MUL_EQUAL => 2, + T_NAMESPACE => 9, + T_NS_C => 13, + T_NS_SEPARATOR => 1, + T_NEW => 3, + T_OBJECT_OPERATOR => 2, + T_OPEN_TAG_WITH_ECHO => 3, + T_OR_EQUAL => 2, + T_PLUS_EQUAL => 2, + T_PRINT => 5, + T_PRIVATE => 7, + T_PUBLIC => 6, + T_PROTECTED => 9, + T_REQUIRE => 7, + T_REQUIRE_ONCE => 12, + T_RETURN => 6, + T_STATIC => 6, + T_SWITCH => 6, + T_THROW => 5, + T_TRAIT => 5, + T_TRAIT_C => 9, + T_TRY => 3, + T_UNSET => 5, + T_USE => 3, + T_VAR => 3, + T_WHILE => 5, + T_XOR_EQUAL => 2, + T_YIELD => 5, + T_OPEN_CURLY_BRACKET => 1, + T_CLOSE_CURLY_BRACKET => 1, + T_OPEN_SQUARE_BRACKET => 1, + T_CLOSE_SQUARE_BRACKET => 1, + T_OPEN_PARENTHESIS => 1, + T_CLOSE_PARENTHESIS => 1, + T_COLON => 1, + T_STRING_CONCAT => 1, + T_INLINE_THEN => 1, + T_INLINE_ELSE => 1, + T_NULLABLE => 1, + T_NULL => 4, + T_FALSE => 5, + T_TRUE => 4, + T_SEMICOLON => 1, + T_EQUAL => 1, + T_MULTIPLY => 1, + T_DIVIDE => 1, + T_PLUS => 1, + T_MINUS => 1, + T_MODULUS => 1, + T_POW => 2, + T_SPACESHIP => 3, + T_COALESCE => 2, + T_COALESCE_EQUAL => 3, + T_BITWISE_AND => 1, + T_BITWISE_OR => 1, + T_BITWISE_XOR => 1, + T_SL => 2, + T_SR => 2, + T_SL_EQUAL => 3, + T_SR_EQUAL => 3, + T_ARRAY_HINT => 5, + T_GREATER_THAN => 1, + T_LESS_THAN => 1, + T_BOOLEAN_NOT => 1, + T_SELF => 4, + T_PARENT => 6, + T_COMMA => 1, + T_THIS => 4, + T_CLOSURE => 8, + T_BACKTICK => 1, + T_OPEN_SHORT_ARRAY => 1, + T_CLOSE_SHORT_ARRAY => 1, + ]; /** @@ -441,7 +441,7 @@ class PHP extends Tokenizer * @var array * @see standardiseToken() */ - private static $resolveTokenCache = array(); + private static $resolveTokenCache = []; /** @@ -465,13 +465,13 @@ protected function tokenize($string) } $tokens = @token_get_all($string); - $finalTokens = array(); + $finalTokens = []; $newStackPtr = 0; $numTokens = count($tokens); $lastNotEmptyToken = 0; - $insideInlineIf = array(); + $insideInlineIf = []; $insideUseGroup = false; $commentTokenizer = new Comment(); @@ -566,16 +566,16 @@ protected function tokenize($string) if ($tokenIsArray === false && ($token[0] === '"' || $token[0] === 'b"')) { // Binary casts need a special token. if ($token[0] === 'b"') { - $finalTokens[$newStackPtr] = array( - 'code' => T_BINARY_CAST, - 'type' => 'T_BINARY_CAST', - 'content' => 'b', - ); + $finalTokens[$newStackPtr] = [ + 'code' => T_BINARY_CAST, + 'type' => 'T_BINARY_CAST', + 'content' => 'b', + ]; $newStackPtr++; } $tokenContent = '"'; - $nestedVars = array(); + $nestedVars = []; for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { $subToken = (array) $tokens[$i]; $subTokenIsArray = isset($subToken[1]); @@ -609,7 +609,7 @@ protected function tokenize($string) // new token, so it conforms with other multiple line tokens. $tokenLines = explode($this->eolChar, $tokenContent); $numLines = count($tokenLines); - $newToken = array(); + $newToken = []; for ($j = 0; $j < $numLines; $j++) { $newToken['content'] = $tokenLines[$j]; @@ -692,7 +692,7 @@ protected function tokenize($string) // new token, so it conforms with other multiple line tokens. $tokenLines = explode($this->eolChar, $tokenContent); $numLines = count($tokenLines); - $newToken = array(); + $newToken = []; for ($j = 0; $j < $numLines; $j++) { $newToken['content'] = $tokenLines[$j]; @@ -747,7 +747,7 @@ protected function tokenize($string) && $tokens[($stackPtr + 2)][0] === T_STRING && strtolower($tokens[($stackPtr + 2)][1]) === 'from' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_YIELD_FROM; $newToken['type'] = 'T_YIELD_FROM'; $newToken['content'] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1]; @@ -776,7 +776,7 @@ protected function tokenize($string) && $tokens[($stackPtr + 2)][0] === T_STRING && strtolower($tokens[($stackPtr + 2)][1]) === 'from' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_YIELD_FROM; $newToken['type'] = 'T_YIELD_FROM'; $newToken['content'] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1]; @@ -787,7 +787,7 @@ protected function tokenize($string) continue; } - $newToken = array(); + $newToken = []; $newToken['code'] = T_YIELD; $newToken['type'] = 'T_YIELD'; $newToken['content'] = $token[1]; @@ -810,7 +810,7 @@ protected function tokenize($string) && $tokens[($stackPtr + 1)] === '.' && $tokens[($stackPtr + 2)] === '.' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_ELLIPSIS; $newToken['type'] = 'T_ELLIPSIS'; $newToken['content'] = '...'; @@ -832,7 +832,7 @@ protected function tokenize($string) && isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)] === '*' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_POW; $newToken['type'] = 'T_POW'; $newToken['content'] = '**'; @@ -855,7 +855,7 @@ protected function tokenize($string) && is_array($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)][1] === '*=' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_POW_EQUAL; $newToken['type'] = 'T_POW_EQUAL'; $newToken['content'] = '**='; @@ -885,7 +885,7 @@ protected function tokenize($string) && isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)][0] === '=') ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_COALESCE_EQUAL; $newToken['type'] = 'T_COALESCE_EQUAL'; $newToken['content'] = '??='; @@ -913,7 +913,7 @@ protected function tokenize($string) && isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)][0] === '?' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_COALESCE; $newToken['type'] = 'T_COALESCE'; $newToken['content'] = '??'; @@ -929,7 +929,7 @@ protected function tokenize($string) */ if ($tokenIsArray === false && $token[0] === '?') { - $newToken = array(); + $newToken = []; $newToken['content'] = '?'; $prevNonEmpty = null; @@ -957,7 +957,7 @@ protected function tokenize($string) $newToken['code'] = T_NULLABLE; $newToken['type'] = 'T_NULLABLE'; break; - } else if (in_array($tokenType, array(T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';')) === true) { + } else if (in_array($tokenType, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';']) === true) { $newToken['code'] = T_INLINE_THEN; $newToken['type'] = 'T_INLINE_THEN'; @@ -986,7 +986,7 @@ protected function tokenize($string) && $token[0] !== T_DOLLAR && isset(Util\Tokens::$emptyTokens[$token[0]]) === false ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_STRING; $newToken['type'] = 'T_STRING'; $newToken['content'] = $token[1]; @@ -1031,7 +1031,7 @@ protected function tokenize($string) && isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)][0] === '>' ) { - $newToken = array(); + $newToken = []; $newToken['code'] = T_SPACESHIP; $newToken['type'] = 'T_SPACESHIP'; $newToken['content'] = '<=>'; @@ -1056,12 +1056,12 @@ protected function tokenize($string) && $tokens[($stackPtr + 1)] === ':' && $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM ) { - $stopTokens = array( - T_CASE => true, - T_SEMICOLON => true, - T_OPEN_CURLY_BRACKET => true, - T_INLINE_THEN => true, - ); + $stopTokens = [ + T_CASE => true, + T_SEMICOLON => true, + T_OPEN_CURLY_BRACKET => true, + T_INLINE_THEN => true, + ]; for ($x = ($newStackPtr - 1); $x > 0; $x--) { if (isset($stopTokens[$finalTokens[$x]['code']]) === true) { @@ -1072,11 +1072,11 @@ protected function tokenize($string) if ($finalTokens[$x]['code'] !== T_CASE && $finalTokens[$x]['code'] !== T_INLINE_THEN ) { - $finalTokens[$newStackPtr] = array( - 'content' => $token[1].':', - 'code' => T_GOTO_LABEL, - 'type' => 'T_GOTO_LABEL', - ); + $finalTokens[$newStackPtr] = [ + 'content' => $token[1].':', + 'code' => T_GOTO_LABEL, + 'type' => 'T_GOTO_LABEL', + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL".PHP_EOL; @@ -1099,25 +1099,25 @@ protected function tokenize($string) && $token[0] === T_ELSEIF && strtolower($token[1]) !== 'elseif' ) { - $finalTokens[$newStackPtr] = array( - 'content' => substr($token[1], 0, 4), - 'code' => T_ELSE, - 'type' => 'T_ELSE', - ); + $finalTokens[$newStackPtr] = [ + 'content' => substr($token[1], 0, 4), + 'code' => T_ELSE, + 'type' => 'T_ELSE', + ]; $newStackPtr++; - $finalTokens[$newStackPtr] = array( - 'content' => substr($token[1], 4, -2), - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - ); + $finalTokens[$newStackPtr] = [ + 'content' => substr($token[1], 4, -2), + 'code' => T_WHITESPACE, + 'type' => 'T_WHITESPACE', + ]; $newStackPtr++; - $finalTokens[$newStackPtr] = array( - 'content' => substr($token[1], -2), - 'code' => T_IF, - 'type' => 'T_IF', - ); + $finalTokens[$newStackPtr] = [ + 'content' => substr($token[1], -2), + 'code' => T_IF, + 'type' => 'T_IF', + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* token $stackPtr changed from T_ELSEIF to T_ELSE/T_WHITESPACE/T_IF".PHP_EOL; @@ -1133,11 +1133,11 @@ protected function tokenize($string) */ if ($tokenIsArray === true && token_name($token[0]) === 'T_HASHBANG') { - $finalTokens[$newStackPtr] = array( - 'content' => $token[1], - 'code' => T_INLINE_HTML, - 'type' => 'T_INLINE_HTML', - ); + $finalTokens[$newStackPtr] = [ + 'content' => $token[1], + 'code' => T_INLINE_HTML, + 'type' => 'T_INLINE_HTML', + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* token $stackPtr changed from T_HASHBANG to T_INLINE_HTML".PHP_EOL; @@ -1157,11 +1157,11 @@ protected function tokenize($string) if ($tokenIsArray === true && strpos($token[1], $this->eolChar) !== false) { $tokenLines = explode($this->eolChar, $token[1]); $numLines = count($tokenLines); - $newToken = array( - 'type' => token_name($token[0]), - 'code' => $token[0], - 'content' => '', - ); + $newToken = [ + 'type' => token_name($token[0]), + 'code' => $token[0], + 'content' => '', + ]; for ($i = 0; $i < $numLines; $i++) { $newToken['content'] = $tokenLines[$i]; @@ -1180,36 +1180,36 @@ protected function tokenize($string) if ($tokenIsArray === true && $token[0] === T_STRING) { // Some T_STRING tokens should remain that way // due to their context. - $context = array( - T_OBJECT_OPERATOR => true, - T_FUNCTION => true, - T_CLASS => true, - T_EXTENDS => true, - T_IMPLEMENTS => true, - T_NEW => true, - T_CONST => true, - T_NS_SEPARATOR => true, - T_USE => true, - T_NAMESPACE => true, - T_PAAMAYIM_NEKUDOTAYIM => true, - ); + $context = [ + T_OBJECT_OPERATOR => true, + T_FUNCTION => true, + T_CLASS => true, + T_EXTENDS => true, + T_IMPLEMENTS => true, + T_NEW => true, + T_CONST => true, + T_NS_SEPARATOR => true, + T_USE => true, + T_NAMESPACE => true, + T_PAAMAYIM_NEKUDOTAYIM => true, + ]; if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) { // Special case for syntax like: return new self // where self should not be a string. if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW && strtolower($token[1]) === 'self' ) { - $finalTokens[$newStackPtr] = array( - 'content' => $token[1], - 'code' => T_SELF, - 'type' => 'T_SELF', - ); + $finalTokens[$newStackPtr] = [ + 'content' => $token[1], + 'code' => T_SELF, + 'type' => 'T_SELF', + ]; } else { - $finalTokens[$newStackPtr] = array( - 'content' => $token[1], - 'code' => T_STRING, - 'type' => 'T_STRING', - ); + $finalTokens[$newStackPtr] = [ + 'content' => $token[1], + 'code' => T_STRING, + 'type' => 'T_STRING', + ]; } $newStackPtr++; @@ -1414,7 +1414,7 @@ protected function processAdditional() for ($x = ($tokenAfterReturnTypeHint - 1); $x > $i; $x--) { if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { - if (in_array($this->tokens[$x]['code'], array(T_STRING, T_ARRAY, T_ARRAY_HINT, T_CALLABLE, T_SELF, T_PARENT), true) === true) { + if (in_array($this->tokens[$x]['code'], [T_STRING, T_ARRAY, T_ARRAY_HINT, T_CALLABLE, T_SELF, T_PARENT], true) === true) { if (PHP_CODESNIFFER_VERBOSITY > 1) { $line = $this->tokens[$x]['line']; $type = $this->tokens[$x]['type']; @@ -1487,15 +1487,15 @@ protected function processAdditional() // Unless there is a variable or a bracket before this token, // it is the start of an array being defined using the short syntax. $isShortArray = false; - $allowed = array( - T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET, - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS, - T_VARIABLE => T_VARIABLE, - T_OBJECT_OPERATOR => T_OBJECT_OPERATOR, - T_STRING => T_STRING, - T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, - ); + $allowed = [ + T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET, + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS, + T_VARIABLE => T_VARIABLE, + T_OBJECT_OPERATOR => T_OBJECT_OPERATOR, + T_STRING => T_STRING, + T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, + ]; for ($x = ($i - 1); $x > 0; $x--) { // If we hit a scope opener, the statement has ended @@ -1569,11 +1569,11 @@ protected function processAdditional() } } - $context = array( - T_OBJECT_OPERATOR => true, - T_NS_SEPARATOR => true, - T_PAAMAYIM_NEKUDOTAYIM => true, - ); + $context = [ + T_OBJECT_OPERATOR => true, + T_NS_SEPARATOR => true, + T_PAAMAYIM_NEKUDOTAYIM => true, + ]; if (isset($context[$this->tokens[$x]['code']]) === true) { if (PHP_CODESNIFFER_VERBOSITY > 1) { $line = $this->tokens[$i]['line']; @@ -1655,7 +1655,7 @@ protected function processAdditional() // not whatever it already is. The opener needs to be the opening curly // brace so everything matches up. $newCloser = $this->tokens[$x]['bracket_closer']; - foreach (array($i, $x, $newCloser) as $index) { + foreach ([$i, $x, $newCloser] as $index) { $this->tokens[$index]['scope_condition'] = $i; $this->tokens[$index]['scope_opener'] = $x; $this->tokens[$index]['scope_closer'] = $newCloser; @@ -1813,15 +1813,15 @@ public static function standardiseToken($token) self::$resolveTokenCache[$cacheKey] = $newToken; } else if ($token[0] === T_CURLY_OPEN) { - $newToken = array( - 'code' => T_OPEN_CURLY_BRACKET, - 'type' => 'T_OPEN_CURLY_BRACKET', - ); + $newToken = [ + 'code' => T_OPEN_CURLY_BRACKET, + 'type' => 'T_OPEN_CURLY_BRACKET', + ]; } else { - $newToken = array( - 'code' => $token[0], - 'type' => token_name($token[0]), - ); + $newToken = [ + 'code' => $token[0], + 'type' => token_name($token[0]), + ]; self::$resolveTokenCache[$token[0]] = $newToken; }//end if @@ -1845,7 +1845,7 @@ public static function standardiseToken($token) */ public static function resolveSimpleToken($token) { - $newToken = array(); + $newToken = []; switch ($token) { case '{': diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 5d7742be48..e02af4538a 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -27,28 +27,28 @@ abstract class Tokenizer * * @var string */ - protected $eolChar = array(); + protected $eolChar = []; /** * A token-based representation of the content. * * @var array */ - protected $tokens = array(); + protected $tokens = []; /** * Known lengths of tokens. * * @var array */ - public $knownLengths = array(); + public $knownLengths = []; /** * A list of lines being ignored due to error suppression comments. * * @var array */ - public $ignoredLines = array(); + public $ignoredLines = []; /** @@ -161,18 +161,18 @@ private function createPositionMap() $checkAnnotations = $this->config->annotations; - $this->tokensWithTabs = array( - T_WHITESPACE => true, - T_COMMENT => true, - T_DOC_COMMENT => true, - T_DOC_COMMENT_WHITESPACE => true, - T_DOC_COMMENT_STRING => true, - T_CONSTANT_ENCAPSED_STRING => true, - T_DOUBLE_QUOTED_STRING => true, - T_HEREDOC => true, - T_NOWDOC => true, - T_INLINE_HTML => true, - ); + $this->tokensWithTabs = [ + T_WHITESPACE => true, + T_COMMENT => true, + T_DOC_COMMENT => true, + T_DOC_COMMENT_WHITESPACE => true, + T_DOC_COMMENT_STRING => true, + T_CONSTANT_ENCAPSED_STRING => true, + T_DOUBLE_QUOTED_STRING => true, + T_HEREDOC => true, + T_NOWDOC => true, + T_INLINE_HTML => true, + ]; $this->numTokens = count($this->tokens); for ($i = 0; $i < $this->numTokens; $i++) { @@ -253,15 +253,15 @@ private function createPositionMap() if ($ignoring === null && strpos($commentText, '@codingStandardsIgnoreStart') !== false ) { - $ignoring = array('all' => true); + $ignoring = ['all' => true]; if ($ownLine === true) { - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; } } else if ($ignoring !== null && strpos($commentText, '@codingStandardsIgnoreEnd') !== false ) { if ($ownLine === true) { - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; } else { $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring; } @@ -270,9 +270,9 @@ private function createPositionMap() } else if ($ignoring === null && strpos($commentText, '@codingStandardsIgnoreLine') !== false ) { - $ignoring = array('all' => true); + $ignoring = ['all' => true]; if ($ownLine === true) { - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoring; } else { $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring; @@ -318,18 +318,18 @@ private function createPositionMap() } else if (substr($commentTextLower, 0, 13) === 'phpcs:disable') { if ($ownLine === true) { // Completely ignore the comment line. - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; } if ($ignoring === null) { - $ignoring = array(); + $ignoring = []; } - $disabledSniffs = array(); + $disabledSniffs = []; $additionalText = substr($commentText, 14); if ($additionalText === false) { - $ignoring = array('all' => true); + $ignoring = ['all' => true]; } else { $parts = explode(',', substr($commentText, 13)); foreach ($parts as $sniffCode) { @@ -345,7 +345,7 @@ private function createPositionMap() } else if ($ignoring !== null && substr($commentTextLower, 0, 12) === 'phpcs:enable' ) { - $enabledSniffs = array(); + $enabledSniffs = []; $additionalText = substr($commentText, 13); if ($additionalText === false) { @@ -367,7 +367,7 @@ private function createPositionMap() if ($ownLine === true) { // Completely ignore the comment line. - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; } else { // The comment is on the same line as the code it is ignoring, // so respect the new ignore rules. @@ -378,11 +378,11 @@ private function createPositionMap() $this->tokens[$i]['type'] = 'T_PHPCS_ENABLE'; $this->tokens[$i]['sniffCodes'] = $enabledSniffs; } else if (substr($commentTextLower, 0, 12) === 'phpcs:ignore') { - $ignoreRules = array(); + $ignoreRules = []; $additionalText = substr($commentText, 13); if ($additionalText === false) { - $ignoreRules = array('all' => true); + $ignoreRules = ['all' => true]; } else { $parts = explode(',', substr($commentText, 13)); foreach ($parts as $sniffCode) { @@ -401,7 +401,7 @@ private function createPositionMap() if ($ownLine === true) { // Completely ignore the comment line, and set the folllowing // line to include the ignore rules we've set. - $this->ignoredLines[$this->tokens[$i]['line']] = array('all' => true); + $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true]; $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoreRules; } else { // The comment is on the same line as the code it is ignoring, @@ -532,11 +532,11 @@ private function createTokenMap() echo "\t*** START TOKEN MAP ***".PHP_EOL; } - $squareOpeners = array(); - $curlyOpeners = array(); + $squareOpeners = []; + $curlyOpeners = []; $this->numTokens = count($this->tokens); - $openers = array(); + $openers = []; $openOwner = null; for ($i = 0; $i < $this->numTokens; $i++) { @@ -658,7 +658,7 @@ private function createTokenMap() */ private function createParenthesisNestingMap() { - $map = array(); + $map = []; for ($i = 0; $i < $this->numTokens; $i++) { if (isset($this->tokens[$i]['parenthesis_opener']) === true && $i === $this->tokens[$i]['parenthesis_opener'] @@ -853,10 +853,10 @@ private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) } } else { $scopeCloser = $i; - $todo = array( - $stackPtr, - $opener, - ); + $todo = [ + $stackPtr, + $opener, + ]; if (PHP_CODESNIFFER_VERBOSITY > 1) { $type = $this->tokens[$stackPtr]['type']; @@ -1098,12 +1098,12 @@ private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) // brace is a string offset, or this brace is mid-way through // a new statement, it isn't a scope opener. $disallowed = Util\Tokens::$assignmentTokens; - $disallowed += array( - T_VARIABLE => true, - T_OBJECT_OPERATOR => true, - T_COMMA => true, - T_OPEN_PARENTHESIS => true, - ); + $disallowed += [ + T_VARIABLE => true, + T_OBJECT_OPERATOR => true, + T_COMMA => true, + T_OPEN_PARENTHESIS => true, + ]; if (isset($disallowed[$this->tokens[$x]['code']]) === true) { if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -1215,7 +1215,7 @@ private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) echo "=> Found (unexpected) scope closer for $stackPtr:$type".PHP_EOL; } - foreach (array($stackPtr, $opener) as $token) { + foreach ([$stackPtr, $opener] as $token) { $this->tokens[$token]['scope_condition'] = $stackPtr; $this->tokens[$token]['scope_opener'] = $opener; $this->tokens[$token]['scope_closer'] = $i; @@ -1250,9 +1250,9 @@ private function createLevelMap() $this->numTokens = count($this->tokens); $level = 0; - $conditions = array(); + $conditions = []; $lastOpener = null; - $openers = array(); + $openers = []; for ($i = 0; $i < $this->numTokens; $i++) { if (PHP_CODESNIFFER_VERBOSITY > 1) { diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 08ab53e939..b77193055d 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -29,7 +29,7 @@ class Cache * * @var array */ - private static $cache = array(); + private static $cache = []; /** @@ -144,14 +144,14 @@ function ($file, $key, $iterator) { // the results of a run to create a new hash. This hash will be used // in the cache file name. $rulesetHash = md5(var_export($ruleset->ignorePatterns, true).var_export($ruleset->includePatterns, true)); - $configData = array( - 'tabWidth' => $config->tabWidth, - 'encoding' => $config->encoding, - 'recordErrors' => $config->recordErrors, - 'annotations' => $config->annotations, - 'codeHash' => $codeHash, - 'rulesetHash' => $rulesetHash, - ); + $configData = [ + 'tabWidth' => $config->tabWidth, + 'encoding' => $config->encoding, + 'recordErrors' => $config->recordErrors, + 'annotations' => $config->annotations, + 'codeHash' => $codeHash, + 'rulesetHash' => $rulesetHash, + ]; $configString = implode(',', $configData); $cacheHash = substr(sha1($configString), 0, 12); @@ -177,7 +177,7 @@ function ($file, $key, $iterator) { echo "\tChecking possible cache file paths".PHP_EOL; } - $paths = array(); + $paths = []; foreach ($config->files as $file) { $file = Common::realpath($file); while ($file !== DIRECTORY_SEPARATOR) { @@ -244,7 +244,7 @@ function ($file, $key, $iterator) { // Verify the contents of the cache file. if (self::$cache['config'] !== $configData) { - self::$cache = array(); + self::$cache = []; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t* cache was invalid and has been cleared *".PHP_EOL; } diff --git a/src/Util/Common.php b/src/Util/Common.php index ca8b5b81be..6d3ed25641 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -20,17 +20,17 @@ class Common * * @var string[] */ - public static $allowedTypes = array( - 'array', - 'boolean', - 'float', - 'integer', - 'mixed', - 'object', - 'string', - 'resource', - 'callable', - ); + public static $allowedTypes = [ + 'array', + 'boolean', + 'float', + 'integer', + 'mixed', + 'object', + 'string', + 'resource', + 'callable', + ]; /** @@ -162,7 +162,7 @@ public static function detectLineEndings($contents) * * @return string */ - public static function prepareForOutput($content, $exclude=array()) + public static function prepareForOutput($content, $exclude=[]) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (in_array("\r", $exclude) === false) { @@ -361,7 +361,7 @@ public static function suggestType($varType) if (strpos($lowerVarType, 'array(') !== false) { // Valid array declaration: // array, array(type), array(type1 => type2). - $matches = array(); + $matches = []; $pattern = '/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i'; if (preg_match($pattern, $varType, $matches) !== 0) { $type1 = ''; diff --git a/src/Util/Standards.php b/src/Util/Standards.php index ac608ab7b4..cbfc944c63 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -24,13 +24,13 @@ public static function getInstalledStandardPaths() { $ds = DIRECTORY_SEPARATOR; - $installedPaths = array(dirname(dirname(__DIR__)).$ds.'src'.$ds.'Standards'); + $installedPaths = [dirname(dirname(__DIR__)).$ds.'src'.$ds.'Standards']; $configPaths = Config::getConfigData('installed_paths'); if ($configPaths !== null) { $installedPaths = array_merge($installedPaths, explode(',', $configPaths)); } - $resolvedInstalledPaths = array(); + $resolvedInstalledPaths = []; foreach ($installedPaths as $installedPath) { if (substr($installedPath, 0, 1) === '.') { $installedPath = Common::realPath(__DIR__.$ds.'..'.$ds.'..'.$ds.$installedPath); @@ -74,12 +74,12 @@ public static function getInstalledStandardDetails( $includeGeneric=false, $standardsDir='' ) { - $rulesets = array(); + $rulesets = []; if ($standardsDir === '') { $installedPaths = self::getInstalledStandardPaths(); } else { - $installedPaths = array($standardsDir); + $installedPaths = [$standardsDir]; } foreach ($installedPaths as $standardsDir) { @@ -109,7 +109,7 @@ public static function getInstalledStandardDetails( } }//end foreach - $installedStandards = array(); + $installedStandards = []; foreach ($rulesets as $rulesetPath) { $ruleset = simplexml_load_string(file_get_contents($rulesetPath)); @@ -126,11 +126,11 @@ public static function getInstalledStandardDetails( $namespace = $dirname; } - $installedStandards[$dirname] = array( - 'path' => dirname($rulesetPath), - 'name' => $standardName, - 'namespace' => $namespace, - ); + $installedStandards[$dirname] = [ + 'path' => dirname($rulesetPath), + 'name' => $standardName, + 'namespace' => $namespace, + ]; }//end foreach return $installedStandards; @@ -159,12 +159,12 @@ public static function getInstalledStandards( $includeGeneric=false, $standardsDir='' ) { - $installedStandards = array(); + $installedStandards = []; if ($standardsDir === '') { $installedPaths = self::getInstalledStandardPaths(); } else { - $installedPaths = array($standardsDir); + $installedPaths = [$standardsDir]; } foreach ($installedPaths as $standardsDir) { diff --git a/src/Util/Tokens.php b/src/Util/Tokens.php index f70d216685..923b3070fb 100644 --- a/src/Util/Tokens.php +++ b/src/Util/Tokens.php @@ -136,331 +136,331 @@ final class Tokens * * @var array */ - public static $weightings = array( - T_CLASS => 1000, - T_INTERFACE => 1000, - T_TRAIT => 1000, - T_NAMESPACE => 1000, - T_FUNCTION => 100, - T_CLOSURE => 100, + public static $weightings = [ + T_CLASS => 1000, + T_INTERFACE => 1000, + T_TRAIT => 1000, + T_NAMESPACE => 1000, + T_FUNCTION => 100, + T_CLOSURE => 100, /* Conditions. */ - T_WHILE => 50, - T_FOR => 50, - T_FOREACH => 50, - T_IF => 50, - T_ELSE => 50, - T_ELSEIF => 50, - T_DO => 50, - T_TRY => 50, - T_CATCH => 50, - T_FINALLY => 50, - T_SWITCH => 50, - - T_SELF => 25, - T_PARENT => 25, + T_WHILE => 50, + T_FOR => 50, + T_FOREACH => 50, + T_IF => 50, + T_ELSE => 50, + T_ELSEIF => 50, + T_DO => 50, + T_TRY => 50, + T_CATCH => 50, + T_FINALLY => 50, + T_SWITCH => 50, + + T_SELF => 25, + T_PARENT => 25, /* Operators and arithmetic. */ - T_BITWISE_AND => 8, - T_BITWISE_OR => 8, - T_BITWISE_XOR => 8, - - T_MULTIPLY => 5, - T_DIVIDE => 5, - T_PLUS => 5, - T_MINUS => 5, - T_MODULUS => 5, - T_POW => 5, - T_SPACESHIP => 5, - T_COALESCE => 5, - T_COALESCE_EQUAL => 5, - - T_SL => 5, - T_SR => 5, - T_SL_EQUAL => 5, - T_SR_EQUAL => 5, - - T_EQUAL => 5, - T_AND_EQUAL => 5, - T_CONCAT_EQUAL => 5, - T_DIV_EQUAL => 5, - T_MINUS_EQUAL => 5, - T_MOD_EQUAL => 5, - T_MUL_EQUAL => 5, - T_OR_EQUAL => 5, - T_PLUS_EQUAL => 5, - T_XOR_EQUAL => 5, - - T_BOOLEAN_AND => 5, - T_BOOLEAN_OR => 5, + T_BITWISE_AND => 8, + T_BITWISE_OR => 8, + T_BITWISE_XOR => 8, + + T_MULTIPLY => 5, + T_DIVIDE => 5, + T_PLUS => 5, + T_MINUS => 5, + T_MODULUS => 5, + T_POW => 5, + T_SPACESHIP => 5, + T_COALESCE => 5, + T_COALESCE_EQUAL => 5, + + T_SL => 5, + T_SR => 5, + T_SL_EQUAL => 5, + T_SR_EQUAL => 5, + + T_EQUAL => 5, + T_AND_EQUAL => 5, + T_CONCAT_EQUAL => 5, + T_DIV_EQUAL => 5, + T_MINUS_EQUAL => 5, + T_MOD_EQUAL => 5, + T_MUL_EQUAL => 5, + T_OR_EQUAL => 5, + T_PLUS_EQUAL => 5, + T_XOR_EQUAL => 5, + + T_BOOLEAN_AND => 5, + T_BOOLEAN_OR => 5, /* Equality. */ - T_IS_EQUAL => 5, - T_IS_NOT_EQUAL => 5, - T_IS_IDENTICAL => 5, - T_IS_NOT_IDENTICAL => 5, - T_IS_SMALLER_OR_EQUAL => 5, - T_IS_GREATER_OR_EQUAL => 5, - ); + T_IS_EQUAL => 5, + T_IS_NOT_EQUAL => 5, + T_IS_IDENTICAL => 5, + T_IS_NOT_IDENTICAL => 5, + T_IS_SMALLER_OR_EQUAL => 5, + T_IS_GREATER_OR_EQUAL => 5, + ]; /** * Tokens that represent assignments. * * @var array */ - public static $assignmentTokens = array( - T_EQUAL => T_EQUAL, - T_AND_EQUAL => T_AND_EQUAL, - T_OR_EQUAL => T_OR_EQUAL, - T_CONCAT_EQUAL => T_CONCAT_EQUAL, - T_DIV_EQUAL => T_DIV_EQUAL, - T_MINUS_EQUAL => T_MINUS_EQUAL, - T_POW_EQUAL => T_POW_EQUAL, - T_MOD_EQUAL => T_MOD_EQUAL, - T_MUL_EQUAL => T_MUL_EQUAL, - T_PLUS_EQUAL => T_PLUS_EQUAL, - T_XOR_EQUAL => T_XOR_EQUAL, - T_DOUBLE_ARROW => T_DOUBLE_ARROW, - T_SL_EQUAL => T_SL_EQUAL, - T_SR_EQUAL => T_SR_EQUAL, - T_COALESCE_EQUAL => T_COALESCE_EQUAL, - ); + public static $assignmentTokens = [ + T_EQUAL => T_EQUAL, + T_AND_EQUAL => T_AND_EQUAL, + T_OR_EQUAL => T_OR_EQUAL, + T_CONCAT_EQUAL => T_CONCAT_EQUAL, + T_DIV_EQUAL => T_DIV_EQUAL, + T_MINUS_EQUAL => T_MINUS_EQUAL, + T_POW_EQUAL => T_POW_EQUAL, + T_MOD_EQUAL => T_MOD_EQUAL, + T_MUL_EQUAL => T_MUL_EQUAL, + T_PLUS_EQUAL => T_PLUS_EQUAL, + T_XOR_EQUAL => T_XOR_EQUAL, + T_DOUBLE_ARROW => T_DOUBLE_ARROW, + T_SL_EQUAL => T_SL_EQUAL, + T_SR_EQUAL => T_SR_EQUAL, + T_COALESCE_EQUAL => T_COALESCE_EQUAL, + ]; /** * Tokens that represent equality comparisons. * * @var array */ - public static $equalityTokens = array( - T_IS_EQUAL => T_IS_EQUAL, - T_IS_NOT_EQUAL => T_IS_NOT_EQUAL, - T_IS_IDENTICAL => T_IS_IDENTICAL, - T_IS_NOT_IDENTICAL => T_IS_NOT_IDENTICAL, - T_IS_SMALLER_OR_EQUAL => T_IS_SMALLER_OR_EQUAL, - T_IS_GREATER_OR_EQUAL => T_IS_GREATER_OR_EQUAL, - ); + public static $equalityTokens = [ + T_IS_EQUAL => T_IS_EQUAL, + T_IS_NOT_EQUAL => T_IS_NOT_EQUAL, + T_IS_IDENTICAL => T_IS_IDENTICAL, + T_IS_NOT_IDENTICAL => T_IS_NOT_IDENTICAL, + T_IS_SMALLER_OR_EQUAL => T_IS_SMALLER_OR_EQUAL, + T_IS_GREATER_OR_EQUAL => T_IS_GREATER_OR_EQUAL, + ]; /** * Tokens that represent comparison operator. * * @var array */ - public static $comparisonTokens = array( - T_IS_EQUAL => T_IS_EQUAL, - T_IS_IDENTICAL => T_IS_IDENTICAL, - T_IS_NOT_EQUAL => T_IS_NOT_EQUAL, - T_IS_NOT_IDENTICAL => T_IS_NOT_IDENTICAL, - T_LESS_THAN => T_LESS_THAN, - T_GREATER_THAN => T_GREATER_THAN, - T_IS_SMALLER_OR_EQUAL => T_IS_SMALLER_OR_EQUAL, - T_IS_GREATER_OR_EQUAL => T_IS_GREATER_OR_EQUAL, - T_SPACESHIP => T_SPACESHIP, - T_COALESCE => T_COALESCE, - ); + public static $comparisonTokens = [ + T_IS_EQUAL => T_IS_EQUAL, + T_IS_IDENTICAL => T_IS_IDENTICAL, + T_IS_NOT_EQUAL => T_IS_NOT_EQUAL, + T_IS_NOT_IDENTICAL => T_IS_NOT_IDENTICAL, + T_LESS_THAN => T_LESS_THAN, + T_GREATER_THAN => T_GREATER_THAN, + T_IS_SMALLER_OR_EQUAL => T_IS_SMALLER_OR_EQUAL, + T_IS_GREATER_OR_EQUAL => T_IS_GREATER_OR_EQUAL, + T_SPACESHIP => T_SPACESHIP, + T_COALESCE => T_COALESCE, + ]; /** * Tokens that represent arithmetic operators. * * @var array */ - public static $arithmeticTokens = array( - T_PLUS => T_PLUS, - T_MINUS => T_MINUS, - T_MULTIPLY => T_MULTIPLY, - T_DIVIDE => T_DIVIDE, - T_MODULUS => T_MODULUS, - T_POW => T_POW, - ); + public static $arithmeticTokens = [ + T_PLUS => T_PLUS, + T_MINUS => T_MINUS, + T_MULTIPLY => T_MULTIPLY, + T_DIVIDE => T_DIVIDE, + T_MODULUS => T_MODULUS, + T_POW => T_POW, + ]; /** * Tokens that represent casting. * * @var array */ - public static $castTokens = array( - T_INT_CAST => T_INT_CAST, - T_STRING_CAST => T_STRING_CAST, - T_DOUBLE_CAST => T_DOUBLE_CAST, - T_ARRAY_CAST => T_ARRAY_CAST, - T_BOOL_CAST => T_BOOL_CAST, - T_OBJECT_CAST => T_OBJECT_CAST, - T_UNSET_CAST => T_UNSET_CAST, - T_BINARY_CAST => T_BINARY_CAST, - ); + public static $castTokens = [ + T_INT_CAST => T_INT_CAST, + T_STRING_CAST => T_STRING_CAST, + T_DOUBLE_CAST => T_DOUBLE_CAST, + T_ARRAY_CAST => T_ARRAY_CAST, + T_BOOL_CAST => T_BOOL_CAST, + T_OBJECT_CAST => T_OBJECT_CAST, + T_UNSET_CAST => T_UNSET_CAST, + T_BINARY_CAST => T_BINARY_CAST, + ]; /** * Token types that open parenthesis. * * @var array */ - public static $parenthesisOpeners = array( - T_ARRAY => T_ARRAY, - T_FUNCTION => T_FUNCTION, - T_CLOSURE => T_CLOSURE, - T_WHILE => T_WHILE, - T_FOR => T_FOR, - T_FOREACH => T_FOREACH, - T_SWITCH => T_SWITCH, - T_IF => T_IF, - T_ELSEIF => T_ELSEIF, - T_CATCH => T_CATCH, - T_DECLARE => T_DECLARE, - ); + public static $parenthesisOpeners = [ + T_ARRAY => T_ARRAY, + T_FUNCTION => T_FUNCTION, + T_CLOSURE => T_CLOSURE, + T_WHILE => T_WHILE, + T_FOR => T_FOR, + T_FOREACH => T_FOREACH, + T_SWITCH => T_SWITCH, + T_IF => T_IF, + T_ELSEIF => T_ELSEIF, + T_CATCH => T_CATCH, + T_DECLARE => T_DECLARE, + ]; /** * Tokens that are allowed to open scopes. * * @var array */ - public static $scopeOpeners = array( - T_CLASS => T_CLASS, - T_ANON_CLASS => T_ANON_CLASS, - T_INTERFACE => T_INTERFACE, - T_TRAIT => T_TRAIT, - T_NAMESPACE => T_NAMESPACE, - T_FUNCTION => T_FUNCTION, - T_CLOSURE => T_CLOSURE, - T_IF => T_IF, - T_SWITCH => T_SWITCH, - T_CASE => T_CASE, - T_DECLARE => T_DECLARE, - T_DEFAULT => T_DEFAULT, - T_WHILE => T_WHILE, - T_ELSE => T_ELSE, - T_ELSEIF => T_ELSEIF, - T_FOR => T_FOR, - T_FOREACH => T_FOREACH, - T_DO => T_DO, - T_TRY => T_TRY, - T_CATCH => T_CATCH, - T_FINALLY => T_FINALLY, - T_PROPERTY => T_PROPERTY, - T_OBJECT => T_OBJECT, - T_USE => T_USE, - ); + public static $scopeOpeners = [ + T_CLASS => T_CLASS, + T_ANON_CLASS => T_ANON_CLASS, + T_INTERFACE => T_INTERFACE, + T_TRAIT => T_TRAIT, + T_NAMESPACE => T_NAMESPACE, + T_FUNCTION => T_FUNCTION, + T_CLOSURE => T_CLOSURE, + T_IF => T_IF, + T_SWITCH => T_SWITCH, + T_CASE => T_CASE, + T_DECLARE => T_DECLARE, + T_DEFAULT => T_DEFAULT, + T_WHILE => T_WHILE, + T_ELSE => T_ELSE, + T_ELSEIF => T_ELSEIF, + T_FOR => T_FOR, + T_FOREACH => T_FOREACH, + T_DO => T_DO, + T_TRY => T_TRY, + T_CATCH => T_CATCH, + T_FINALLY => T_FINALLY, + T_PROPERTY => T_PROPERTY, + T_OBJECT => T_OBJECT, + T_USE => T_USE, + ]; /** * Tokens that represent scope modifiers. * * @var array */ - public static $scopeModifiers = array( - T_PRIVATE => T_PRIVATE, - T_PUBLIC => T_PUBLIC, - T_PROTECTED => T_PROTECTED, - ); + public static $scopeModifiers = [ + T_PRIVATE => T_PRIVATE, + T_PUBLIC => T_PUBLIC, + T_PROTECTED => T_PROTECTED, + ]; /** * Tokens that can prefix a method name * * @var array */ - public static $methodPrefixes = array( - T_PRIVATE => T_PRIVATE, - T_PUBLIC => T_PUBLIC, - T_PROTECTED => T_PROTECTED, - T_ABSTRACT => T_ABSTRACT, - T_STATIC => T_STATIC, - T_FINAL => T_FINAL, - ); + public static $methodPrefixes = [ + T_PRIVATE => T_PRIVATE, + T_PUBLIC => T_PUBLIC, + T_PROTECTED => T_PROTECTED, + T_ABSTRACT => T_ABSTRACT, + T_STATIC => T_STATIC, + T_FINAL => T_FINAL, + ]; /** * Tokens that perform operations. * * @var array */ - public static $operators = array( - T_MINUS => T_MINUS, - T_PLUS => T_PLUS, - T_MULTIPLY => T_MULTIPLY, - T_DIVIDE => T_DIVIDE, - T_MODULUS => T_MODULUS, - T_POW => T_POW, - T_SPACESHIP => T_SPACESHIP, - T_COALESCE => T_COALESCE, - T_BITWISE_AND => T_BITWISE_AND, - T_BITWISE_OR => T_BITWISE_OR, - T_BITWISE_XOR => T_BITWISE_XOR, - T_SL => T_SL, - T_SR => T_SR, - ); + public static $operators = [ + T_MINUS => T_MINUS, + T_PLUS => T_PLUS, + T_MULTIPLY => T_MULTIPLY, + T_DIVIDE => T_DIVIDE, + T_MODULUS => T_MODULUS, + T_POW => T_POW, + T_SPACESHIP => T_SPACESHIP, + T_COALESCE => T_COALESCE, + T_BITWISE_AND => T_BITWISE_AND, + T_BITWISE_OR => T_BITWISE_OR, + T_BITWISE_XOR => T_BITWISE_XOR, + T_SL => T_SL, + T_SR => T_SR, + ]; /** * Tokens that perform boolean operations. * * @var array */ - public static $booleanOperators = array( - T_BOOLEAN_AND => T_BOOLEAN_AND, - T_BOOLEAN_OR => T_BOOLEAN_OR, - T_LOGICAL_AND => T_LOGICAL_AND, - T_LOGICAL_OR => T_LOGICAL_OR, - T_LOGICAL_XOR => T_LOGICAL_XOR, - ); + public static $booleanOperators = [ + T_BOOLEAN_AND => T_BOOLEAN_AND, + T_BOOLEAN_OR => T_BOOLEAN_OR, + T_LOGICAL_AND => T_LOGICAL_AND, + T_LOGICAL_OR => T_LOGICAL_OR, + T_LOGICAL_XOR => T_LOGICAL_XOR, + ]; /** * Tokens that open code blocks. * * @var array */ - public static $blockOpeners = array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_OPEN_SQUARE_BRACKET => T_OPEN_SQUARE_BRACKET, - T_OPEN_PARENTHESIS => T_OPEN_PARENTHESIS, - T_OBJECT => T_OBJECT, - ); + public static $blockOpeners = [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_OPEN_SQUARE_BRACKET => T_OPEN_SQUARE_BRACKET, + T_OPEN_PARENTHESIS => T_OPEN_PARENTHESIS, + T_OBJECT => T_OBJECT, + ]; /** * Tokens that don't represent code. * * @var array */ - public static $emptyTokens = array( - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - T_DOC_COMMENT_STAR => T_DOC_COMMENT_STAR, - T_DOC_COMMENT_WHITESPACE => T_DOC_COMMENT_WHITESPACE, - T_DOC_COMMENT_TAG => T_DOC_COMMENT_TAG, - T_DOC_COMMENT_OPEN_TAG => T_DOC_COMMENT_OPEN_TAG, - T_DOC_COMMENT_CLOSE_TAG => T_DOC_COMMENT_CLOSE_TAG, - T_DOC_COMMENT_STRING => T_DOC_COMMENT_STRING, - T_PHPCS_ENABLE => T_PHPCS_ENABLE, - T_PHPCS_DISABLE => T_PHPCS_DISABLE, - T_PHPCS_SET => T_PHPCS_SET, - T_PHPCS_IGNORE => T_PHPCS_IGNORE, - T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE, - ); + public static $emptyTokens = [ + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + T_DOC_COMMENT_STAR => T_DOC_COMMENT_STAR, + T_DOC_COMMENT_WHITESPACE => T_DOC_COMMENT_WHITESPACE, + T_DOC_COMMENT_TAG => T_DOC_COMMENT_TAG, + T_DOC_COMMENT_OPEN_TAG => T_DOC_COMMENT_OPEN_TAG, + T_DOC_COMMENT_CLOSE_TAG => T_DOC_COMMENT_CLOSE_TAG, + T_DOC_COMMENT_STRING => T_DOC_COMMENT_STRING, + T_PHPCS_ENABLE => T_PHPCS_ENABLE, + T_PHPCS_DISABLE => T_PHPCS_DISABLE, + T_PHPCS_SET => T_PHPCS_SET, + T_PHPCS_IGNORE => T_PHPCS_IGNORE, + T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE, + ]; /** * Tokens that are comments. * * @var array */ - public static $commentTokens = array( - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - T_DOC_COMMENT_STAR => T_DOC_COMMENT_STAR, - T_DOC_COMMENT_WHITESPACE => T_DOC_COMMENT_WHITESPACE, - T_DOC_COMMENT_TAG => T_DOC_COMMENT_TAG, - T_DOC_COMMENT_OPEN_TAG => T_DOC_COMMENT_OPEN_TAG, - T_DOC_COMMENT_CLOSE_TAG => T_DOC_COMMENT_CLOSE_TAG, - T_DOC_COMMENT_STRING => T_DOC_COMMENT_STRING, - T_PHPCS_ENABLE => T_PHPCS_ENABLE, - T_PHPCS_DISABLE => T_PHPCS_DISABLE, - T_PHPCS_SET => T_PHPCS_SET, - T_PHPCS_IGNORE => T_PHPCS_IGNORE, - T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE, - ); + public static $commentTokens = [ + T_COMMENT => T_COMMENT, + T_DOC_COMMENT => T_DOC_COMMENT, + T_DOC_COMMENT_STAR => T_DOC_COMMENT_STAR, + T_DOC_COMMENT_WHITESPACE => T_DOC_COMMENT_WHITESPACE, + T_DOC_COMMENT_TAG => T_DOC_COMMENT_TAG, + T_DOC_COMMENT_OPEN_TAG => T_DOC_COMMENT_OPEN_TAG, + T_DOC_COMMENT_CLOSE_TAG => T_DOC_COMMENT_CLOSE_TAG, + T_DOC_COMMENT_STRING => T_DOC_COMMENT_STRING, + T_PHPCS_ENABLE => T_PHPCS_ENABLE, + T_PHPCS_DISABLE => T_PHPCS_DISABLE, + T_PHPCS_SET => T_PHPCS_SET, + T_PHPCS_IGNORE => T_PHPCS_IGNORE, + T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE, + ]; /** * Tokens that represent strings. @@ -469,63 +469,63 @@ final class Tokens * * @var array */ - public static $stringTokens = array( - T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, - ); + public static $stringTokens = [ + T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, + ]; /** * Tokens that represent text strings. * * @var array */ - public static $textStringTokens = array( - T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, - T_INLINE_HTML => T_INLINE_HTML, - T_HEREDOC => T_HEREDOC, - T_NOWDOC => T_NOWDOC, - ); + public static $textStringTokens = [ + T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING, + T_INLINE_HTML => T_INLINE_HTML, + T_HEREDOC => T_HEREDOC, + T_NOWDOC => T_NOWDOC, + ]; /** * Tokens that represent brackets and parenthesis. * * @var array */ - public static $bracketTokens = array( - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_OPEN_SQUARE_BRACKET => T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET, - T_OPEN_PARENTHESIS => T_OPEN_PARENTHESIS, - T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS, - ); + public static $bracketTokens = [ + T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, + T_OPEN_SQUARE_BRACKET => T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET, + T_OPEN_PARENTHESIS => T_OPEN_PARENTHESIS, + T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS, + ]; /** * Tokens that include files. * * @var array */ - public static $includeTokens = array( - T_REQUIRE_ONCE => T_REQUIRE_ONCE, - T_REQUIRE => T_REQUIRE, - T_INCLUDE_ONCE => T_INCLUDE_ONCE, - T_INCLUDE => T_INCLUDE, - ); + public static $includeTokens = [ + T_REQUIRE_ONCE => T_REQUIRE_ONCE, + T_REQUIRE => T_REQUIRE, + T_INCLUDE_ONCE => T_INCLUDE_ONCE, + T_INCLUDE => T_INCLUDE, + ]; /** * Tokens that make up a heredoc string. * * @var array */ - public static $heredocTokens = array( - T_START_HEREDOC => T_START_HEREDOC, - T_END_HEREDOC => T_END_HEREDOC, - T_HEREDOC => T_HEREDOC, - T_START_NOWDOC => T_START_NOWDOC, - T_END_NOWDOC => T_END_NOWDOC, - T_NOWDOC => T_NOWDOC, - ); + public static $heredocTokens = [ + T_START_HEREDOC => T_START_HEREDOC, + T_END_HEREDOC => T_END_HEREDOC, + T_HEREDOC => T_HEREDOC, + T_START_NOWDOC => T_START_NOWDOC, + T_END_NOWDOC => T_END_NOWDOC, + T_NOWDOC => T_NOWDOC, + ]; /** * Tokens that represent the names of called functions. @@ -535,32 +535,32 @@ final class Tokens * * @var array */ - public static $functionNameTokens = array( - T_STRING => T_STRING, - T_EVAL => T_EVAL, - T_EXIT => T_EXIT, - T_INCLUDE => T_INCLUDE, - T_INCLUDE_ONCE => T_INCLUDE_ONCE, - T_REQUIRE => T_REQUIRE, - T_REQUIRE_ONCE => T_REQUIRE_ONCE, - T_ISSET => T_ISSET, - T_UNSET => T_UNSET, - T_EMPTY => T_EMPTY, - T_SELF => T_SELF, - T_STATIC => T_STATIC, - ); + public static $functionNameTokens = [ + T_STRING => T_STRING, + T_EVAL => T_EVAL, + T_EXIT => T_EXIT, + T_INCLUDE => T_INCLUDE, + T_INCLUDE_ONCE => T_INCLUDE_ONCE, + T_REQUIRE => T_REQUIRE, + T_REQUIRE_ONCE => T_REQUIRE_ONCE, + T_ISSET => T_ISSET, + T_UNSET => T_UNSET, + T_EMPTY => T_EMPTY, + T_SELF => T_SELF, + T_STATIC => T_STATIC, + ]; /** * Tokens that are open class and object scopes. * * @var array */ - public static $ooScopeTokens = array( - T_CLASS => T_CLASS, - T_ANON_CLASS => T_ANON_CLASS, - T_INTERFACE => T_INTERFACE, - T_TRAIT => T_TRAIT, - ); + public static $ooScopeTokens = [ + T_CLASS => T_CLASS, + T_ANON_CLASS => T_ANON_CLASS, + T_INTERFACE => T_INTERFACE, + T_TRAIT => T_TRAIT, + ]; /** diff --git a/tests/AllTests.php b/tests/AllTests.php index 9c28c4f57a..7514cdfa2b 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -45,8 +45,8 @@ public static function main() */ public static function suite() { - $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'] = array(); - $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'] = array(); + $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'] = []; + $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'] = []; // Use a special PHP_CodeSniffer test suite so that we can // unset our autoload function after the run. diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index b5824bc31f..3818a781b4 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -26,8 +26,8 @@ class ErrorSuppressionTest extends TestCase public function testSuppressError() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.PHP.LowerCaseConstant'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.PHP.LowerCaseConstant']; $ruleset = new Ruleset($config); @@ -122,8 +122,8 @@ public function testSuppressError() public function testSuppressSomeErrors() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.PHP.LowerCaseConstant'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.PHP.LowerCaseConstant']; $ruleset = new Ruleset($config); @@ -188,8 +188,8 @@ public function testSuppressSomeErrors() public function testSuppressWarning() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.Commenting.Todo'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.Commenting.Todo']; $ruleset = new Ruleset($config); @@ -254,8 +254,8 @@ public function testSuppressWarning() public function testSuppressLine() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.PHP.LowerCaseConstant'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.PHP.LowerCaseConstant']; $ruleset = new Ruleset($config); @@ -320,8 +320,8 @@ public function testSuppressLine() public function testNestedSuppressLine() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.PHP.LowerCaseConstant'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.PHP.LowerCaseConstant']; $ruleset = new Ruleset($config); @@ -377,7 +377,7 @@ public function testSuppressScope() { return; $phpcs = new PHP_CodeSniffer(); - $phpcs->initStandard('PEAR', array('PEAR.NamingConventions.ValidVariableName')); + $phpcs->initStandard('PEAR', ['PEAR.NamingConventions.ValidVariableName']); // Process without suppression. $content = 'foo();'.PHP_EOL.'}'.PHP_EOL.'}'; @@ -438,8 +438,8 @@ public function testSuppressScope() public function testSuppressFile() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array('Generic.Commenting.Todo'); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.Commenting.Todo']; $ruleset = new Ruleset($config); @@ -554,11 +554,11 @@ public function testSuppressFile() public function testDisableSelected() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array( - 'Generic.PHP.LowerCaseConstant', - 'Generic.Commenting.Todo', - ); + $config->standards = ['Generic']; + $config->sniffs = [ + 'Generic.PHP.LowerCaseConstant', + 'Generic.Commenting.Todo', + ]; $ruleset = new Ruleset($config); @@ -643,11 +643,11 @@ public function testDisableSelected() public function testEnableSelected() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array( - 'Generic.PHP.LowerCaseConstant', - 'Generic.Commenting.Todo', - ); + $config->standards = ['Generic']; + $config->sniffs = [ + 'Generic.PHP.LowerCaseConstant', + 'Generic.Commenting.Todo', + ]; $ruleset = new Ruleset($config); @@ -732,11 +732,11 @@ public function testEnableSelected() public function testIgnoreSelected() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array( - 'Generic.PHP.LowerCaseConstant', - 'Generic.Commenting.Todo', - ); + $config->standards = ['Generic']; + $config->sniffs = [ + 'Generic.PHP.LowerCaseConstant', + 'Generic.Commenting.Todo', + ]; $ruleset = new Ruleset($config); @@ -835,11 +835,11 @@ public function testIgnoreSelected() public function testCommenting() { $config = new Config(); - $config->standards = array('Generic'); - $config->sniffs = array( - 'Generic.PHP.LowerCaseConstant', - 'Generic.Commenting.Todo', - ); + $config->standards = ['Generic']; + $config->sniffs = [ + 'Generic.PHP.LowerCaseConstant', + 'Generic.Commenting.Todo', + ]; $ruleset = new Ruleset($config); diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index 7a76cfd1de..9217152ede 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -36,7 +36,7 @@ class FindExtendedClassNameTest extends TestCase public function setUp() { $config = new Config(); - $config->standards = array('Generic'); + $config->standards = ['Generic']; $ruleset = new Ruleset($config); diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 7e865f1d6b..581023274b 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -36,7 +36,7 @@ class FindImplementedInterfaceNamesTest extends TestCase public function setUp() { $config = new Config(); - $config->standards = array('Generic'); + $config->standards = ['Generic']; $ruleset = new Ruleset($config); @@ -76,7 +76,7 @@ public function testImplementedClass() ); $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2)); - $this->assertSame(array('testFIINInterface'), $found); + $this->assertSame(['testFIINInterface'], $found); }//end testImplementedClass() @@ -98,7 +98,7 @@ public function testMultiImplementedClass() ); $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2)); - $this->assertSame(array('testFIINInterface', 'testFIINInterface2'), $found); + $this->assertSame(['testFIINInterface', 'testFIINInterface2'], $found); }//end testMultiImplementedClass() @@ -120,7 +120,7 @@ public function testNamespacedClass() ); $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2)); - $this->assertSame(array('\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'), $found); + $this->assertSame(['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], $found); }//end testNamespacedClass() diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index 15ce46e25f..9c9f7c2c67 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -36,7 +36,7 @@ class GetMethodParametersTest extends TestCase public function setUp() { $config = new Config(); - $config->standards = array('Generic'); + $config->standards = ['Generic']; $ruleset = new Ruleset($config); @@ -66,15 +66,15 @@ public function tearDown() */ public function testPassByReference() { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'content' => '&$var', - 'pass_by_reference' => true, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var', + 'content' => '&$var', + 'pass_by_reference' => true, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -99,15 +99,15 @@ public function testPassByReference() */ public function testArrayHint() { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'content' => 'array $var', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'array', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var', + 'content' => 'array $var', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => 'array', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -132,24 +132,24 @@ public function testArrayHint() */ public function testTypeHint() { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'content' => 'foo $var1', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'foo', - 'nullable_type' => false, - ); - - $expected[1] = array( - 'name' => '$var2', - 'content' => 'bar $var2', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'bar', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var1', + 'content' => 'foo $var1', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => 'foo', + 'nullable_type' => false, + ]; + + $expected[1] = [ + 'name' => '$var2', + 'content' => 'bar $var2', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => 'bar', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -175,15 +175,15 @@ public function testTypeHint() */ public function testSelfTypeHint() { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'content' => 'self $var', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'self', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var', + 'content' => 'self $var', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => 'self', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -208,24 +208,24 @@ public function testSelfTypeHint() */ public function testNullableTypeHint() { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'content' => '?int $var1', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?int', - 'nullable_type' => true, - ); - - $expected[1] = array( - 'name' => '$var2', - 'content' => '?\bar $var2', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?\bar', - 'nullable_type' => true, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var1', + 'content' => '?int $var1', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '?int', + 'nullable_type' => true, + ]; + + $expected[1] = [ + 'name' => '$var2', + 'content' => '?\bar $var2', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '?\bar', + 'nullable_type' => true, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -251,15 +251,15 @@ public function testNullableTypeHint() */ public function testVariable() { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'content' => '$var', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var', + 'content' => '$var', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -284,16 +284,16 @@ public function testVariable() */ public function testSingleDefaultValue() { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'content' => '$var1=self::CONSTANT', - 'default' => 'self::CONSTANT', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var1', + 'content' => '$var1=self::CONSTANT', + 'default' => 'self::CONSTANT', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -318,25 +318,25 @@ public function testSingleDefaultValue() */ public function testDefaultValues() { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'content' => '$var1=1', - 'default' => '1', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); - $expected[1] = array( - 'name' => '$var2', - 'content' => "\$var2='value'", - 'default' => "'value'", - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$var1', + 'content' => '$var1=1', + 'default' => '1', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; + $expected[1] = [ + 'name' => '$var2', + 'content' => "\$var2='value'", + 'default' => "'value'", + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( @@ -362,16 +362,16 @@ public function testDefaultValues() */ public function testBitwiseAndConstantExpressionDefaultValue() { - $expected = array(); - $expected[0] = array( - 'name' => '$a', - 'content' => '$a = 10 & 20', - 'default' => '10 & 20', - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, - ); + $expected = []; + $expected[0] = [ + 'name' => '$a', + 'content' => '$a = 10 & 20', + 'default' => '10 & 20', + 'pass_by_reference' => false, + 'variable_length' => false, + 'type_hint' => '', + 'nullable_type' => false, + ]; $start = ($this->phpcsFile->numTokens - 1); $function = $this->phpcsFile->findPrevious( diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index cffbce191f..a3fecc32ed 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -36,7 +36,7 @@ class IsReferenceTest extends TestCase public function setUp() { $config = new Config(); - $config->standards = array('Generic'); + $config->standards = ['Generic']; $ruleset = new Ruleset($config); @@ -96,188 +96,188 @@ public function testIsReference($identifier, $expected) */ public function dataIsReference() { - return array( - array( - '/* bitwiseAndA */', - false, - ), - array( - '/* bitwiseAndB */', - false, - ), - array( - '/* bitwiseAndC */', - false, - ), - array( - '/* bitwiseAndD */', - false, - ), - array( - '/* bitwiseAndE */', - false, - ), - array( - '/* bitwiseAndF */', - false, - ), - array( - '/* bitwiseAndG */', - false, - ), - array( - '/* bitwiseAndH */', - false, - ), - array( - '/* bitwiseAndI */', - false, - ), - array( - '/* functionReturnByReference */', - true, - ), - array( - '/* functionPassByReferenceA */', - true, - ), - array( - '/* functionPassByReferenceB */', - true, - ), - array( - '/* functionPassByReferenceC */', - true, - ), - array( - '/* functionPassByReferenceD */', - true, - ), - array( - '/* functionPassByReferenceE */', - true, - ), - array( - '/* functionPassByReferenceF */', - true, - ), - array( - '/* functionPassByReferenceG */', - true, - ), - array( - '/* foreachValueByReference */', - true, - ), - array( - '/* foreachKeyByReference */', - true, - ), - array( - '/* arrayValueByReferenceA */', - true, - ), - array( - '/* arrayValueByReferenceB */', - true, - ), - array( - '/* arrayValueByReferenceC */', - true, - ), - array( - '/* arrayValueByReferenceD */', - true, - ), - array( - '/* arrayValueByReferenceE */', - true, - ), - array( - '/* arrayValueByReferenceF */', - true, - ), - array( - '/* arrayValueByReferenceG */', - true, - ), - array( - '/* arrayValueByReferenceH */', - true, - ), - array( - '/* assignByReferenceA */', - true, - ), - array( - '/* assignByReferenceB */', - true, - ), - array( - '/* assignByReferenceC */', - true, - ), - array( - '/* assignByReferenceD */', - true, - ), - array( - '/* assignByReferenceE */', - true, - ), - array( - '/* passByReferenceA */', - true, - ), - array( - '/* passByReferenceB */', - true, - ), - array( - '/* passByReferenceC */', - true, - ), - array( - '/* passByReferenceD */', - true, - ), - array( - '/* passByReferenceE */', - true, - ), - array( - '/* passByReferenceF */', - true, - ), - array( - '/* passByReferenceG */', - true, - ), - array( - '/* passByReferenceH */', - true, - ), - array( - '/* passByReferenceI */', - true, - ), - array( - '/* passByReferenceJ */', - true, - ), - array( - '/* newByReferenceA */', - true, - ), - array( - '/* newByReferenceB */', - true, - ), - array( - '/* useByReference */', - true, - ), - ); + return [ + [ + '/* bitwiseAndA */', + false, + ], + [ + '/* bitwiseAndB */', + false, + ], + [ + '/* bitwiseAndC */', + false, + ], + [ + '/* bitwiseAndD */', + false, + ], + [ + '/* bitwiseAndE */', + false, + ], + [ + '/* bitwiseAndF */', + false, + ], + [ + '/* bitwiseAndG */', + false, + ], + [ + '/* bitwiseAndH */', + false, + ], + [ + '/* bitwiseAndI */', + false, + ], + [ + '/* functionReturnByReference */', + true, + ], + [ + '/* functionPassByReferenceA */', + true, + ], + [ + '/* functionPassByReferenceB */', + true, + ], + [ + '/* functionPassByReferenceC */', + true, + ], + [ + '/* functionPassByReferenceD */', + true, + ], + [ + '/* functionPassByReferenceE */', + true, + ], + [ + '/* functionPassByReferenceF */', + true, + ], + [ + '/* functionPassByReferenceG */', + true, + ], + [ + '/* foreachValueByReference */', + true, + ], + [ + '/* foreachKeyByReference */', + true, + ], + [ + '/* arrayValueByReferenceA */', + true, + ], + [ + '/* arrayValueByReferenceB */', + true, + ], + [ + '/* arrayValueByReferenceC */', + true, + ], + [ + '/* arrayValueByReferenceD */', + true, + ], + [ + '/* arrayValueByReferenceE */', + true, + ], + [ + '/* arrayValueByReferenceF */', + true, + ], + [ + '/* arrayValueByReferenceG */', + true, + ], + [ + '/* arrayValueByReferenceH */', + true, + ], + [ + '/* assignByReferenceA */', + true, + ], + [ + '/* assignByReferenceB */', + true, + ], + [ + '/* assignByReferenceC */', + true, + ], + [ + '/* assignByReferenceD */', + true, + ], + [ + '/* assignByReferenceE */', + true, + ], + [ + '/* passByReferenceA */', + true, + ], + [ + '/* passByReferenceB */', + true, + ], + [ + '/* passByReferenceC */', + true, + ], + [ + '/* passByReferenceD */', + true, + ], + [ + '/* passByReferenceE */', + true, + ], + [ + '/* passByReferenceF */', + true, + ], + [ + '/* passByReferenceG */', + true, + ], + [ + '/* passByReferenceH */', + true, + ], + [ + '/* passByReferenceI */', + true, + ], + [ + '/* passByReferenceJ */', + true, + ], + [ + '/* newByReferenceA */', + true, + ], + [ + '/* newByReferenceB */', + true, + ], + [ + '/* useByReference */', + true, + ], + ]; }//end dataIsReference() diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index 5feff610bb..09b01e2328 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -73,7 +73,7 @@ protected function setUp() */ protected function getTestFiles($testFileBase) { - $testFiles = array(); + $testFiles = []; $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); $di = new \DirectoryIterator($dir); @@ -136,12 +136,12 @@ final public function testSniff() $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; } - $config->standards = array($standardName); - $config->sniffs = array($sniffCode); - $config->ignored = array(); + $config->standards = [$standardName]; + $config->sniffs = [$sniffCode]; + $config->ignored = []; if (isset($GLOBALS['PHP_CODESNIFFER_RULESETS']) === false) { - $GLOBALS['PHP_CODESNIFFER_RULESETS'] = array(); + $GLOBALS['PHP_CODESNIFFER_RULESETS'] = []; } if (isset($GLOBALS['PHP_CODESNIFFER_RULESETS'][$standardName]) === false) { @@ -157,11 +157,11 @@ final public function testSniff() $sniffClassName = str_replace('\Tests\\', '\Sniffs\\', $sniffClassName); $sniffClassName = Common::cleanSniffClass($sniffClassName); - $restrictions = array(strtolower($sniffClassName) => true); - $ruleset->registerSniffs(array($sniffFile), $restrictions, array()); + $restrictions = [strtolower($sniffClassName) => true]; + $ruleset->registerSniffs([$sniffFile], $restrictions, []); $ruleset->populateTokenListeners(); - $failureMessages = array(); + $failureMessages = []; foreach ($testFiles as $testFile) { $filename = basename($testFile); $oldConfig = $config->getSettings(); @@ -240,26 +240,26 @@ public function generateFailureMessages(LocalFile $file) it's not really structured to allow that. */ - $allProblems = array(); - $failureMessages = array(); + $allProblems = []; + $failureMessages = []; foreach ($foundErrors as $line => $lineErrors) { foreach ($lineErrors as $column => $errors) { if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); + $allProblems[$line] = [ + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => [], + 'found_warnings' => [], + ]; } - $foundErrorsTemp = array(); + $foundErrorsTemp = []; foreach ($allProblems[$line]['found_errors'] as $foundError) { $foundErrorsTemp[] = $foundError; } - $errorsTemp = array(); + $errorsTemp = []; foreach ($errors as $foundError) { $errorsTemp[] = $foundError['message'].' ('.$foundError['source'].')'; @@ -289,12 +289,12 @@ public function generateFailureMessages(LocalFile $file) foreach ($expectedErrors as $line => $numErrors) { if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); + $allProblems[$line] = [ + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => [], + 'found_warnings' => [], + ]; } $allProblems[$line]['expected_errors'] = $numErrors; @@ -303,20 +303,20 @@ public function generateFailureMessages(LocalFile $file) foreach ($foundWarnings as $line => $lineWarnings) { foreach ($lineWarnings as $column => $warnings) { if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); + $allProblems[$line] = [ + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => [], + 'found_warnings' => [], + ]; } - $foundWarningsTemp = array(); + $foundWarningsTemp = []; foreach ($allProblems[$line]['found_warnings'] as $foundWarning) { $foundWarningsTemp[] = $foundWarning; } - $warningsTemp = array(); + $warningsTemp = []; foreach ($warnings as $warning) { $warningsTemp[] = $warning['message'].' ('.$warning['source'].')'; } @@ -335,12 +335,12 @@ public function generateFailureMessages(LocalFile $file) foreach ($expectedWarnings as $line => $numWarnings) { if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); + $allProblems[$line] = [ + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => [], + 'found_warnings' => [], + ]; } $allProblems[$line]['expected_warnings'] = $numWarnings; diff --git a/tests/Standards/AllSniffs.php b/tests/Standards/AllSniffs.php index f899cb7c5b..6356e23c38 100644 --- a/tests/Standards/AllSniffs.php +++ b/tests/Standards/AllSniffs.php @@ -41,8 +41,8 @@ public static function main() */ public static function suite() { - $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = array(); - $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = array(); + $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; + $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; $suite = new TestSuite('PHP CodeSniffer Standards'); @@ -51,7 +51,7 @@ public static function suite() // Optionally allow for ignoring the tests for one or more standards. $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS'); if ($ignoreTestsForStandards === false) { - $ignoreTestsForStandards = array(); + $ignoreTestsForStandards = []; } else { $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards); }