| @@ -21,7 +21,7 @@ discard block | ||
| 21 | 21 | */ | 
| 22 | 22 | public function register(): array | 
| 23 | 23 |      { | 
| 24 | - return [T_FUNCTION]; | |
| 24 | + return [ T_FUNCTION ]; | |
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | 27 | /** | 
| @@ -35,19 +35,19 @@ discard block | ||
| 35 | 35 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 36 | 36 |      { | 
| 37 | 37 | $tokens = $phpcsFile->getTokens(); | 
| 38 | - $token = $tokens[$stackPtr]; | |
| 38 | + $token = $tokens[ $stackPtr ]; | |
| 39 | 39 | |
| 40 | 40 | // Skip function without body. | 
| 41 | -        if (isset($token['scope_opener']) === false) { | |
| 41 | +        if (isset($token[ 'scope_opener' ]) === false) { | |
| 42 | 42 | return; | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | - $firstToken = $tokens[$token['scope_opener']]; | |
| 46 | - $lastToken = $tokens[$token['scope_closer']]; | |
| 47 | - $length = $lastToken['line'] - $firstToken['line']; | |
| 45 | + $firstToken = $tokens[ $token[ 'scope_opener' ] ]; | |
| 46 | + $lastToken = $tokens[ $token[ 'scope_closer' ] ]; | |
| 47 | + $length = $lastToken[ 'line' ] - $firstToken[ 'line' ]; | |
| 48 | 48 | |
| 49 | 49 |          if ($length > $this->maxLength) { | 
| 50 | - $tokenType = strtolower(substr($token['type'], 2)); | |
| 50 | + $tokenType = strtolower(substr($token[ 'type' ], 2)); | |
| 51 | 51 |              $error = "Function is {$length} lines. Must be {$this->maxLength} lines or fewer."; | 
| 52 | 52 |              $phpcsFile->addError($error, $stackPtr, sprintf('%sTooBig', ucfirst($tokenType))); | 
| 53 | 53 | } | 
| @@ -24,7 +24,7 @@ discard block | ||
| 24 | 24 | * It is increased inside try-catch blocks. | 
| 25 | 25 | * @var array | 
| 26 | 26 | */ | 
| 27 | - protected $relativeScopeLevels = []; | |
| 27 | + protected $relativeScopeLevels = [ ]; | |
| 28 | 28 | |
| 29 | 29 | /** | 
| 30 | 30 | * Returns the token types that this sniff is interested in. | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | */ | 
| 33 | 33 | public function register(): array | 
| 34 | 34 |      { | 
| 35 | - return [T_FUNCTION, T_CLOSURE, T_SWITCH]; | |
| 35 | + return [ T_FUNCTION, T_CLOSURE, T_SWITCH ]; | |
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 | /** | 
| @@ -46,11 +46,11 @@ discard block | ||
| 46 | 46 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 47 | 47 |      { | 
| 48 | 48 | $tokens = $phpcsFile->getTokens(); | 
| 49 | - $token = $tokens[$stackPtr]; | |
| 49 | + $token = $tokens[ $stackPtr ]; | |
| 50 | 50 | $this->maxIndentFound = 0; | 
| 51 | 51 | |
| 52 | 52 | // Ignore functions with no body | 
| 53 | -        if (isset($token['scope_opener']) === false) { | |
| 53 | +        if (isset($token[ 'scope_opener' ]) === false) { | |
| 54 | 54 | return; | 
| 55 | 55 | } | 
| 56 | 56 | |
| @@ -71,16 +71,16 @@ discard block | ||
| 71 | 71 | */ | 
| 72 | 72 | protected function inspectScope(array $token, array $tokens) | 
| 73 | 73 |      { | 
| 74 | - $start = $token['scope_opener']; | |
| 75 | - $length = $token['scope_closer'] - $start + 1; | |
| 74 | + $start = $token[ 'scope_opener' ]; | |
| 75 | + $length = $token[ 'scope_closer' ] - $start + 1; | |
| 76 | 76 | |
| 77 | 77 | $scope = array_slice($tokens, $start, $length, true); | 
| 78 | 78 | $scope = $this->removeTokenScopes($scope, 'T_SWITCH'); | 
| 79 | 79 | |
| 80 | - $this->setRelativeScopeLevels($scope, $scope[$start]['level']); | |
| 80 | + $this->setRelativeScopeLevels($scope, $scope[ $start ][ 'level' ]); | |
| 81 | 81 | |
| 82 | 82 |          foreach ($scope as $i => $token) { | 
| 83 | - $this->maxIndentFound = max($this->maxIndentFound, $token['level'] - $this->relativeScopeLevels[$i]); | |
| 83 | + $this->maxIndentFound = max($this->maxIndentFound, $token[ 'level' ] - $this->relativeScopeLevels[ $i ]); | |
| 84 | 84 | } | 
| 85 | 85 | } | 
| 86 | 86 | |
| @@ -95,16 +95,16 @@ discard block | ||
| 95 | 95 |      { | 
| 96 | 96 | // first set the base level for all tokens | 
| 97 | 97 |          foreach (array_keys($scope) as $i) { | 
| 98 | - $this->relativeScopeLevels[$i] = $level; | |
| 98 | + $this->relativeScopeLevels[ $i ] = $level; | |
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | 101 | // then increase the base level by one for all the tokens in a try-catch block | 
| 102 | 102 |          foreach (array_keys($this->findNestedTokens($scope, 'T_TRY')) as $i) { | 
| 103 | - $this->relativeScopeLevels[$i] += 1; | |
| 103 | + $this->relativeScopeLevels[ $i ] += 1; | |
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 |          foreach (array_keys($this->findNestedTokens($scope, 'T_CATCH')) as $i) { | 
| 107 | - $this->relativeScopeLevels[$i] += 1; | |
| 107 | + $this->relativeScopeLevels[ $i ] += 1; | |
| 108 | 108 | } | 
| 109 | 109 | } | 
| 110 | 110 | |
| @@ -127,13 +127,13 @@ discard block | ||
| 127 | 127 | */ | 
| 128 | 128 | protected function findNestedTokens(array $scope, string $type): array | 
| 129 | 129 |      { | 
| 130 | -        $typeTokens = array_filter($scope, function ($token) use ($type) { | |
| 131 | - return $token['type'] == $type; | |
| 130 | +        $typeTokens = array_filter($scope, function($token) use ($type) { | |
| 131 | + return $token[ 'type' ] == $type; | |
| 132 | 132 | }); | 
| 133 | 133 | |
| 134 | - $nestedTokens = []; | |
| 134 | + $nestedTokens = [ ]; | |
| 135 | 135 |          foreach ($typeTokens as $token) { | 
| 136 | - $range = array_flip(range($token['scope_opener'], $token['scope_closer'])); | |
| 136 | + $range = array_flip(range($token[ 'scope_opener' ], $token[ 'scope_closer' ])); | |
| 137 | 137 | $nestedTokens += array_intersect_key($scope, $range); | 
| 138 | 138 | } | 
| 139 | 139 | |
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | // indentation limit. | 
| 152 | 152 | $indentationFound = $this->maxIndentFound - 1; | 
| 153 | 153 | $indentationLimit = $this->indentationLimit - 1; | 
| 154 | -        return "{$indentationFound} indentation levels found. " . | |
| 154 | +        return "{$indentationFound} indentation levels found. ". | |
| 155 | 155 |          "Maximum of {$indentationLimit} indentation levels allowed."; | 
| 156 | 156 | } | 
| 157 | 157 | } | 
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | * The forbidden strings this sniff looks for. | 
| 13 | 13 | * @var array | 
| 14 | 14 | */ | 
| 15 | - protected $keywords = ['And', '_and', 'Or', '_or']; | |
| 15 | + protected $keywords = [ 'And', '_and', 'Or', '_or' ]; | |
| 16 | 16 | |
| 17 | 17 | /** | 
| 18 | 18 | * Returns the token types that this sniff is interested in. | 
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 | */ | 
| 21 | 21 | public function register(): array | 
| 22 | 22 |      { | 
| 23 | - return [T_FUNCTION]; | |
| 23 | + return [ T_FUNCTION ]; | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | /** | 
| @@ -34,14 +34,14 @@ discard block | ||
| 34 | 34 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 35 | 35 |      { | 
| 36 | 36 | $tokens = $phpcsFile->getTokens(); | 
| 37 | - $functionNameToken = $tokens[$stackPtr + 2]; | |
| 38 | - $functionName = $functionNameToken['content']; | |
| 37 | + $functionNameToken = $tokens[ $stackPtr + 2 ]; | |
| 38 | + $functionName = $functionNameToken[ 'content' ]; | |
| 39 | 39 | |
| 40 | -        if (! $this->containsKeywords($functionName)) { | |
| 40 | +        if (!$this->containsKeywords($functionName)) { | |
| 41 | 41 | return; | 
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | -        if (! $this->ensuingDelimiter($functionName)) { | |
| 44 | +        if (!$this->ensuingDelimiter($functionName)) { | |
| 45 | 45 | return; | 
| 46 | 46 | } | 
| 47 | 47 | |
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | protected function ensuingDelimiter(string $string): bool | 
| 74 | 74 |      { | 
| 75 | 75 |          foreach ($this->keywords as $keyword) { | 
| 76 | -            if (! $this->contains($keyword, $string)) { | |
| 76 | +            if (!$this->contains($keyword, $string)) { | |
| 77 | 77 | continue; | 
| 78 | 78 | } | 
| 79 | 79 | |
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | */ | 
| 15 | 15 | public function register(): array | 
| 16 | 16 |      { | 
| 17 | - return [T_ISSET]; | |
| 17 | + return [ T_ISSET ]; | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | /** | 
| @@ -49,15 +49,15 @@ discard block | ||
| 49 | 49 | $semiColinFound = false; | 
| 50 | 50 | |
| 51 | 51 |          while (true) { | 
| 52 | -            if ($tokens[$index]['type'] == 'T_SEMICOLON') { | |
| 52 | +            if ($tokens[ $index ][ 'type' ] == 'T_SEMICOLON') { | |
| 53 | 53 | break; | 
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | -            if ($tokens[$index]['type'] == 'T_INLINE_THEN') { | |
| 56 | +            if ($tokens[ $index ][ 'type' ] == 'T_INLINE_THEN') { | |
| 57 | 57 | $questionMarkFound = true; | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | -            if ($tokens[$index]['type'] == 'T_INLINE_ELSE') { | |
| 60 | +            if ($tokens[ $index ][ 'type' ] == 'T_INLINE_ELSE') { | |
| 61 | 61 | $semiColinFound = true; | 
| 62 | 62 | } | 
| 63 | 63 | $index++; | 
| @@ -12,19 +12,19 @@ discard block | ||
| 12 | 12 | * The decalred member variables in the class. | 
| 13 | 13 | * @var array | 
| 14 | 14 | */ | 
| 15 | - protected $memberVars = []; | |
| 15 | + protected $memberVars = [ ]; | |
| 16 | 16 | |
| 17 | 17 | /** | 
| 18 | 18 | * The referenced member variables in the class. | 
| 19 | 19 | * @var array | 
| 20 | 20 | */ | 
| 21 | - protected $referencedMemberVars = []; | |
| 21 | + protected $referencedMemberVars = [ ]; | |
| 22 | 22 | |
| 23 | 23 | /** | 
| 24 | 24 | * Visibility Tokens. | 
| 25 | 25 | * @var array | 
| 26 | 26 | */ | 
| 27 | - protected $visibilityTokens = ['T_PRIVATE', 'T_PUBLIC', 'T_PROTECTED']; | |
| 27 | + protected $visibilityTokens = [ 'T_PRIVATE', 'T_PUBLIC', 'T_PROTECTED' ]; | |
| 28 | 28 | |
| 29 | 29 | /** | 
| 30 | 30 | * Holds the value if the class is extended or not. | 
| @@ -38,7 +38,7 @@ discard block | ||
| 38 | 38 | */ | 
| 39 | 39 | public function register(): array | 
| 40 | 40 |      { | 
| 41 | - return [T_CLASS]; | |
| 41 | + return [ T_CLASS ]; | |
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 | /** | 
| @@ -52,8 +52,8 @@ discard block | ||
| 52 | 52 | */ | 
| 53 | 53 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 54 | 54 |      { | 
| 55 | - $this->memberVars = []; | |
| 56 | - $this->referencedMemberVars = []; | |
| 55 | + $this->memberVars = [ ]; | |
| 56 | + $this->referencedMemberVars = [ ]; | |
| 57 | 57 | $tokens = $phpcsFile->getTokens(); | 
| 58 | 58 |          foreach ($tokens as $index => $token) { | 
| 59 | 59 | $this->handleToken($tokens, $index); | 
| @@ -74,9 +74,9 @@ discard block | ||
| 74 | 74 | */ | 
| 75 | 75 | protected function handleToken($tokens, $index) | 
| 76 | 76 |      { | 
| 77 | - $token = $tokens[$index]; | |
| 77 | + $token = $tokens[ $index ]; | |
| 78 | 78 | |
| 79 | -        if ($token['type'] === 'T_EXTENDS') { | |
| 79 | +        if ($token[ 'type' ] === 'T_EXTENDS') { | |
| 80 | 80 | $this->isExtendedClass = true; | 
| 81 | 81 | return; | 
| 82 | 82 | } | 
| @@ -87,7 +87,7 @@ discard block | ||
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 | |
| 90 | -        if ($token['type'] === 'T_OBJECT_OPERATOR') { | |
| 90 | +        if ($token[ 'type' ] === 'T_OBJECT_OPERATOR') { | |
| 91 | 91 | $this->handleObjectOperatorToken($tokens, $index); | 
| 92 | 92 | return; | 
| 93 | 93 | } | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | */ | 
| 101 | 101 | protected function isVisibilityToken($token): bool | 
| 102 | 102 |      { | 
| 103 | - return in_array($token['type'], $this->visibilityTokens); | |
| 103 | + return in_array($token[ 'type' ], $this->visibilityTokens); | |
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 | /** | 
| @@ -111,11 +111,11 @@ discard block | ||
| 111 | 111 | */ | 
| 112 | 112 | protected function handleVisibilityToken($tokens, $index) | 
| 113 | 113 |      { | 
| 114 | - $possibleVariable = $tokens[$index + 2]; | |
| 115 | -        if ($possibleVariable['type'] !== 'T_VARIABLE') { | |
| 114 | + $possibleVariable = $tokens[ $index + 2 ]; | |
| 115 | +        if ($possibleVariable[ 'type' ] !== 'T_VARIABLE') { | |
| 116 | 116 | return; | 
| 117 | 117 | } | 
| 118 | -        $this->memberVars[] = str_replace('$', '', $possibleVariable['content']); | |
| 118 | +        $this->memberVars[ ] = str_replace('$', '', $possibleVariable[ 'content' ]); | |
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | 121 | /** | 
| @@ -126,19 +126,19 @@ discard block | ||
| 126 | 126 | */ | 
| 127 | 127 | protected function handleObjectOperatorToken($tokens, $index) | 
| 128 | 128 |      { | 
| 129 | - $previousToken = $tokens[$index-1]; | |
| 130 | - $nextToken = $tokens[$index+1]; | |
| 131 | - $tokenAfterNext = $tokens[$index+2]; | |
| 129 | + $previousToken = $tokens[ $index - 1 ]; | |
| 130 | + $nextToken = $tokens[ $index + 1 ]; | |
| 131 | + $tokenAfterNext = $tokens[ $index + 2 ]; | |
| 132 | 132 | |
| 133 | -        if ($previousToken['content'] !== '$this') { | |
| 133 | +        if ($previousToken[ 'content' ] !== '$this') { | |
| 134 | 134 | return; | 
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | -        if (($tokenAfterNext['type'] !== 'T_WHITESPACE') && ($tokenAfterNext['type'] !== 'T_EQUAL')) { | |
| 137 | +        if (($tokenAfterNext[ 'type' ] !== 'T_WHITESPACE') && ($tokenAfterNext[ 'type' ] !== 'T_EQUAL')) { | |
| 138 | 138 | return; | 
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | - $this->referencedMemberVars[] = $nextToken['content']; | |
| 141 | + $this->referencedMemberVars[ ] = $nextToken[ 'content' ]; | |
| 142 | 142 | } | 
| 143 | 143 | |
| 144 | 144 | /** | 
| @@ -18,7 +18,7 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | public function register(): array | 
| 20 | 20 |      { | 
| 21 | - return [T_FUNCTION]; | |
| 21 | + return [ T_FUNCTION ]; | |
| 22 | 22 | } | 
| 23 | 23 | |
| 24 | 24 | /** | 
| @@ -36,11 +36,11 @@ discard block | ||
| 36 | 36 | |
| 37 | 37 | $commentEnd = $this->findCommentEnd($phpcsFile, $stackPtr, $tokens); | 
| 38 | 38 | |
| 39 | -        if (empty($tokens[$commentEnd]['comment_opener'])) { | |
| 39 | +        if (empty($tokens[ $commentEnd ][ 'comment_opener' ])) { | |
| 40 | 40 | return; | 
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | - $commentStart = $tokens[$commentEnd]['comment_opener']; | |
| 43 | + $commentStart = $tokens[ $commentEnd ][ 'comment_opener' ]; | |
| 44 | 44 | |
| 45 | 45 | $this->processReturn($phpcsFile, $commentStart); | 
| 46 | 46 | } | 
| @@ -86,8 +86,8 @@ discard block | ||
| 86 | 86 | */ | 
| 87 | 87 | private function findReturnTag(array $tokens, int $commentStart) | 
| 88 | 88 |      { | 
| 89 | -        return array_reduce($tokens[$commentStart]['comment_tags'], function ($carry, $tag) use ($tokens) { | |
| 90 | - return $carry || ($tokens[$tag]['content'] === self::RETURN_TAG_NAME) ? $tag : false; | |
| 89 | +        return array_reduce($tokens[ $commentStart ][ 'comment_tags' ], function($carry, $tag) use ($tokens) { | |
| 90 | + return $carry || ($tokens[ $tag ][ 'content' ] === self::RETURN_TAG_NAME) ? $tag : false; | |
| 91 | 91 | }, false); | 
| 92 | 92 | } | 
| 93 | 93 | |
| @@ -99,11 +99,11 @@ discard block | ||
| 99 | 99 | */ | 
| 100 | 100 | private function parseTagForReturnType(array $tokens, int $returnPosition) | 
| 101 | 101 |      { | 
| 102 | - $content = $tokens[$returnPosition + 2]['content']; | |
| 102 | + $content = $tokens[ $returnPosition + 2 ][ 'content' ]; | |
| 103 | 103 | // Support both a return type and a description. | 
| 104 | 104 |          preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $content, $returnParts); | 
| 105 | 105 | |
| 106 | - return $returnParts[1] ?? false; | |
| 106 | + return $returnParts[ 1 ] ?? false; | |
| 107 | 107 | } | 
| 108 | 108 | |
| 109 | 109 | /** | 
| @@ -116,10 +116,10 @@ discard block | ||
| 116 | 116 | */ | 
| 117 | 117 | private function findCommentEnd(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $tokens) | 
| 118 | 118 |      { | 
| 119 | - $find = PHP_CodeSniffer_Tokens::$methodPrefixes + [T_WHITESPACE]; | |
| 119 | + $find = PHP_CodeSniffer_Tokens::$methodPrefixes + [ T_WHITESPACE ]; | |
| 120 | 120 | |
| 121 | 121 | $commentEnd = $phpcsFile->findPrevious($find, $stackPtr - 1, null, true); | 
| 122 | -        if ($tokens[$commentEnd]['code'] !== T_COMMENT) { | |
| 122 | +        if ($tokens[ $commentEnd ][ 'code' ] !== T_COMMENT) { | |
| 123 | 123 | return $commentEnd; | 
| 124 | 124 | } | 
| 125 | 125 | |
| @@ -128,7 +128,7 @@ discard block | ||
| 128 | 128 | // using the wrong comment type. If there is other code on the line, | 
| 129 | 129 | // assume they relate to that code. | 
| 130 | 130 | $prev = $phpcsFile->findPrevious($find, $commentEnd - 1, null, true); | 
| 131 | -        if ($prev !== false && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) { | |
| 131 | +        if ($prev !== false && $tokens[ $prev ][ 'line' ] === $tokens[ $commentEnd ][ 'line' ]) { | |
| 132 | 132 | $commentEnd = $prev; | 
| 133 | 133 | } | 
| 134 | 134 | |
| @@ -19,7 +19,7 @@ discard block | ||
| 19 | 19 | */ | 
| 20 | 20 | public function register(): array | 
| 21 | 21 |      { | 
| 22 | - return [T_CLASS]; | |
| 22 | + return [ T_CLASS ]; | |
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | 25 | /** | 
| @@ -46,10 +46,10 @@ discard block | ||
| 46 | 46 | */ | 
| 47 | 47 | protected function handleToken($token) | 
| 48 | 48 |      { | 
| 49 | -        if ($token['type'] !== 'T_EXTENDS') { | |
| 49 | +        if ($token[ 'type' ] !== 'T_EXTENDS') { | |
| 50 | 50 | return; | 
| 51 | 51 | } | 
| 52 | 52 | $warning = "Class extends another class - consider composition over inheritance."; | 
| 53 | - $this->phpcsFile->addWarning($warning, $token['line'], __CLASS__); | |
| 53 | + $this->phpcsFile->addWarning($warning, $token[ 'line' ], __CLASS__); | |
| 54 | 54 | } | 
| 55 | 55 | } | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | */ | 
| 17 | 17 | public function register(): array | 
| 18 | 18 |      { | 
| 19 | - return [T_CLASS]; | |
| 19 | + return [ T_CLASS ]; | |
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | 22 | /** | 
| @@ -29,13 +29,13 @@ discard block | ||
| 29 | 29 | * List of protected methods found. | 
| 30 | 30 | * @var array | 
| 31 | 31 | */ | 
| 32 | - protected $protectedMethodTokens = []; | |
| 32 | + protected $protectedMethodTokens = [ ]; | |
| 33 | 33 | |
| 34 | 34 | /** | 
| 35 | 35 | * List of protected variables found. | 
| 36 | 36 | * @var array | 
| 37 | 37 | */ | 
| 38 | - protected $protectedVariableTokens = []; | |
| 38 | + protected $protectedVariableTokens = [ ]; | |
| 39 | 39 | |
| 40 | 40 | /** | 
| 41 | 41 | * Processes the tokens that this sniff is interested in. | 
| @@ -49,8 +49,8 @@ discard block | ||
| 49 | 49 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 50 | 50 |      { | 
| 51 | 51 | $this->classIsMarkedFinal = false; | 
| 52 | - $this->protectedMethodTokens = []; | |
| 53 | - $this->protectedVariableTokens = []; | |
| 52 | + $this->protectedMethodTokens = [ ]; | |
| 53 | + $this->protectedVariableTokens = [ ]; | |
| 54 | 54 | |
| 55 | 55 | $tokens = $phpcsFile->getTokens(); | 
| 56 | 56 | |
| @@ -69,14 +69,14 @@ discard block | ||
| 69 | 69 | */ | 
| 70 | 70 | protected function handleToken($tokens, $index) | 
| 71 | 71 |      { | 
| 72 | - $tokenType = $tokens[$index]['type']; | |
| 72 | + $tokenType = $tokens[ $index ][ 'type' ]; | |
| 73 | 73 | |
| 74 | 74 |          if ($tokenType === 'T_FINAL') { | 
| 75 | 75 | $this->classIsMarkedFinal = true; | 
| 76 | 76 | return; | 
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | -        if (! $this->classIsMarkedFinal) { | |
| 79 | +        if (!$this->classIsMarkedFinal) { | |
| 80 | 80 | return; | 
| 81 | 81 | } | 
| 82 | 82 | |
| @@ -96,14 +96,14 @@ discard block | ||
| 96 | 96 | */ | 
| 97 | 97 | protected function handleFoundProtectedElement($tokens, $index) | 
| 98 | 98 |      { | 
| 99 | - $type = $tokens[$index+2]['type']; | |
| 99 | + $type = $tokens[ $index + 2 ][ 'type' ]; | |
| 100 | 100 | |
| 101 | 101 |          if ($type === 'T_VARIABLE') { | 
| 102 | - $this->protectedVariableTokens[] = $tokens[$index+2]; | |
| 102 | + $this->protectedVariableTokens[ ] = $tokens[ $index + 2 ]; | |
| 103 | 103 | return; | 
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | - $this->protectedMethodTokens[] = $tokens[$index+4]; | |
| 106 | + $this->protectedMethodTokens[ ] = $tokens[ $index + 4 ]; | |
| 107 | 107 | } | 
| 108 | 108 | |
| 109 | 109 | /** | 
| @@ -131,8 +131,8 @@ discard block | ||
| 131 | 131 | */ | 
| 132 | 132 | protected function handleProtectedMethodToken($token, $phpcsFile) | 
| 133 | 133 |      { | 
| 134 | - $methodName = $token['content']; | |
| 135 | - $line = $token['line']; | |
| 134 | + $methodName = $token[ 'content' ]; | |
| 135 | + $line = $token[ 'line' ]; | |
| 136 | 136 |          $phpcsFile->addError("Final Class contains a protected method {$methodName} - should be private.", $line, __CLASS__); | 
| 137 | 137 | } | 
| 138 | 138 | |
| @@ -144,8 +144,8 @@ discard block | ||
| 144 | 144 | */ | 
| 145 | 145 | protected function handleProtectedVariableToken($token, $phpcsFile) | 
| 146 | 146 |      { | 
| 147 | - $variableName = $token['content']; | |
| 148 | - $line = $token['line']; | |
| 147 | + $variableName = $token[ 'content' ]; | |
| 148 | + $line = $token[ 'line' ]; | |
| 149 | 149 |          $phpcsFile->addError("Final Class contains a protected variable {$variableName} - should be private.", $line, __CLASS__); | 
| 150 | 150 | } | 
| 151 | 151 | } | 
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | * The loop tokens we're lookin for. | 
| 13 | 13 | * @var array | 
| 14 | 14 | */ | 
| 15 | - protected $loops = ['T_FOR', 'T_FOREACH', 'T_WHILE']; | |
| 15 | + protected $loops = [ 'T_FOR', 'T_FOREACH', 'T_WHILE' ]; | |
| 16 | 16 | |
| 17 | 17 | /** | 
| 18 | 18 | * Returns the token types that this sniff is interested in. | 
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 | */ | 
| 21 | 21 | public function register(): array | 
| 22 | 22 |      { | 
| 23 | - return [T_FUNCTION]; | |
| 23 | + return [ T_FUNCTION ]; | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | /** | 
| @@ -34,20 +34,20 @@ discard block | ||
| 34 | 34 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 
| 35 | 35 |      { | 
| 36 | 36 | $tokens = $phpcsFile->getTokens(); | 
| 37 | - $token = $tokens[$stackPtr]; | |
| 38 | - $functionNameToken = $tokens[$stackPtr + 2]; | |
| 39 | - $functionName = $functionNameToken['content']; | |
| 37 | + $token = $tokens[ $stackPtr ]; | |
| 38 | + $functionNameToken = $tokens[ $stackPtr + 2 ]; | |
| 39 | + $functionName = $functionNameToken[ 'content' ]; | |
| 40 | 40 | |
| 41 | 41 |          if ($functionName !== '__construct') { | 
| 42 | 42 | return; | 
| 43 | 43 | } | 
| 44 | 44 | // If this is an interface we don't check it. | 
| 45 | -        if (! isset($token['scope_opener'])) { | |
| 45 | +        if (!isset($token[ 'scope_opener' ])) { | |
| 46 | 46 | return; | 
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | -        for ($index=$token['scope_opener']; $index <= $token['scope_closer']; $index++) { | |
| 50 | -            if (in_array($tokens[$index]['type'], $this->loops)) { | |
| 49 | +        for ($index = $token[ 'scope_opener' ]; $index <= $token[ 'scope_closer' ]; $index++) { | |
| 50 | +            if (in_array($tokens[ $index ][ 'type' ], $this->loops)) { | |
| 51 | 51 |                  $phpcsFile->addError("Class constructor cannot contain a loop.", $stackPtr, __CLASS__); | 
| 52 | 52 | continue; | 
| 53 | 53 | } |