@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public function register() |
71 | 71 | { |
72 | 72 | // Handle case-insensitivity of function names. |
73 | - $this->targetFunctions = $this->arrayKeysToLowercase($this->targetFunctions); |
|
73 | + $this->targetFunctions = $this->arrayKeysToLowercase( $this->targetFunctions ); |
|
74 | 74 | |
75 | - return array(\T_STRING); |
|
75 | + return array( \T_STRING ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -86,49 +86,49 @@ discard block |
||
86 | 86 | * @return int|void Integer stack pointer to skip forward or void to continue |
87 | 87 | * normal file processing. |
88 | 88 | */ |
89 | - public function process(File $phpcsFile, $stackPtr) |
|
89 | + public function process( File $phpcsFile, $stackPtr ) |
|
90 | 90 | { |
91 | - if ($this->bowOutEarly() === true) { |
|
91 | + if ( $this->bowOutEarly() === true ) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $tokens = $phpcsFile->getTokens(); |
96 | - $function = $tokens[$stackPtr]['content']; |
|
97 | - $functionLc = strtolower($function); |
|
96 | + $function = $tokens[ $stackPtr ][ 'content' ]; |
|
97 | + $functionLc = strtolower( $function ); |
|
98 | 98 | |
99 | - if (isset($this->targetFunctions[$functionLc]) === false) { |
|
99 | + if ( isset( $this->targetFunctions[ $functionLc ] ) === false ) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
|
103 | + $prevNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true ); |
|
104 | 104 | |
105 | - if ($this->isMethod === true) { |
|
106 | - if ($tokens[$prevNonEmpty]['code'] !== \T_DOUBLE_COLON |
|
107 | - && $tokens[$prevNonEmpty]['code'] !== \T_OBJECT_OPERATOR |
|
105 | + if ( $this->isMethod === true ) { |
|
106 | + if ( $tokens[ $prevNonEmpty ][ 'code' ] !== \T_DOUBLE_COLON |
|
107 | + && $tokens[ $prevNonEmpty ][ 'code' ] !== \T_OBJECT_OPERATOR |
|
108 | 108 | ) { |
109 | 109 | // Not a call to a PHP method. |
110 | 110 | return; |
111 | 111 | } |
112 | 112 | } else { |
113 | - if (isset($this->ignoreTokens[$tokens[$prevNonEmpty]['code']]) === true) { |
|
113 | + if ( isset( $this->ignoreTokens[ $tokens[ $prevNonEmpty ][ 'code' ] ] ) === true ) { |
|
114 | 114 | // Not a call to a PHP function. |
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - if ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR |
|
119 | - && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING |
|
118 | + if ( $tokens[ $prevNonEmpty ][ 'code' ] === \T_NS_SEPARATOR |
|
119 | + && $tokens[ $prevNonEmpty - 1 ][ 'code' ] === \T_STRING |
|
120 | 120 | ) { |
121 | 121 | // Namespaced function. |
122 | 122 | return; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - $parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr); |
|
126 | + $parameters = $this->getFunctionCallParameters( $phpcsFile, $stackPtr ); |
|
127 | 127 | |
128 | - if (empty($parameters)) { |
|
129 | - return $this->processNoParameters($phpcsFile, $stackPtr, $function); |
|
128 | + if ( empty( $parameters ) ) { |
|
129 | + return $this->processNoParameters( $phpcsFile, $stackPtr, $function ); |
|
130 | 130 | } else { |
131 | - return $this->processParameters($phpcsFile, $stackPtr, $function, $parameters); |
|
131 | + return $this->processParameters( $phpcsFile, $stackPtr, $function, $parameters ); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return int|void Integer stack pointer to skip forward or void to continue |
158 | 158 | * normal file processing. |
159 | 159 | */ |
160 | - abstract public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters); |
|
160 | + abstract public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters ); |
|
161 | 161 | |
162 | 162 | |
163 | 163 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return int|void Integer stack pointer to skip forward or void to continue |
174 | 174 | * normal file processing. |
175 | 175 | */ |
176 | - public function processNoParameters(File $phpcsFile, $stackPtr, $functionName) |
|
176 | + public function processNoParameters( File $phpcsFile, $stackPtr, $functionName ) |
|
177 | 177 | { |
178 | 178 | return; |
179 | 179 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function getVersion() |
39 | 39 | { |
40 | - if (\defined('\PHP_CodeSniffer\Config::VERSION')) { |
|
40 | + if ( \defined( '\PHP_CodeSniffer\Config::VERSION' ) ) { |
|
41 | 41 | // PHPCS 3.x. |
42 | 42 | return \PHP_CodeSniffer\Config::VERSION; |
43 | 43 | } else { |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public static function setConfigData($key, $value, $temp = false) |
|
63 | + public static function setConfigData( $key, $value, $temp = false ) |
|
64 | 64 | { |
65 | - if (method_exists('\PHP_CodeSniffer\Config', 'setConfigData')) { |
|
65 | + if ( method_exists( '\PHP_CodeSniffer\Config', 'setConfigData' ) ) { |
|
66 | 66 | // PHPCS 3.x. |
67 | - \PHP_CodeSniffer\Config::setConfigData($key, $value, $temp); |
|
67 | + \PHP_CodeSniffer\Config::setConfigData( $key, $value, $temp ); |
|
68 | 68 | } else { |
69 | 69 | // PHPCS 2.x. |
70 | - \PHP_CodeSniffer::setConfigData($key, $value, $temp); |
|
70 | + \PHP_CodeSniffer::setConfigData( $key, $value, $temp ); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string|null |
81 | 81 | */ |
82 | - public static function getConfigData($key) |
|
82 | + public static function getConfigData( $key ) |
|
83 | 83 | { |
84 | - if (method_exists('\PHP_CodeSniffer\Config', 'getConfigData')) { |
|
84 | + if ( method_exists( '\PHP_CodeSniffer\Config', 'getConfigData' ) ) { |
|
85 | 85 | // PHPCS 3.x. |
86 | - return \PHP_CodeSniffer\Config::getConfigData($key); |
|
86 | + return \PHP_CodeSniffer\Config::getConfigData( $key ); |
|
87 | 87 | } else { |
88 | 88 | // PHPCS 2.x. |
89 | - return \PHP_CodeSniffer::getConfigData($key); |
|
89 | + return \PHP_CodeSniffer::getConfigData( $key ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return string|null |
104 | 104 | */ |
105 | - public static function getCommandLineData(File $phpcsFile, $key) |
|
105 | + public static function getCommandLineData( File $phpcsFile, $key ) |
|
106 | 106 | { |
107 | - if (class_exists('\PHP_CodeSniffer\Config')) { |
|
107 | + if ( class_exists( '\PHP_CodeSniffer\Config' ) ) { |
|
108 | 108 | // PHPCS 3.x. |
109 | 109 | $config = $phpcsFile->config; |
110 | - if (isset($config->{$key})) { |
|
110 | + if ( isset( $config->{$key}) ) { |
|
111 | 111 | return $config->{$key}; |
112 | 112 | } |
113 | 113 | } else { |
114 | 114 | // PHPCS 2.x. |
115 | 115 | $config = $phpcsFile->phpcs->cli->getCommandLineValues(); |
116 | - if (isset($config[$key])) { |
|
117 | - return $config[$key]; |
|
116 | + if ( isset( $config[ $key ] ) ) { |
|
117 | + return $config[ $key ]; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -140,59 +140,59 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return int |
142 | 142 | */ |
143 | - public static function findStartOfStatement(File $phpcsFile, $start, $ignore = null) |
|
143 | + public static function findStartOfStatement( File $phpcsFile, $start, $ignore = null ) |
|
144 | 144 | { |
145 | - if (version_compare(self::getVersion(), '2.7.1', '>=') === true) { |
|
146 | - return $phpcsFile->findStartOfStatement($start, $ignore); |
|
145 | + if ( version_compare( self::getVersion(), '2.7.1', '>=' ) === true ) { |
|
146 | + return $phpcsFile->findStartOfStatement( $start, $ignore ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $tokens = $phpcsFile->getTokens(); |
150 | 150 | $endTokens = Tokens::$blockOpeners; |
151 | 151 | |
152 | - $endTokens[\T_COLON] = true; |
|
153 | - $endTokens[\T_COMMA] = true; |
|
154 | - $endTokens[\T_DOUBLE_ARROW] = true; |
|
155 | - $endTokens[\T_SEMICOLON] = true; |
|
156 | - $endTokens[\T_OPEN_TAG] = true; |
|
157 | - $endTokens[\T_CLOSE_TAG] = true; |
|
158 | - $endTokens[\T_OPEN_SHORT_ARRAY] = true; |
|
159 | - |
|
160 | - if ($ignore !== null) { |
|
161 | - $ignore = (array) $ignore; |
|
162 | - foreach ($ignore as $code) { |
|
163 | - if (isset($endTokens[$code]) === true) { |
|
164 | - unset($endTokens[$code]); |
|
152 | + $endTokens[ \T_COLON ] = true; |
|
153 | + $endTokens[ \T_COMMA ] = true; |
|
154 | + $endTokens[ \T_DOUBLE_ARROW ] = true; |
|
155 | + $endTokens[ \T_SEMICOLON ] = true; |
|
156 | + $endTokens[ \T_OPEN_TAG ] = true; |
|
157 | + $endTokens[ \T_CLOSE_TAG ] = true; |
|
158 | + $endTokens[ \T_OPEN_SHORT_ARRAY ] = true; |
|
159 | + |
|
160 | + if ( $ignore !== null ) { |
|
161 | + $ignore = (array)$ignore; |
|
162 | + foreach ( $ignore as $code ) { |
|
163 | + if ( isset( $endTokens[ $code ] ) === true ) { |
|
164 | + unset( $endTokens[ $code ] ); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | $lastNotEmpty = $start; |
170 | 170 | |
171 | - for ($i = $start; $i >= 0; $i--) { |
|
172 | - if (isset($endTokens[$tokens[$i]['code']]) === true) { |
|
171 | + for ( $i = $start; $i >= 0; $i-- ) { |
|
172 | + if ( isset( $endTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) { |
|
173 | 173 | // Found the end of the previous statement. |
174 | 174 | return $lastNotEmpty; |
175 | 175 | } |
176 | 176 | |
177 | - if (isset($tokens[$i]['scope_opener']) === true |
|
178 | - && $i === $tokens[$i]['scope_closer'] |
|
177 | + if ( isset( $tokens[ $i ][ 'scope_opener' ] ) === true |
|
178 | + && $i === $tokens[ $i ][ 'scope_closer' ] |
|
179 | 179 | ) { |
180 | 180 | // Found the end of the previous scope block. |
181 | 181 | return $lastNotEmpty; |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Skip nested statements. |
185 | - if (isset($tokens[$i]['bracket_opener']) === true |
|
186 | - && $i === $tokens[$i]['bracket_closer'] |
|
185 | + if ( isset( $tokens[ $i ][ 'bracket_opener' ] ) === true |
|
186 | + && $i === $tokens[ $i ][ 'bracket_closer' ] |
|
187 | 187 | ) { |
188 | - $i = $tokens[$i]['bracket_opener']; |
|
189 | - } elseif (isset($tokens[$i]['parenthesis_opener']) === true |
|
190 | - && $i === $tokens[$i]['parenthesis_closer'] |
|
188 | + $i = $tokens[ $i ][ 'bracket_opener' ]; |
|
189 | + } elseif ( isset( $tokens[ $i ][ 'parenthesis_opener' ] ) === true |
|
190 | + && $i === $tokens[ $i ][ 'parenthesis_closer' ] |
|
191 | 191 | ) { |
192 | - $i = $tokens[$i]['parenthesis_opener']; |
|
192 | + $i = $tokens[ $i ][ 'parenthesis_opener' ]; |
|
193 | 193 | } |
194 | 194 | |
195 | - if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) { |
|
195 | + if ( isset( Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) { |
|
196 | 196 | $lastNotEmpty = $i; |
197 | 197 | } |
198 | 198 | }//end for |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return int |
221 | 221 | */ |
222 | - public static function findEndOfStatement(File $phpcsFile, $start, $ignore = null) |
|
222 | + public static function findEndOfStatement( File $phpcsFile, $start, $ignore = null ) |
|
223 | 223 | { |
224 | - if (version_compare(self::getVersion(), '3.3.0', '>=') === true) { |
|
225 | - return $phpcsFile->findEndOfStatement($start, $ignore); |
|
224 | + if ( version_compare( self::getVersion(), '3.3.0', '>=' ) === true ) { |
|
225 | + return $phpcsFile->findEndOfStatement( $start, $ignore ); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | $tokens = $phpcsFile->getTokens(); |
@@ -239,26 +239,26 @@ discard block |
||
239 | 239 | \T_CLOSE_TAG => true, |
240 | 240 | ); |
241 | 241 | |
242 | - if ($ignore !== null) { |
|
243 | - $ignore = (array) $ignore; |
|
244 | - foreach ($ignore as $code) { |
|
245 | - if (isset($endTokens[$code]) === true) { |
|
246 | - unset($endTokens[$code]); |
|
242 | + if ( $ignore !== null ) { |
|
243 | + $ignore = (array)$ignore; |
|
244 | + foreach ( $ignore as $code ) { |
|
245 | + if ( isset( $endTokens[ $code ] ) === true ) { |
|
246 | + unset( $endTokens[ $code ] ); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | $lastNotEmpty = $start; |
252 | 252 | |
253 | - for ($i = $start; $i < $phpcsFile->numTokens; $i++) { |
|
254 | - if ($i !== $start && isset($endTokens[$tokens[$i]['code']]) === true) { |
|
253 | + for ( $i = $start; $i < $phpcsFile->numTokens; $i++ ) { |
|
254 | + if ( $i !== $start && isset( $endTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) { |
|
255 | 255 | // Found the end of the statement. |
256 | - if ($tokens[$i]['code'] === \T_CLOSE_PARENTHESIS |
|
257 | - || $tokens[$i]['code'] === \T_CLOSE_SQUARE_BRACKET |
|
258 | - || $tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET |
|
259 | - || $tokens[$i]['code'] === \T_CLOSE_SHORT_ARRAY |
|
260 | - || $tokens[$i]['code'] === \T_OPEN_TAG |
|
261 | - || $tokens[$i]['code'] === \T_CLOSE_TAG |
|
256 | + if ( $tokens[ $i ][ 'code' ] === \T_CLOSE_PARENTHESIS |
|
257 | + || $tokens[ $i ][ 'code' ] === \T_CLOSE_SQUARE_BRACKET |
|
258 | + || $tokens[ $i ][ 'code' ] === \T_CLOSE_CURLY_BRACKET |
|
259 | + || $tokens[ $i ][ 'code' ] === \T_CLOSE_SHORT_ARRAY |
|
260 | + || $tokens[ $i ][ 'code' ] === \T_OPEN_TAG |
|
261 | + || $tokens[ $i ][ 'code' ] === \T_CLOSE_TAG |
|
262 | 262 | ) { |
263 | 263 | return $lastNotEmpty; |
264 | 264 | } |
@@ -267,31 +267,31 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | // Skip nested statements. |
270 | - if (isset($tokens[$i]['scope_closer']) === true |
|
271 | - && ($i === $tokens[$i]['scope_opener'] |
|
272 | - || $i === $tokens[$i]['scope_condition']) |
|
270 | + if ( isset( $tokens[ $i ][ 'scope_closer' ] ) === true |
|
271 | + && ( $i === $tokens[ $i ][ 'scope_opener' ] |
|
272 | + || $i === $tokens[ $i ][ 'scope_condition' ] ) |
|
273 | 273 | ) { |
274 | - if ($i === $start && isset(Tokens::$scopeOpeners[$tokens[$i]['code']]) === true) { |
|
275 | - return $tokens[$i]['scope_closer']; |
|
274 | + if ( $i === $start && isset( Tokens::$scopeOpeners[ $tokens[ $i ][ 'code' ] ] ) === true ) { |
|
275 | + return $tokens[ $i ][ 'scope_closer' ]; |
|
276 | 276 | } |
277 | 277 | |
278 | - $i = $tokens[$i]['scope_closer']; |
|
279 | - } elseif (isset($tokens[$i]['bracket_closer']) === true |
|
280 | - && $i === $tokens[$i]['bracket_opener'] |
|
278 | + $i = $tokens[ $i ][ 'scope_closer' ]; |
|
279 | + } elseif ( isset( $tokens[ $i ][ 'bracket_closer' ] ) === true |
|
280 | + && $i === $tokens[ $i ][ 'bracket_opener' ] |
|
281 | 281 | ) { |
282 | - $i = $tokens[$i]['bracket_closer']; |
|
283 | - } elseif (isset($tokens[$i]['parenthesis_closer']) === true |
|
284 | - && $i === $tokens[$i]['parenthesis_opener'] |
|
282 | + $i = $tokens[ $i ][ 'bracket_closer' ]; |
|
283 | + } elseif ( isset( $tokens[ $i ][ 'parenthesis_closer' ] ) === true |
|
284 | + && $i === $tokens[ $i ][ 'parenthesis_opener' ] |
|
285 | 285 | ) { |
286 | - $i = $tokens[$i]['parenthesis_closer']; |
|
286 | + $i = $tokens[ $i ][ 'parenthesis_closer' ]; |
|
287 | 287 | } |
288 | 288 | |
289 | - if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) { |
|
289 | + if ( isset( Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) { |
|
290 | 290 | $lastNotEmpty = $i; |
291 | 291 | } |
292 | 292 | }//end for |
293 | 293 | |
294 | - return ($phpcsFile->numTokens - 1); |
|
294 | + return ( $phpcsFile->numTokens - 1 ); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -317,33 +317,33 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string|false |
319 | 319 | */ |
320 | - public static function findExtendedClassName(File $phpcsFile, $stackPtr) |
|
320 | + public static function findExtendedClassName( File $phpcsFile, $stackPtr ) |
|
321 | 321 | { |
322 | - if (version_compare(self::getVersion(), '3.1.0', '>=') === true) { |
|
323 | - return $phpcsFile->findExtendedClassName($stackPtr); |
|
322 | + if ( version_compare( self::getVersion(), '3.1.0', '>=' ) === true ) { |
|
323 | + return $phpcsFile->findExtendedClassName( $stackPtr ); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | $tokens = $phpcsFile->getTokens(); |
327 | 327 | |
328 | 328 | // Check for the existence of the token. |
329 | - if (isset($tokens[$stackPtr]) === false) { |
|
329 | + if ( isset( $tokens[ $stackPtr ] ) === false ) { |
|
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | |
333 | - if ($tokens[$stackPtr]['code'] !== \T_CLASS |
|
334 | - && $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS' |
|
335 | - && $tokens[$stackPtr]['type'] !== 'T_INTERFACE' |
|
333 | + if ( $tokens[ $stackPtr ][ 'code' ] !== \T_CLASS |
|
334 | + && $tokens[ $stackPtr ][ 'type' ] !== 'T_ANON_CLASS' |
|
335 | + && $tokens[ $stackPtr ][ 'type' ] !== 'T_INTERFACE' |
|
336 | 336 | ) { |
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | - if (isset($tokens[$stackPtr]['scope_closer']) === false) { |
|
340 | + if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | |
344 | - $classCloserIndex = $tokens[$stackPtr]['scope_closer']; |
|
345 | - $extendsIndex = $phpcsFile->findNext(\T_EXTENDS, $stackPtr, $classCloserIndex); |
|
346 | - if ($extendsIndex === false) { |
|
344 | + $classCloserIndex = $tokens[ $stackPtr ][ 'scope_closer' ]; |
|
345 | + $extendsIndex = $phpcsFile->findNext( \T_EXTENDS, $stackPtr, $classCloserIndex ); |
|
346 | + if ( $extendsIndex === false ) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | \T_WHITESPACE, |
354 | 354 | ); |
355 | 355 | |
356 | - $end = $phpcsFile->findNext($find, ($extendsIndex + 1), $classCloserIndex, true); |
|
357 | - $name = $phpcsFile->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1)); |
|
358 | - $name = trim($name); |
|
356 | + $end = $phpcsFile->findNext( $find, ( $extendsIndex + 1 ), $classCloserIndex, true ); |
|
357 | + $name = $phpcsFile->getTokensAsString( ( $extendsIndex + 1 ), ( $end - $extendsIndex - 1 ) ); |
|
358 | + $name = trim( $name ); |
|
359 | 359 | |
360 | - if ($name === '') { |
|
360 | + if ( $name === '' ) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
@@ -382,32 +382,32 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return array|false |
384 | 384 | */ |
385 | - public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) |
|
385 | + public static function findImplementedInterfaceNames( File $phpcsFile, $stackPtr ) |
|
386 | 386 | { |
387 | - if (version_compare(self::getVersion(), '2.7.1', '>') === true) { |
|
388 | - return $phpcsFile->findImplementedInterfaceNames($stackPtr); |
|
387 | + if ( version_compare( self::getVersion(), '2.7.1', '>' ) === true ) { |
|
388 | + return $phpcsFile->findImplementedInterfaceNames( $stackPtr ); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $tokens = $phpcsFile->getTokens(); |
392 | 392 | |
393 | 393 | // Check for the existence of the token. |
394 | - if (isset($tokens[$stackPtr]) === false) { |
|
394 | + if ( isset( $tokens[ $stackPtr ] ) === false ) { |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - if ($tokens[$stackPtr]['code'] !== \T_CLASS |
|
399 | - && $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS' |
|
398 | + if ( $tokens[ $stackPtr ][ 'code' ] !== \T_CLASS |
|
399 | + && $tokens[ $stackPtr ][ 'type' ] !== 'T_ANON_CLASS' |
|
400 | 400 | ) { |
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - if (isset($tokens[$stackPtr]['scope_closer']) === false) { |
|
404 | + if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | |
408 | - $classOpenerIndex = $tokens[$stackPtr]['scope_opener']; |
|
409 | - $implementsIndex = $phpcsFile->findNext(\T_IMPLEMENTS, $stackPtr, $classOpenerIndex); |
|
410 | - if ($implementsIndex === false) { |
|
408 | + $classOpenerIndex = $tokens[ $stackPtr ][ 'scope_opener' ]; |
|
409 | + $implementsIndex = $phpcsFile->findNext( \T_IMPLEMENTS, $stackPtr, $classOpenerIndex ); |
|
410 | + if ( $implementsIndex === false ) { |
|
411 | 411 | return false; |
412 | 412 | } |
413 | 413 | |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | \T_COMMA, |
419 | 419 | ); |
420 | 420 | |
421 | - $end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true); |
|
422 | - $name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1)); |
|
423 | - $name = trim($name); |
|
421 | + $end = $phpcsFile->findNext( $find, ( $implementsIndex + 1 ), ( $classOpenerIndex + 1 ), true ); |
|
422 | + $name = $phpcsFile->getTokensAsString( ( $implementsIndex + 1 ), ( $end - $implementsIndex - 1 ) ); |
|
423 | + $name = trim( $name ); |
|
424 | 424 | |
425 | - if ($name === '') { |
|
425 | + if ( $name === '' ) { |
|
426 | 426 | return false; |
427 | 427 | } else { |
428 | - $names = explode(',', $name); |
|
429 | - $names = array_map('trim', $names); |
|
428 | + $names = explode( ',', $name ); |
|
429 | + $names = array_map( 'trim', $names ); |
|
430 | 430 | return $names; |
431 | 431 | } |
432 | 432 | } |
@@ -468,31 +468,31 @@ discard block |
||
468 | 468 | * @throws \PHP_CodeSniffer_Exception If the specified $stackPtr is not of |
469 | 469 | * type T_FUNCTION or T_CLOSURE. |
470 | 470 | */ |
471 | - public static function getMethodParameters(File $phpcsFile, $stackPtr) |
|
471 | + public static function getMethodParameters( File $phpcsFile, $stackPtr ) |
|
472 | 472 | { |
473 | - if (version_compare(self::getVersion(), '3.3.0', '>=') === true) { |
|
474 | - return $phpcsFile->getMethodParameters($stackPtr); |
|
473 | + if ( version_compare( self::getVersion(), '3.3.0', '>=' ) === true ) { |
|
474 | + return $phpcsFile->getMethodParameters( $stackPtr ); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | $tokens = $phpcsFile->getTokens(); |
478 | 478 | |
479 | 479 | // Check for the existence of the token. |
480 | - if (isset($tokens[$stackPtr]) === false) { |
|
480 | + if ( isset( $tokens[ $stackPtr ] ) === false ) { |
|
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | |
484 | - if ($tokens[$stackPtr]['code'] !== \T_FUNCTION |
|
485 | - && $tokens[$stackPtr]['code'] !== \T_CLOSURE |
|
484 | + if ( $tokens[ $stackPtr ][ 'code' ] !== \T_FUNCTION |
|
485 | + && $tokens[ $stackPtr ][ 'code' ] !== \T_CLOSURE |
|
486 | 486 | ) { |
487 | - throw new PHPCS_Exception('$stackPtr must be of type T_FUNCTION or T_CLOSURE'); |
|
487 | + throw new PHPCS_Exception( '$stackPtr must be of type T_FUNCTION or T_CLOSURE' ); |
|
488 | 488 | } |
489 | 489 | |
490 | - $opener = $tokens[$stackPtr]['parenthesis_opener']; |
|
491 | - $closer = $tokens[$stackPtr]['parenthesis_closer']; |
|
490 | + $opener = $tokens[ $stackPtr ][ 'parenthesis_opener' ]; |
|
491 | + $closer = $tokens[ $stackPtr ][ 'parenthesis_closer' ]; |
|
492 | 492 | |
493 | 493 | $vars = array(); |
494 | 494 | $currVar = null; |
495 | - $paramStart = ($opener + 1); |
|
495 | + $paramStart = ( $opener + 1 ); |
|
496 | 496 | $defaultStart = null; |
497 | 497 | $paramCount = 0; |
498 | 498 | $passByReference = false; |
@@ -501,28 +501,28 @@ discard block |
||
501 | 501 | $typeHintToken = false; |
502 | 502 | $nullableType = false; |
503 | 503 | |
504 | - for ($i = $paramStart; $i <= $closer; $i++) { |
|
504 | + for ( $i = $paramStart; $i <= $closer; $i++ ) { |
|
505 | 505 | // Check to see if this token has a parenthesis or bracket opener. If it does |
506 | 506 | // it's likely to be an array which might have arguments in it. This |
507 | 507 | // could cause problems in our parsing below, so lets just skip to the |
508 | 508 | // end of it. |
509 | - if (isset($tokens[$i]['parenthesis_opener']) === true) { |
|
509 | + if ( isset( $tokens[ $i ][ 'parenthesis_opener' ] ) === true ) { |
|
510 | 510 | // Don't do this if it's the close parenthesis for the method. |
511 | - if ($i !== $tokens[$i]['parenthesis_closer']) { |
|
512 | - $i = ($tokens[$i]['parenthesis_closer'] + 1); |
|
511 | + if ( $i !== $tokens[ $i ][ 'parenthesis_closer' ] ) { |
|
512 | + $i = ( $tokens[ $i ][ 'parenthesis_closer' ] + 1 ); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | - if (isset($tokens[$i]['bracket_opener']) === true) { |
|
516 | + if ( isset( $tokens[ $i ][ 'bracket_opener' ] ) === true ) { |
|
517 | 517 | // Don't do this if it's the close parenthesis for the method. |
518 | - if ($i !== $tokens[$i]['bracket_closer']) { |
|
519 | - $i = ($tokens[$i]['bracket_closer'] + 1); |
|
518 | + if ( $i !== $tokens[ $i ][ 'bracket_closer' ] ) { |
|
519 | + $i = ( $tokens[ $i ][ 'bracket_closer' ] + 1 ); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | - switch ($tokens[$i]['type']) { |
|
523 | + switch ( $tokens[ $i ][ 'type' ] ) { |
|
524 | 524 | case 'T_BITWISE_AND': |
525 | - if ($defaultStart === null) { |
|
525 | + if ( $defaultStart === null ) { |
|
526 | 526 | $passByReference = true; |
527 | 527 | } |
528 | 528 | break; |
@@ -534,105 +534,105 @@ discard block |
||
534 | 534 | break; |
535 | 535 | case 'T_ARRAY_HINT': // Pre-PHPCS 3.3.0. |
536 | 536 | case 'T_CALLABLE': |
537 | - if ($typeHintToken === false) { |
|
537 | + if ( $typeHintToken === false ) { |
|
538 | 538 | $typeHintToken = $i; |
539 | 539 | } |
540 | 540 | |
541 | - $typeHint .= $tokens[$i]['content']; |
|
541 | + $typeHint .= $tokens[ $i ][ 'content' ]; |
|
542 | 542 | break; |
543 | 543 | case 'T_SELF': |
544 | 544 | case 'T_PARENT': |
545 | 545 | case 'T_STATIC': |
546 | 546 | // Self and parent are valid, static invalid, but was probably intended as type hint. |
547 | - if (isset($defaultStart) === false) { |
|
548 | - if ($typeHintToken === false) { |
|
547 | + if ( isset( $defaultStart ) === false ) { |
|
548 | + if ( $typeHintToken === false ) { |
|
549 | 549 | $typeHintToken = $i; |
550 | 550 | } |
551 | 551 | |
552 | - $typeHint .= $tokens[$i]['content']; |
|
552 | + $typeHint .= $tokens[ $i ][ 'content' ]; |
|
553 | 553 | } |
554 | 554 | break; |
555 | 555 | case 'T_STRING': |
556 | 556 | // This is a string, so it may be a type hint, but it could |
557 | 557 | // also be a constant used as a default value. |
558 | 558 | $prevComma = false; |
559 | - for ($t = $i; $t >= $opener; $t--) { |
|
560 | - if ($tokens[$t]['code'] === \T_COMMA) { |
|
559 | + for ( $t = $i; $t >= $opener; $t-- ) { |
|
560 | + if ( $tokens[ $t ][ 'code' ] === \T_COMMA ) { |
|
561 | 561 | $prevComma = $t; |
562 | 562 | break; |
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | - if ($prevComma !== false) { |
|
566 | + if ( $prevComma !== false ) { |
|
567 | 567 | $nextEquals = false; |
568 | - for ($t = $prevComma; $t < $i; $t++) { |
|
569 | - if ($tokens[$t]['code'] === \T_EQUAL) { |
|
568 | + for ( $t = $prevComma; $t < $i; $t++ ) { |
|
569 | + if ( $tokens[ $t ][ 'code' ] === \T_EQUAL ) { |
|
570 | 570 | $nextEquals = $t; |
571 | 571 | break; |
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | - if ($nextEquals !== false) { |
|
575 | + if ( $nextEquals !== false ) { |
|
576 | 576 | break; |
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | - if ($defaultStart === null) { |
|
581 | - if ($typeHintToken === false) { |
|
580 | + if ( $defaultStart === null ) { |
|
581 | + if ( $typeHintToken === false ) { |
|
582 | 582 | $typeHintToken = $i; |
583 | 583 | } |
584 | 584 | |
585 | - $typeHint .= $tokens[$i]['content']; |
|
585 | + $typeHint .= $tokens[ $i ][ 'content' ]; |
|
586 | 586 | } |
587 | 587 | break; |
588 | 588 | case 'T_NS_SEPARATOR': |
589 | 589 | // Part of a type hint or default value. |
590 | - if ($defaultStart === null) { |
|
591 | - if ($typeHintToken === false) { |
|
590 | + if ( $defaultStart === null ) { |
|
591 | + if ( $typeHintToken === false ) { |
|
592 | 592 | $typeHintToken = $i; |
593 | 593 | } |
594 | 594 | |
595 | - $typeHint .= $tokens[$i]['content']; |
|
595 | + $typeHint .= $tokens[ $i ][ 'content' ]; |
|
596 | 596 | } |
597 | 597 | break; |
598 | 598 | case 'T_NULLABLE': |
599 | 599 | case 'T_INLINE_THEN': // Pre-PHPCS 2.8.0. |
600 | - if ($defaultStart === null) { |
|
600 | + if ( $defaultStart === null ) { |
|
601 | 601 | $nullableType = true; |
602 | - $typeHint .= $tokens[$i]['content']; |
|
602 | + $typeHint .= $tokens[ $i ][ 'content' ]; |
|
603 | 603 | } |
604 | 604 | break; |
605 | 605 | case 'T_CLOSE_PARENTHESIS': |
606 | 606 | case 'T_COMMA': |
607 | 607 | // If it's null, then there must be no parameters for this |
608 | 608 | // method. |
609 | - if ($currVar === null) { |
|
609 | + if ( $currVar === null ) { |
|
610 | 610 | break; |
611 | 611 | } |
612 | 612 | |
613 | - $vars[$paramCount] = array(); |
|
614 | - $vars[$paramCount]['token'] = $currVar; |
|
615 | - $vars[$paramCount]['name'] = $tokens[$currVar]['content']; |
|
616 | - $vars[$paramCount]['content'] = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart))); |
|
613 | + $vars[ $paramCount ] = array(); |
|
614 | + $vars[ $paramCount ][ 'token' ] = $currVar; |
|
615 | + $vars[ $paramCount ][ 'name' ] = $tokens[ $currVar ][ 'content' ]; |
|
616 | + $vars[ $paramCount ][ 'content' ] = trim( $phpcsFile->getTokensAsString( $paramStart, ( $i - $paramStart ) ) ); |
|
617 | 617 | |
618 | - if ($defaultStart !== null) { |
|
619 | - $vars[$paramCount]['default'] = trim( |
|
618 | + if ( $defaultStart !== null ) { |
|
619 | + $vars[ $paramCount ][ 'default' ] = trim( |
|
620 | 620 | $phpcsFile->getTokensAsString( |
621 | 621 | $defaultStart, |
622 | - ($i - $defaultStart) |
|
622 | + ( $i - $defaultStart ) |
|
623 | 623 | ) |
624 | 624 | ); |
625 | 625 | } |
626 | 626 | |
627 | - $vars[$paramCount]['pass_by_reference'] = $passByReference; |
|
628 | - $vars[$paramCount]['variable_length'] = $variableLength; |
|
629 | - $vars[$paramCount]['type_hint'] = $typeHint; |
|
630 | - $vars[$paramCount]['type_hint_token'] = $typeHintToken; |
|
631 | - $vars[$paramCount]['nullable_type'] = $nullableType; |
|
627 | + $vars[ $paramCount ][ 'pass_by_reference' ] = $passByReference; |
|
628 | + $vars[ $paramCount ][ 'variable_length' ] = $variableLength; |
|
629 | + $vars[ $paramCount ][ 'type_hint' ] = $typeHint; |
|
630 | + $vars[ $paramCount ][ 'type_hint_token' ] = $typeHintToken; |
|
631 | + $vars[ $paramCount ][ 'nullable_type' ] = $nullableType; |
|
632 | 632 | |
633 | 633 | // Reset the vars, as we are about to process the next parameter. |
634 | 634 | $defaultStart = null; |
635 | - $paramStart = ($i + 1); |
|
635 | + $paramStart = ( $i + 1 ); |
|
636 | 636 | $passByReference = false; |
637 | 637 | $variableLength = false; |
638 | 638 | $typeHint = ''; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $paramCount++; |
643 | 643 | break; |
644 | 644 | case 'T_EQUAL': |
645 | - $defaultStart = ($i + 1); |
|
645 | + $defaultStart = ( $i + 1 ); |
|
646 | 646 | break; |
647 | 647 | }//end switch |
648 | 648 | }//end for |
@@ -23,27 +23,27 @@ discard block |
||
23 | 23 | * external PHPCS standards creating cross-version compatibility in the same |
24 | 24 | * manner.}} |
25 | 25 | */ |
26 | -if (defined('PHPCOMPATIBILITY_PHPCS_ALIASES_SET') === false) { |
|
27 | - if (interface_exists('\PHP_CodeSniffer_Sniff') === false) { |
|
28 | - class_alias('PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff'); |
|
26 | +if ( defined( 'PHPCOMPATIBILITY_PHPCS_ALIASES_SET' ) === false ) { |
|
27 | + if ( interface_exists( '\PHP_CodeSniffer_Sniff' ) === false ) { |
|
28 | + class_alias( 'PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff' ); |
|
29 | 29 | } |
30 | - if (class_exists('\PHP_CodeSniffer_File') === false) { |
|
31 | - class_alias('PHP_CodeSniffer\Files\File', '\PHP_CodeSniffer_File'); |
|
30 | + if ( class_exists( '\PHP_CodeSniffer_File' ) === false ) { |
|
31 | + class_alias( 'PHP_CodeSniffer\Files\File', '\PHP_CodeSniffer_File' ); |
|
32 | 32 | } |
33 | - if (class_exists('\PHP_CodeSniffer_Tokens') === false) { |
|
34 | - class_alias('PHP_CodeSniffer\Util\Tokens', '\PHP_CodeSniffer_Tokens'); |
|
33 | + if ( class_exists( '\PHP_CodeSniffer_Tokens' ) === false ) { |
|
34 | + class_alias( 'PHP_CodeSniffer\Util\Tokens', '\PHP_CodeSniffer_Tokens' ); |
|
35 | 35 | } |
36 | - if (class_exists('\PHP_CodeSniffer_Exception') === false) { |
|
37 | - class_alias('PHP_CodeSniffer\Exceptions\RuntimeException', '\PHP_CodeSniffer_Exception'); |
|
36 | + if ( class_exists( '\PHP_CodeSniffer_Exception' ) === false ) { |
|
37 | + class_alias( 'PHP_CodeSniffer\Exceptions\RuntimeException', '\PHP_CodeSniffer_Exception' ); |
|
38 | 38 | } |
39 | - if (class_exists('\PHP_CodeSniffer_Standards_AbstractScopeSniff') === false) { |
|
40 | - class_alias('PHP_CodeSniffer\Sniffs\AbstractScopeSniff', '\PHP_CodeSniffer_Standards_AbstractScopeSniff'); |
|
39 | + if ( class_exists( '\PHP_CodeSniffer_Standards_AbstractScopeSniff' ) === false ) { |
|
40 | + class_alias( 'PHP_CodeSniffer\Sniffs\AbstractScopeSniff', '\PHP_CodeSniffer_Standards_AbstractScopeSniff' ); |
|
41 | 41 | } |
42 | - if (class_exists('\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff') === false) { |
|
43 | - class_alias('PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', '\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff'); |
|
42 | + if ( class_exists( '\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' ) === false ) { |
|
43 | + class_alias( 'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', '\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' ); |
|
44 | 44 | } |
45 | 45 | |
46 | - define('PHPCOMPATIBILITY_PHPCS_ALIASES_SET', true); |
|
46 | + define( 'PHPCOMPATIBILITY_PHPCS_ALIASES_SET', true ); |
|
47 | 47 | |
48 | 48 | /* |
49 | 49 | * Register an autoloader. |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * is needed to run the sniffs. |
53 | 53 | * Upstream issue: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591} }} |
54 | 54 | */ |
55 | - spl_autoload_register(function ($class) { |
|
55 | + spl_autoload_register( function( $class ) { |
|
56 | 56 | // Only try & load our own classes. |
57 | - if (stripos($class, 'PHPCompatibility') !== 0) { |
|
57 | + if ( stripos( $class, 'PHPCompatibility' ) !== 0 ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - $file = realpath(__DIR__) . DIRECTORY_SEPARATOR . strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php'; |
|
61 | + $file = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . strtr( $class, '\\', DIRECTORY_SEPARATOR ) . '.php'; |
|
62 | 62 | |
63 | - if (file_exists($file)) { |
|
63 | + if ( file_exists( $file ) ) { |
|
64 | 64 | include_once $file; |
65 | 65 | } |
66 | 66 | }); |
@@ -5,34 +5,34 @@ discard block |
||
5 | 5 | * @package PHPCompatibility |
6 | 6 | */ |
7 | 7 | |
8 | -if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { |
|
9 | - define('PHP_CODESNIFFER_IN_TESTS', true); |
|
8 | +if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === false ) { |
|
9 | + define( 'PHP_CODESNIFFER_IN_TESTS', true ); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // The below two defines are needed for PHPCS 3.x. |
13 | -if (defined('PHP_CODESNIFFER_CBF') === false) { |
|
14 | - define('PHP_CODESNIFFER_CBF', false); |
|
13 | +if ( defined( 'PHP_CODESNIFFER_CBF' ) === false ) { |
|
14 | + define( 'PHP_CODESNIFFER_CBF', false ); |
|
15 | 15 | } |
16 | 16 | |
17 | -if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { |
|
18 | - define('PHP_CODESNIFFER_VERBOSITY', 0); |
|
17 | +if ( defined( 'PHP_CODESNIFFER_VERBOSITY' ) === false ) { |
|
18 | + define( 'PHP_CODESNIFFER_VERBOSITY', 0 ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $ds = DIRECTORY_SEPARATOR; |
22 | 22 | |
23 | 23 | // Get the PHPCS dir from an environment variable. |
24 | -$phpcsDir = getenv('PHPCS_DIR'); |
|
24 | +$phpcsDir = getenv( 'PHPCS_DIR' ); |
|
25 | 25 | |
26 | 26 | // This may be a Composer install. |
27 | -if ($phpcsDir === false && is_dir(__DIR__ . $ds . 'vendor' . $ds . 'squizlabs' . $ds . 'php_codesniffer')) { |
|
27 | +if ( $phpcsDir === false && is_dir( __DIR__ . $ds . 'vendor' . $ds . 'squizlabs' . $ds . 'php_codesniffer' ) ) { |
|
28 | 28 | $vendorDir = __DIR__ . $ds . 'vendor'; |
29 | 29 | $phpcsDir = $vendorDir . $ds . 'squizlabs' . $ds . 'php_codesniffer'; |
30 | -} elseif ($phpcsDir !== false) { |
|
31 | - $phpcsDir = realpath($phpcsDir); |
|
30 | +} elseif ( $phpcsDir !== false ) { |
|
31 | + $phpcsDir = realpath( $phpcsDir ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | // Try and load the PHPCS autoloader. |
35 | -if ($phpcsDir !== false && file_exists($phpcsDir . $ds . 'autoload.php')) { |
|
35 | +if ( $phpcsDir !== false && file_exists( $phpcsDir . $ds . 'autoload.php' ) ) { |
|
36 | 36 | // PHPCS 3.x. |
37 | 37 | require_once $phpcsDir . $ds . 'autoload.php'; |
38 | 38 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | */ |
44 | 44 | require_once __DIR__ . $ds . 'PHPCSAliases.php'; |
45 | 45 | |
46 | -} elseif ($phpcsDir !== false && file_exists($phpcsDir . $ds . 'CodeSniffer.php')) { |
|
46 | +} elseif ( $phpcsDir !== false && file_exists( $phpcsDir . $ds . 'CodeSniffer.php' ) ) { |
|
47 | 47 | // PHPCS 2.x. |
48 | 48 | require_once $phpcsDir . $ds . 'CodeSniffer.php'; |
49 | 49 | |
50 | - if (isset($vendorDir) && file_exists($vendorDir . $ds . 'autoload.php')) { |
|
50 | + if ( isset( $vendorDir ) && file_exists( $vendorDir . $ds . 'autoload.php' ) ) { |
|
51 | 51 | require_once $vendorDir . $ds . 'autoload.php'; |
52 | 52 | } |
53 | 53 | |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | https://is.gd/PHPCompatibilityContrib |
63 | 63 | '; |
64 | 64 | |
65 | - die(1); |
|
65 | + die( 1 ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | // PHPUnit cross version compatibility. |
70 | -if (class_exists('PHPUnit\Runner\Version') |
|
71 | - && version_compare(PHPUnit\Runner\Version::id(), '6.0', '>=') |
|
72 | - && class_exists('PHPUnit_Framework_TestCase') === false |
|
70 | +if ( class_exists( 'PHPUnit\Runner\Version' ) |
|
71 | + && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) |
|
72 | + && class_exists( 'PHPUnit_Framework_TestCase' ) === false |
|
73 | 73 | ) { |
74 | - class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); |
|
74 | + class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | require_once __DIR__ . $ds . 'PHPCompatibility' . $ds . 'Tests' . $ds . 'BaseSniffTest.php'; |
78 | 78 | require_once __DIR__ . $ds . 'PHPCompatibility' . $ds . 'Util' . $ds . 'Tests' . $ds . 'CoreMethodTestFrame.php'; |
79 | -unset($ds, $phpcsDir, $vendorDir); |
|
79 | +unset( $ds, $phpcsDir, $vendorDir ); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @throws ProcessFailedException |
91 | 91 | * @throws RuntimeException |
92 | 92 | */ |
93 | - public static function run(Event $event) |
|
93 | + public static function run( Event $event ) |
|
94 | 94 | { |
95 | 95 | $io = $event->getIO(); |
96 | 96 | $composer = $event->getComposer(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @throws ProcessFailedException |
112 | 112 | * @throws RuntimeException |
113 | 113 | */ |
114 | - public function activate(Composer $composer, IOInterface $io) |
|
114 | + public function activate( Composer $composer, IOInterface $io ) |
|
115 | 115 | { |
116 | 116 | $this->composer = $composer; |
117 | 117 | $this->io = $io; |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | $this->cwd = getcwd(); |
133 | 133 | $this->installedPaths = array(); |
134 | 134 | |
135 | - $this->processExecutor = new ProcessExecutor($this->io); |
|
136 | - $this->filesystem = new Filesystem($this->processExecutor); |
|
135 | + $this->processExecutor = new ProcessExecutor( $this->io ); |
|
136 | + $this->filesystem = new Filesystem( $this->processExecutor ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | { |
144 | 144 | return array( |
145 | 145 | ScriptEvents::POST_INSTALL_CMD => array( |
146 | - array('onDependenciesChangedEvent', 0), |
|
146 | + array( 'onDependenciesChangedEvent', 0 ), |
|
147 | 147 | ), |
148 | 148 | ScriptEvents::POST_UPDATE_CMD => array( |
149 | - array('onDependenciesChangedEvent', 0), |
|
149 | + array( 'onDependenciesChangedEvent', 0 ), |
|
150 | 150 | ), |
151 | 151 | ); |
152 | 152 | } |
@@ -164,22 +164,22 @@ discard block |
||
164 | 164 | $io = $this->io; |
165 | 165 | $isVerbose = $io->isVerbose(); |
166 | 166 | |
167 | - if ($isVerbose) { |
|
168 | - $io->write(sprintf('<info>%s</info>', self::MESSAGE_RUNNING_INSTALLER)); |
|
167 | + if ( $isVerbose ) { |
|
168 | + $io->write( sprintf( '<info>%s</info>', self::MESSAGE_RUNNING_INSTALLER ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | - if ($this->isPHPCodeSnifferInstalled() === true) { |
|
171 | + if ( $this->isPHPCodeSnifferInstalled() === true ) { |
|
172 | 172 | $this->loadInstalledPaths(); |
173 | 173 | $installPathCleaned = $this->cleanInstalledPaths(); |
174 | 174 | $installPathUpdated = $this->updateInstalledPaths(); |
175 | 175 | |
176 | - if ($installPathCleaned === true || $installPathUpdated === true) { |
|
176 | + if ( $installPathCleaned === true || $installPathUpdated === true ) { |
|
177 | 177 | $this->saveInstalledPaths(); |
178 | - } elseif ($isVerbose) { |
|
179 | - $io->write(sprintf('<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL)); |
|
178 | + } elseif ( $isVerbose ) { |
|
179 | + $io->write( sprintf( '<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL ) ); |
|
180 | 180 | } |
181 | - } elseif ($isVerbose) { |
|
182 | - $io->write(sprintf('<info>%s</info>', self::MESSAGE_NOT_INSTALLED)); |
|
181 | + } elseif ( $isVerbose ) { |
|
182 | + $io->write( sprintf( '<info>%s</info>', self::MESSAGE_NOT_INSTALLED ) ); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -192,21 +192,21 @@ discard block |
||
192 | 192 | */ |
193 | 193 | private function loadInstalledPaths() |
194 | 194 | { |
195 | - if ($this->isPHPCodeSnifferInstalled() === true) { |
|
195 | + if ( $this->isPHPCodeSnifferInstalled() === true ) { |
|
196 | 196 | $this->processExecutor->execute( |
197 | 197 | sprintf( |
198 | 198 | 'phpcs --config-show %s', |
199 | 199 | self::PHPCS_CONFIG_KEY |
200 | 200 | ), |
201 | 201 | $output, |
202 | - $this->composer->getConfig()->get('bin-dir') |
|
202 | + $this->composer->getConfig()->get( 'bin-dir' ) |
|
203 | 203 | ); |
204 | 204 | |
205 | - $phpcsInstalledPaths = str_replace(self::PHPCS_CONFIG_KEY . ': ', '', $output); |
|
206 | - $phpcsInstalledPaths = trim($phpcsInstalledPaths); |
|
205 | + $phpcsInstalledPaths = str_replace( self::PHPCS_CONFIG_KEY . ': ', '', $output ); |
|
206 | + $phpcsInstalledPaths = trim( $phpcsInstalledPaths ); |
|
207 | 207 | |
208 | - if ($phpcsInstalledPaths !== '') { |
|
209 | - $this->installedPaths = explode(',', $phpcsInstalledPaths); |
|
208 | + if ( $phpcsInstalledPaths !== '' ) { |
|
209 | + $this->installedPaths = explode( ',', $phpcsInstalledPaths ); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | private function saveInstalledPaths() |
222 | 222 | { |
223 | 223 | // Check if we found installed paths to set. |
224 | - if (count($this->installedPaths) !== 0) { |
|
225 | - $paths = implode(',', $this->installedPaths); |
|
226 | - $arguments = array('--config-set', self::PHPCS_CONFIG_KEY, $paths); |
|
224 | + if ( count( $this->installedPaths ) !== 0 ) { |
|
225 | + $paths = implode( ',', $this->installedPaths ); |
|
226 | + $arguments = array( '--config-set', self::PHPCS_CONFIG_KEY, $paths ); |
|
227 | 227 | $configMessage = sprintf( |
228 | 228 | 'PHP CodeSniffer Config <info>%s</info> <comment>set to</comment> <info>%s</info>', |
229 | 229 | self::PHPCS_CONFIG_KEY, |
@@ -231,26 +231,26 @@ discard block |
||
231 | 231 | ); |
232 | 232 | } else { |
233 | 233 | // Delete the installed paths if none were found. |
234 | - $arguments = array('--config-delete', self::PHPCS_CONFIG_KEY); |
|
234 | + $arguments = array( '--config-delete', self::PHPCS_CONFIG_KEY ); |
|
235 | 235 | $configMessage = sprintf( |
236 | 236 | 'PHP CodeSniffer Config <info>%s</info> <comment>delete</comment>', |
237 | 237 | self::PHPCS_CONFIG_KEY |
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
241 | - $this->io->write($configMessage); |
|
241 | + $this->io->write( $configMessage ); |
|
242 | 242 | |
243 | 243 | $this->processExecutor->execute( |
244 | 244 | sprintf( |
245 | 245 | 'phpcs %s', |
246 | - implode(' ', $arguments) |
|
246 | + implode( ' ', $arguments ) |
|
247 | 247 | ), |
248 | 248 | $configResult, |
249 | - $this->composer->getConfig()->get('bin-dir') |
|
249 | + $this->composer->getConfig()->get( 'bin-dir' ) |
|
250 | 250 | ); |
251 | 251 | |
252 | - if ($this->io->isVerbose() && !empty($configResult)) { |
|
253 | - $this->io->write(sprintf('<info>%s</info>', $configResult)); |
|
252 | + if ( $this->io->isVerbose() && ! empty( $configResult ) ) { |
|
253 | + $this->io->write( sprintf( '<info>%s</info>', $configResult ) ); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | private function cleanInstalledPaths() |
266 | 266 | { |
267 | 267 | $changes = false; |
268 | - foreach ($this->installedPaths as $key => $path) { |
|
268 | + foreach ( $this->installedPaths as $key => $path ) { |
|
269 | 269 | // This might be a relative path as well |
270 | - $alternativePath = realpath($this->getPHPCodeSnifferInstallPath() . DIRECTORY_SEPARATOR . $path); |
|
270 | + $alternativePath = realpath( $this->getPHPCodeSnifferInstallPath() . DIRECTORY_SEPARATOR . $path ); |
|
271 | 271 | |
272 | - if ((is_dir($path) === false || is_readable($path) === false) && |
|
273 | - (is_dir($alternativePath) === false || is_readable($alternativePath) === false) |
|
272 | + if ( ( is_dir( $path ) === false || is_readable( $path ) === false ) && |
|
273 | + ( is_dir( $alternativePath ) === false || is_readable( $alternativePath ) === false ) |
|
274 | 274 | ) { |
275 | - unset($this->installedPaths[$key]); |
|
275 | + unset( $this->installedPaths[ $key ] ); |
|
276 | 276 | $changes = true; |
277 | 277 | } |
278 | 278 | } |
@@ -292,38 +292,38 @@ discard block |
||
292 | 292 | { |
293 | 293 | $changes = false; |
294 | 294 | |
295 | - $searchPaths = array($this->cwd); |
|
295 | + $searchPaths = array( $this->cwd ); |
|
296 | 296 | $codingStandardPackages = $this->getPHPCodingStandardPackages(); |
297 | - foreach ($codingStandardPackages as $package) { |
|
298 | - $installPath = $this->composer->getInstallationManager()->getInstallPath($package); |
|
299 | - if ($this->filesystem->isAbsolutePath($installPath) === false) { |
|
297 | + foreach ( $codingStandardPackages as $package ) { |
|
298 | + $installPath = $this->composer->getInstallationManager()->getInstallPath( $package ); |
|
299 | + if ( $this->filesystem->isAbsolutePath( $installPath ) === false ) { |
|
300 | 300 | $installPath = $this->filesystem->normalizePath( |
301 | 301 | $this->cwd . DIRECTORY_SEPARATOR . $installPath |
302 | 302 | ); |
303 | 303 | } |
304 | - $searchPaths[] = $installPath; |
|
304 | + $searchPaths[ ] = $installPath; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $finder = new Finder(); |
308 | 308 | $finder->files() |
309 | - ->depth('<= ' . $this->getMaxDepth()) |
|
310 | - ->depth('>= ' . $this->getMinDepth()) |
|
309 | + ->depth( '<= ' . $this->getMaxDepth() ) |
|
310 | + ->depth( '>= ' . $this->getMinDepth() ) |
|
311 | 311 | ->ignoreUnreadableDirs() |
312 | - ->ignoreVCS(true) |
|
313 | - ->in($searchPaths) |
|
314 | - ->name('ruleset.xml'); |
|
312 | + ->ignoreVCS( true ) |
|
313 | + ->in( $searchPaths ) |
|
314 | + ->name( 'ruleset.xml' ); |
|
315 | 315 | |
316 | 316 | // Process each found possible ruleset. |
317 | - foreach ($finder as $ruleset) { |
|
317 | + foreach ( $finder as $ruleset ) { |
|
318 | 318 | $standardsPath = $ruleset->getPath(); |
319 | 319 | |
320 | 320 | // Pick the directory above the directory containing the standard, unless this is the project root. |
321 | - if ($standardsPath !== $this->cwd) { |
|
322 | - $standardsPath = dirname($standardsPath); |
|
321 | + if ( $standardsPath !== $this->cwd ) { |
|
322 | + $standardsPath = dirname( $standardsPath ); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Use relative paths for local project repositories. |
326 | - if ($this->isRunningGlobally() === false) { |
|
326 | + if ( $this->isRunningGlobally() === false ) { |
|
327 | 327 | $standardsPath = $this->filesystem->findShortestPath( |
328 | 328 | $this->getPHPCodeSnifferInstallPath(), |
329 | 329 | $standardsPath, |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | // De-duplicate and add when directory is not configured. |
335 | - if (in_array($standardsPath, $this->installedPaths, true) === false) { |
|
336 | - $this->installedPaths[] = $standardsPath; |
|
335 | + if ( in_array( $standardsPath, $this->installedPaths, true ) === false ) { |
|
336 | + $this->installedPaths[ ] = $standardsPath; |
|
337 | 337 | $changes = true; |
338 | 338 | } |
339 | 339 | } |
@@ -354,18 +354,18 @@ discard block |
||
354 | 354 | { |
355 | 355 | $codingStandardPackages = array_filter( |
356 | 356 | $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(), |
357 | - function (PackageInterface $package) { |
|
358 | - if ($package instanceof AliasPackage) { |
|
357 | + function( PackageInterface $package ) { |
|
358 | + if ( $package instanceof AliasPackage ) { |
|
359 | 359 | return false; |
360 | 360 | } |
361 | 361 | return $package->getType() === Plugin::PACKAGE_TYPE; |
362 | 362 | } |
363 | 363 | ); |
364 | 364 | |
365 | - if (! $this->composer->getPackage() instanceof RootpackageInterface |
|
365 | + if ( ! $this->composer->getPackage() instanceof RootpackageInterface |
|
366 | 366 | && $this->composer->getPackage()->getType() === self::PACKAGE_TYPE |
367 | 367 | ) { |
368 | - $codingStandardPackages[] = $this->composer->getPackage(); |
|
368 | + $codingStandardPackages[ ] = $this->composer->getPackage(); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | return $codingStandardPackages; |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return PackageInterface|null |
380 | 380 | */ |
381 | - private function getPHPCodeSnifferPackage($versionConstraint = null) |
|
381 | + private function getPHPCodeSnifferPackage( $versionConstraint = null ) |
|
382 | 382 | { |
383 | 383 | $packages = $this |
384 | 384 | ->composer |
385 | 385 | ->getRepositoryManager() |
386 | 386 | ->getLocalRepository() |
387 | - ->findPackages(self::PACKAGE_NAME, $versionConstraint); |
|
387 | + ->findPackages( self::PACKAGE_NAME, $versionConstraint ); |
|
388 | 388 | |
389 | - return array_shift($packages); |
|
389 | + return array_shift( $packages ); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | private function getPHPCodeSnifferInstallPath() |
398 | 398 | { |
399 | - return $this->composer->getInstallationManager()->getInstallPath($this->getPHPCodeSnifferPackage()); |
|
399 | + return $this->composer->getInstallationManager()->getInstallPath( $this->getPHPCodeSnifferPackage() ); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return bool Whether PHP_CodeSniffer is installed |
408 | 408 | */ |
409 | - private function isPHPCodeSnifferInstalled($versionConstraint = null) |
|
409 | + private function isPHPCodeSnifferInstalled( $versionConstraint = null ) |
|
410 | 410 | { |
411 | - return ($this->getPHPCodeSnifferPackage($versionConstraint) !== null); |
|
411 | + return ( $this->getPHPCodeSnifferPackage( $versionConstraint ) !== null ); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | */ |
422 | 422 | private function isRunningGlobally() |
423 | 423 | { |
424 | - return ($this->composer->getConfig()->get('home') === $this->cwd); |
|
424 | + return ( $this->composer->getConfig()->get( 'home' ) === $this->cwd ); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -437,24 +437,24 @@ discard block |
||
437 | 437 | |
438 | 438 | $extra = $this->composer->getPackage()->getExtra(); |
439 | 439 | |
440 | - if (array_key_exists(self::KEY_MAX_DEPTH, $extra)) { |
|
441 | - $maxDepth = $extra[self::KEY_MAX_DEPTH]; |
|
440 | + if ( array_key_exists( self::KEY_MAX_DEPTH, $extra ) ) { |
|
441 | + $maxDepth = $extra[ self::KEY_MAX_DEPTH ]; |
|
442 | 442 | $minDepth = $this->getMinDepth(); |
443 | 443 | |
444 | - if (is_int($maxDepth) === false /* Must be an integer */ |
|
444 | + if ( is_int( $maxDepth ) === false /* Must be an integer */ |
|
445 | 445 | || $maxDepth <= $minDepth /* Larger than the minimum */ |
446 | - || is_float($maxDepth) === true /* Within the boundaries of integer */ |
|
446 | + || is_float( $maxDepth ) === true /* Within the boundaries of integer */ |
|
447 | 447 | ) { |
448 | 448 | $message = vsprintf( |
449 | 449 | self::MESSAGE_ERROR_WRONG_MAX_DEPTH, |
450 | 450 | array( |
451 | 451 | 'key' => self::KEY_MAX_DEPTH, |
452 | 452 | 'min' => $minDepth, |
453 | - 'given' => var_export($maxDepth, true), |
|
453 | + 'given' => var_export( $maxDepth, true ), |
|
454 | 454 | ) |
455 | 455 | ); |
456 | 456 | |
457 | - throw new \InvalidArgumentException($message); |
|
457 | + throw new \InvalidArgumentException( $message ); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | */ |
471 | 471 | private function getMinDepth() |
472 | 472 | { |
473 | - if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) { |
|
473 | + if ( $this->isPHPCodeSnifferInstalled( '>= 3.0.0' ) !== true ) { |
|
474 | 474 | return 1; |
475 | 475 | } |
476 | 476 | return 0; |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | unset( $this->groups[ $groupName ] ); |
154 | 154 | } else { |
155 | 155 | $items = array_map( array( $this, 'prepare_name_for_regex' ), $group[ $key ] ); |
156 | - $all_items[] = $items; |
|
156 | + $all_items[ ] = $items; |
|
157 | 157 | $items = implode( '|', $items ); |
158 | 158 | |
159 | - $this->groups[ $groupName ]['regex'] = sprintf( $this->regex_pattern, $items ); |
|
159 | + $this->groups[ $groupName ][ 'regex' ] = sprintf( $this->regex_pattern, $items ); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // Preliminary check. If the content of the T_STRING is not one of the functions we're |
193 | 193 | // looking for, we can bow out before doing the heavy lifting of checking whether |
194 | 194 | // this is a function call. |
195 | - if ( preg_match( $this->prelim_check_regex, $this->tokens[ $stackPtr ]['content'] ) !== 1 ) { |
|
195 | + if ( preg_match( $this->prelim_check_regex, $this->tokens[ $stackPtr ][ 'content' ] ) !== 1 ) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function is_targetted_token( $stackPtr ) { |
214 | 214 | |
215 | 215 | // Exclude function definitions, class methods, and namespaced calls. |
216 | - if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) { |
|
216 | + if ( \T_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) { |
|
217 | 217 | if ( $this->is_class_object_call( $stackPtr ) === true ) { |
218 | 218 | return false; |
219 | 219 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | \T_AS => \T_AS, // Use declaration alias. |
233 | 233 | ); |
234 | 234 | |
235 | - if ( isset( $skipped[ $this->tokens[ $prev ]['code'] ] ) ) { |
|
235 | + if ( isset( $skipped[ $this->tokens[ $prev ][ 'code' ] ] ) ) { |
|
236 | 236 | return false; |
237 | 237 | } |
238 | 238 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * normal file processing. |
255 | 255 | */ |
256 | 256 | public function check_for_matches( $stackPtr ) { |
257 | - $token_content = strtolower( $this->tokens[ $stackPtr ]['content'] ); |
|
257 | + $token_content = strtolower( $this->tokens[ $stackPtr ][ 'content' ] ); |
|
258 | 258 | $skip_to = array(); |
259 | 259 | |
260 | 260 | foreach ( $this->groups as $groupName => $group ) { |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | - if ( isset( $group['whitelist'][ $token_content ] ) ) { |
|
266 | + if ( isset( $group[ 'whitelist' ][ $token_content ] ) ) { |
|
267 | 267 | continue; |
268 | 268 | } |
269 | 269 | |
270 | - if ( preg_match( $group['regex'], $token_content ) === 1 ) { |
|
271 | - $skip_to[] = $this->process_matched_token( $stackPtr, $groupName, $token_content ); |
|
270 | + if ( preg_match( $group[ 'regex' ], $token_content ) === 1 ) { |
|
271 | + $skip_to[ ] = $this->process_matched_token( $stackPtr, $groupName, $token_content ); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | public function process_matched_token( $stackPtr, $group_name, $matched_content ) { |
295 | 295 | |
296 | 296 | $this->addMessage( |
297 | - $this->groups[ $group_name ]['message'], |
|
297 | + $this->groups[ $group_name ][ 'message' ], |
|
298 | 298 | $stackPtr, |
299 | - ( 'error' === $this->groups[ $group_name ]['type'] ), |
|
299 | + ( 'error' === $this->groups[ $group_name ][ 'type' ] ), |
|
300 | 300 | $this->string_to_errorcode( $group_name . '_' . $matched_content ), |
301 | 301 | array( $matched_content ) |
302 | 302 | ); |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence |
8 | 8 | */ |
9 | 9 | |
10 | -if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { |
|
11 | - define('PHP_CODESNIFFER_IN_TESTS', true); |
|
10 | +if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === false ) { |
|
11 | + define( 'PHP_CODESNIFFER_IN_TESTS', true ); |
|
12 | 12 | } |
13 | 13 | |
14 | -if (defined('PHP_CODESNIFFER_CBF') === false) { |
|
15 | - define('PHP_CODESNIFFER_CBF', false); |
|
14 | +if ( defined( 'PHP_CODESNIFFER_CBF' ) === false ) { |
|
15 | + define( 'PHP_CODESNIFFER_CBF', false ); |
|
16 | 16 | } |
17 | 17 | |
18 | -if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { |
|
19 | - define('PHP_CODESNIFFER_VERBOSITY', 0); |
|
18 | +if ( defined( 'PHP_CODESNIFFER_VERBOSITY' ) === false ) { |
|
19 | + define( 'PHP_CODESNIFFER_VERBOSITY', 0 ); |
|
20 | 20 | } |
21 | 21 | |
22 | -if (is_file(__DIR__.'/../autoload.php') === true) { |
|
23 | - include_once __DIR__.'/../autoload.php'; |
|
22 | +if ( is_file( __DIR__ . '/../autoload.php' ) === true ) { |
|
23 | + include_once __DIR__ . '/../autoload.php'; |
|
24 | 24 | } else { |
25 | 25 | include_once 'PHP/CodeSniffer/autoload.php'; |
26 | 26 | } |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $tokens = new \PHP_CodeSniffer\Util\Tokens(); |
29 | 29 | |
30 | 30 | // Compatibility for PHPUnit < 6 and PHPUnit 6+. |
31 | -if (class_exists('PHPUnit_Framework_TestSuite') === true && class_exists('PHPUnit\Framework\TestSuite') === false) { |
|
32 | - class_alias('PHPUnit_Framework_TestSuite', 'PHPUnit'.'\Framework\TestSuite'); |
|
31 | +if ( class_exists( 'PHPUnit_Framework_TestSuite' ) === true && class_exists( 'PHPUnit\Framework\TestSuite' ) === false ) { |
|
32 | + class_alias( 'PHPUnit_Framework_TestSuite', 'PHPUnit' . '\Framework\TestSuite' ); |
|
33 | 33 | } |
34 | 34 | |
35 | -if (class_exists('PHPUnit_Framework_TestCase') === true && class_exists('PHPUnit\Framework\TestCase') === false) { |
|
36 | - class_alias('PHPUnit_Framework_TestCase', 'PHPUnit'.'\Framework\TestCase'); |
|
35 | +if ( class_exists( 'PHPUnit_Framework_TestCase' ) === true && class_exists( 'PHPUnit\Framework\TestCase' ) === false ) { |
|
36 | + class_alias( 'PHPUnit_Framework_TestCase', 'PHPUnit' . '\Framework\TestCase' ); |
|
37 | 37 | } |
38 | 38 | |
39 | -if (class_exists('PHPUnit_TextUI_TestRunner') === true && class_exists('PHPUnit\TextUI\TestRunner') === false) { |
|
40 | - class_alias('PHPUnit_TextUI_TestRunner', 'PHPUnit'.'\TextUI\TestRunner'); |
|
39 | +if ( class_exists( 'PHPUnit_TextUI_TestRunner' ) === true && class_exists( 'PHPUnit\TextUI\TestRunner' ) === false ) { |
|
40 | + class_alias( 'PHPUnit_TextUI_TestRunner', 'PHPUnit' . '\TextUI\TestRunner' ); |
|
41 | 41 | } |
42 | 42 | |
43 | -if (class_exists('PHPUnit_Framework_TestResult') === true && class_exists('PHPUnit\Framework\TestResult') === false) { |
|
44 | - class_alias('PHPUnit_Framework_TestResult', 'PHPUnit'.'\Framework\TestResult'); |
|
43 | +if ( class_exists( 'PHPUnit_Framework_TestResult' ) === true && class_exists( 'PHPUnit\Framework\TestResult' ) === false ) { |
|
44 | + class_alias( 'PHPUnit_Framework_TestResult', 'PHPUnit' . '\Framework\TestResult' ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function printPHPCodeSnifferTestOutput() |
54 | 54 | { |
55 | - echo PHP_EOL.PHP_EOL; |
|
55 | + echo PHP_EOL . PHP_EOL; |
|
56 | 56 | |
57 | 57 | $output = 'The test files'; |
58 | - $data = []; |
|
58 | + $data = [ ]; |
|
59 | 59 | |
60 | - $codeCount = count($GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']); |
|
61 | - if (empty($GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES']) === false) { |
|
62 | - $files = call_user_func_array('array_merge', $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES']); |
|
63 | - $files = array_unique($files); |
|
64 | - $fileCount = count($files); |
|
60 | + $codeCount = count( $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CODES' ] ); |
|
61 | + if ( empty( $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CASE_FILES' ] ) === false ) { |
|
62 | + $files = call_user_func_array( 'array_merge', $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CASE_FILES' ] ); |
|
63 | + $files = array_unique( $files ); |
|
64 | + $fileCount = count( $files ); |
|
65 | 65 | |
66 | 66 | $output = '%d sniff test files'; |
67 | - $data[] = $fileCount; |
|
67 | + $data[ ] = $fileCount; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $output .= ' generated %d unique error codes'; |
71 | - $data[] = $codeCount; |
|
71 | + $data[ ] = $codeCount; |
|
72 | 72 | |
73 | - if ($codeCount > 0) { |
|
74 | - $fixes = count($GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']); |
|
75 | - $percent = round(($fixes / $codeCount * 100), 2); |
|
73 | + if ( $codeCount > 0 ) { |
|
74 | + $fixes = count( $GLOBALS[ 'PHP_CODESNIFFER_FIXABLE_CODES' ] ); |
|
75 | + $percent = round( ( $fixes / $codeCount * 100 ), 2 ); |
|
76 | 76 | |
77 | 77 | $output .= '; %d were fixable (%d%%)'; |
78 | - $data[] = $fixes; |
|
79 | - $data[] = $percent; |
|
78 | + $data[ ] = $fixes; |
|
79 | + $data[ ] = $percent; |
|
80 | 80 | } |
81 | 81 | |
82 | - vprintf($output, $data); |
|
82 | + vprintf( $output, $data ); |
|
83 | 83 | |
84 | 84 | }//end printPHPCodeSnifferTestOutput() |
@@ -23,9 +23,9 @@ |
||
23 | 23 | * |
24 | 24 | * @return \PHPUnit\Framework\TestResult |
25 | 25 | */ |
26 | - public function run(TestResult $result=null): TestResult |
|
26 | + public function run( TestResult $result = null ): TestResult |
|
27 | 27 | { |
28 | - $result = parent::run($result); |
|
28 | + $result = parent::run( $result ); |
|
29 | 29 | printPHPCodeSnifferTestOutput(); |
30 | 30 | return $result; |
31 | 31 |
@@ -23,9 +23,9 @@ |
||
23 | 23 | * |
24 | 24 | * @return \PHPUnit\Framework\TestResult |
25 | 25 | */ |
26 | - public function run(TestResult $result=null) |
|
26 | + public function run( TestResult $result = null ) |
|
27 | 27 | { |
28 | - $result = parent::run($result); |
|
28 | + $result = parent::run( $result ); |
|
29 | 29 | printPHPCodeSnifferTestOutput(); |
30 | 30 | return $result; |
31 | 31 |