@@ -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() |
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 ($scope as $i => $token) { |
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, $type) |
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 | } |