@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function setUp() |
56 | 56 | { |
57 | - $class = get_class($this); |
|
58 | - $this->standardsDir = $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$class]; |
|
59 | - $this->testsDir = $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$class]; |
|
57 | + $class = get_class( $this ); |
|
58 | + $this->standardsDir = $GLOBALS[ 'PHP_CODESNIFFER_STANDARD_DIRS' ][ $class ]; |
|
59 | + $this->testsDir = $GLOBALS[ 'PHP_CODESNIFFER_TEST_DIRS' ][ $class ]; |
|
60 | 60 | |
61 | 61 | }//end setUp() |
62 | 62 | |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return string[] |
73 | 73 | */ |
74 | - protected function getTestFiles($testFileBase) |
|
74 | + protected function getTestFiles( $testFileBase ) |
|
75 | 75 | { |
76 | - $testFiles = []; |
|
76 | + $testFiles = [ ]; |
|
77 | 77 | |
78 | - $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); |
|
79 | - $di = new \DirectoryIterator($dir); |
|
78 | + $dir = substr( $testFileBase, 0, strrpos( $testFileBase, DIRECTORY_SEPARATOR ) ); |
|
79 | + $di = new \DirectoryIterator( $dir ); |
|
80 | 80 | |
81 | - foreach ($di as $file) { |
|
81 | + foreach ( $di as $file ) { |
|
82 | 82 | $path = $file->getPathname(); |
83 | - if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { |
|
84 | - if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed' && substr($path, -4) !== '.bak') { |
|
85 | - $testFiles[] = $path; |
|
83 | + if ( substr( $path, 0, strlen( $testFileBase ) ) === $testFileBase ) { |
|
84 | + if ( $path !== $testFileBase . 'php' && substr( $path, -5 ) !== 'fixed' && substr( $path, -4 ) !== '.bak' ) { |
|
85 | + $testFiles[ ] = $path; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Put them in order. |
91 | - sort($testFiles); |
|
91 | + sort( $testFiles ); |
|
92 | 92 | |
93 | 93 | return $testFiles; |
94 | 94 | |
@@ -116,94 +116,94 @@ discard block |
||
116 | 116 | final public function testSniff() |
117 | 117 | { |
118 | 118 | // Skip this test if we can't run in this environment. |
119 | - if ($this->shouldSkipTest() === true) { |
|
119 | + if ( $this->shouldSkipTest() === true ) { |
|
120 | 120 | $this->markTestSkipped(); |
121 | 121 | } |
122 | 122 | |
123 | - $sniffCode = Common::getSniffCode(get_class($this)); |
|
124 | - list($standardName, $categoryName, $sniffName) = explode('.', $sniffCode); |
|
123 | + $sniffCode = Common::getSniffCode( get_class( $this ) ); |
|
124 | + list( $standardName, $categoryName, $sniffName ) = explode( '.', $sniffCode ); |
|
125 | 125 | |
126 | - $testFileBase = $this->testsDir.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'UnitTest.'; |
|
126 | + $testFileBase = $this->testsDir . $categoryName . DIRECTORY_SEPARATOR . $sniffName . 'UnitTest.'; |
|
127 | 127 | |
128 | 128 | // Get a list of all test files to check. |
129 | - $testFiles = $this->getTestFiles($testFileBase); |
|
130 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'][] = $testFiles; |
|
129 | + $testFiles = $this->getTestFiles( $testFileBase ); |
|
130 | + $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CASE_FILES' ][ ] = $testFiles; |
|
131 | 131 | |
132 | - if (isset($GLOBALS['PHP_CODESNIFFER_CONFIG']) === true) { |
|
133 | - $config = $GLOBALS['PHP_CODESNIFFER_CONFIG']; |
|
132 | + if ( isset( $GLOBALS[ 'PHP_CODESNIFFER_CONFIG' ] ) === true ) { |
|
133 | + $config = $GLOBALS[ 'PHP_CODESNIFFER_CONFIG' ]; |
|
134 | 134 | } else { |
135 | 135 | $config = new Config(); |
136 | 136 | $config->cache = false; |
137 | - $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; |
|
137 | + $GLOBALS[ 'PHP_CODESNIFFER_CONFIG' ] = $config; |
|
138 | 138 | } |
139 | 139 | |
140 | - $config->standards = [$standardName]; |
|
141 | - $config->sniffs = [$sniffCode]; |
|
142 | - $config->ignored = []; |
|
140 | + $config->standards = [ $standardName ]; |
|
141 | + $config->sniffs = [ $sniffCode ]; |
|
142 | + $config->ignored = [ ]; |
|
143 | 143 | |
144 | - if (isset($GLOBALS['PHP_CODESNIFFER_RULESETS']) === false) { |
|
145 | - $GLOBALS['PHP_CODESNIFFER_RULESETS'] = []; |
|
144 | + if ( isset( $GLOBALS[ 'PHP_CODESNIFFER_RULESETS' ] ) === false ) { |
|
145 | + $GLOBALS[ 'PHP_CODESNIFFER_RULESETS' ] = [ ]; |
|
146 | 146 | } |
147 | 147 | |
148 | - if (isset($GLOBALS['PHP_CODESNIFFER_RULESETS'][$standardName]) === false) { |
|
149 | - $ruleset = new Ruleset($config); |
|
150 | - $GLOBALS['PHP_CODESNIFFER_RULESETS'][$standardName] = $ruleset; |
|
148 | + if ( isset( $GLOBALS[ 'PHP_CODESNIFFER_RULESETS' ][ $standardName ] ) === false ) { |
|
149 | + $ruleset = new Ruleset( $config ); |
|
150 | + $GLOBALS[ 'PHP_CODESNIFFER_RULESETS' ][ $standardName ] = $ruleset; |
|
151 | 151 | } |
152 | 152 | |
153 | - $ruleset = $GLOBALS['PHP_CODESNIFFER_RULESETS'][$standardName]; |
|
153 | + $ruleset = $GLOBALS[ 'PHP_CODESNIFFER_RULESETS' ][ $standardName ]; |
|
154 | 154 | |
155 | - $sniffFile = $this->standardsDir.DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'Sniff.php'; |
|
155 | + $sniffFile = $this->standardsDir . DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR . $categoryName . DIRECTORY_SEPARATOR . $sniffName . 'Sniff.php'; |
|
156 | 156 | |
157 | - $sniffClassName = substr(get_class($this), 0, -8).'Sniff'; |
|
158 | - $sniffClassName = str_replace('\Tests\\', '\Sniffs\\', $sniffClassName); |
|
159 | - $sniffClassName = Common::cleanSniffClass($sniffClassName); |
|
157 | + $sniffClassName = substr( get_class( $this ), 0, -8 ) . 'Sniff'; |
|
158 | + $sniffClassName = str_replace( '\Tests\\', '\Sniffs\\', $sniffClassName ); |
|
159 | + $sniffClassName = Common::cleanSniffClass( $sniffClassName ); |
|
160 | 160 | |
161 | - $restrictions = [strtolower($sniffClassName) => true]; |
|
162 | - $ruleset->registerSniffs([$sniffFile], $restrictions, []); |
|
161 | + $restrictions = [ strtolower( $sniffClassName ) => true ]; |
|
162 | + $ruleset->registerSniffs( [ $sniffFile ], $restrictions, [ ] ); |
|
163 | 163 | $ruleset->populateTokenListeners(); |
164 | 164 | |
165 | - $failureMessages = []; |
|
166 | - foreach ($testFiles as $testFile) { |
|
167 | - $filename = basename($testFile); |
|
165 | + $failureMessages = [ ]; |
|
166 | + foreach ( $testFiles as $testFile ) { |
|
167 | + $filename = basename( $testFile ); |
|
168 | 168 | $oldConfig = $config->getSettings(); |
169 | 169 | |
170 | 170 | try { |
171 | - $this->setCliValues($filename, $config); |
|
172 | - $phpcsFile = new LocalFile($testFile, $ruleset, $config); |
|
171 | + $this->setCliValues( $filename, $config ); |
|
172 | + $phpcsFile = new LocalFile( $testFile, $ruleset, $config ); |
|
173 | 173 | $phpcsFile->process(); |
174 | - } catch (RuntimeException $e) { |
|
175 | - $this->fail('An unexpected exception has been caught: '.$e->getMessage()); |
|
174 | + } catch ( RuntimeException $e ) { |
|
175 | + $this->fail( 'An unexpected exception has been caught: ' . $e->getMessage() ); |
|
176 | 176 | } |
177 | 177 | |
178 | - $failures = $this->generateFailureMessages($phpcsFile); |
|
179 | - $failureMessages = array_merge($failureMessages, $failures); |
|
178 | + $failures = $this->generateFailureMessages( $phpcsFile ); |
|
179 | + $failureMessages = array_merge( $failureMessages, $failures ); |
|
180 | 180 | |
181 | - if ($phpcsFile->getFixableCount() > 0) { |
|
181 | + if ( $phpcsFile->getFixableCount() > 0 ) { |
|
182 | 182 | // Attempt to fix the errors. |
183 | 183 | $phpcsFile->fixer->fixFile(); |
184 | 184 | $fixable = $phpcsFile->getFixableCount(); |
185 | - if ($fixable > 0) { |
|
186 | - $failureMessages[] = "Failed to fix $fixable fixable violations in $filename"; |
|
185 | + if ( $fixable > 0 ) { |
|
186 | + $failureMessages[ ] = "Failed to fix $fixable fixable violations in $filename"; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for a .fixed file to check for accuracy of fixes. |
190 | - $fixedFile = $testFile.'.fixed'; |
|
191 | - if (file_exists($fixedFile) === true) { |
|
192 | - $diff = $phpcsFile->fixer->generateDiff($fixedFile); |
|
193 | - if (trim($diff) !== '') { |
|
194 | - $filename = basename($testFile); |
|
195 | - $fixedFilename = basename($fixedFile); |
|
196 | - $failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; |
|
190 | + $fixedFile = $testFile . '.fixed'; |
|
191 | + if ( file_exists( $fixedFile ) === true ) { |
|
192 | + $diff = $phpcsFile->fixer->generateDiff( $fixedFile ); |
|
193 | + if ( trim( $diff ) !== '' ) { |
|
194 | + $filename = basename( $testFile ); |
|
195 | + $fixedFilename = basename( $fixedFile ); |
|
196 | + $failureMessages[ ] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Restore the config. |
202 | - $config->setSettings($oldConfig); |
|
202 | + $config->setSettings( $oldConfig ); |
|
203 | 203 | }//end foreach |
204 | 204 | |
205 | - if (empty($failureMessages) === false) { |
|
206 | - $this->fail(implode(PHP_EOL, $failureMessages)); |
|
205 | + if ( empty( $failureMessages ) === false ) { |
|
206 | + $this->fail( implode( PHP_EOL, $failureMessages ) ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | }//end testSniff() |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | * @return array |
218 | 218 | * @throws \PHP_CodeSniffer\Exceptions\RuntimeException |
219 | 219 | */ |
220 | - public function generateFailureMessages(LocalFile $file) |
|
220 | + public function generateFailureMessages( LocalFile $file ) |
|
221 | 221 | { |
222 | 222 | $testFile = $file->getFilename(); |
223 | 223 | |
224 | 224 | $foundErrors = $file->getErrors(); |
225 | 225 | $foundWarnings = $file->getWarnings(); |
226 | - $expectedErrors = $this->getErrorList(basename($testFile)); |
|
227 | - $expectedWarnings = $this->getWarningList(basename($testFile)); |
|
226 | + $expectedErrors = $this->getErrorList( basename( $testFile ) ); |
|
227 | + $expectedWarnings = $this->getWarningList( basename( $testFile ) ); |
|
228 | 228 | |
229 | - if (is_array($expectedErrors) === false) { |
|
230 | - throw new RuntimeException('getErrorList() must return an array'); |
|
229 | + if ( is_array( $expectedErrors ) === false ) { |
|
230 | + throw new RuntimeException( 'getErrorList() must return an array' ); |
|
231 | 231 | } |
232 | 232 | |
233 | - if (is_array($expectedWarnings) === false) { |
|
234 | - throw new RuntimeException('getWarningList() must return an array'); |
|
233 | + if ( is_array( $expectedWarnings ) === false ) { |
|
234 | + throw new RuntimeException( 'getWarningList() must return an array' ); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /* |
@@ -241,167 +241,167 @@ discard block |
||
241 | 241 | it's not really structured to allow that. |
242 | 242 | */ |
243 | 243 | |
244 | - $allProblems = []; |
|
245 | - $failureMessages = []; |
|
244 | + $allProblems = [ ]; |
|
245 | + $failureMessages = [ ]; |
|
246 | 246 | |
247 | - foreach ($foundErrors as $line => $lineErrors) { |
|
248 | - foreach ($lineErrors as $column => $errors) { |
|
249 | - if (isset($allProblems[$line]) === false) { |
|
250 | - $allProblems[$line] = [ |
|
247 | + foreach ( $foundErrors as $line => $lineErrors ) { |
|
248 | + foreach ( $lineErrors as $column => $errors ) { |
|
249 | + if ( isset( $allProblems[ $line ] ) === false ) { |
|
250 | + $allProblems[ $line ] = [ |
|
251 | 251 | 'expected_errors' => 0, |
252 | 252 | 'expected_warnings' => 0, |
253 | - 'found_errors' => [], |
|
254 | - 'found_warnings' => [], |
|
253 | + 'found_errors' => [ ], |
|
254 | + 'found_warnings' => [ ], |
|
255 | 255 | ]; |
256 | 256 | } |
257 | 257 | |
258 | - $foundErrorsTemp = []; |
|
259 | - foreach ($allProblems[$line]['found_errors'] as $foundError) { |
|
260 | - $foundErrorsTemp[] = $foundError; |
|
258 | + $foundErrorsTemp = [ ]; |
|
259 | + foreach ( $allProblems[ $line ][ 'found_errors' ] as $foundError ) { |
|
260 | + $foundErrorsTemp[ ] = $foundError; |
|
261 | 261 | } |
262 | 262 | |
263 | - $errorsTemp = []; |
|
264 | - foreach ($errors as $foundError) { |
|
265 | - $errorsTemp[] = $foundError['message'].' ('.$foundError['source'].')'; |
|
263 | + $errorsTemp = [ ]; |
|
264 | + foreach ( $errors as $foundError ) { |
|
265 | + $errorsTemp[ ] = $foundError[ 'message' ] . ' (' . $foundError[ 'source' ] . ')'; |
|
266 | 266 | |
267 | - $source = $foundError['source']; |
|
268 | - if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'], true) === false) { |
|
269 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'][] = $source; |
|
267 | + $source = $foundError[ 'source' ]; |
|
268 | + if ( in_array( $source, $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CODES' ], true ) === false ) { |
|
269 | + $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CODES' ][ ] = $source; |
|
270 | 270 | } |
271 | 271 | |
272 | - if ($foundError['fixable'] === true |
|
273 | - && in_array($source, $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'], true) === false |
|
272 | + if ( $foundError[ 'fixable' ] === true |
|
273 | + && in_array( $source, $GLOBALS[ 'PHP_CODESNIFFER_FIXABLE_CODES' ], true ) === false |
|
274 | 274 | ) { |
275 | - $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'][] = $source; |
|
275 | + $GLOBALS[ 'PHP_CODESNIFFER_FIXABLE_CODES' ][ ] = $source; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - $allProblems[$line]['found_errors'] = array_merge($foundErrorsTemp, $errorsTemp); |
|
279 | + $allProblems[ $line ][ 'found_errors' ] = array_merge( $foundErrorsTemp, $errorsTemp ); |
|
280 | 280 | }//end foreach |
281 | 281 | |
282 | - if (isset($expectedErrors[$line]) === true) { |
|
283 | - $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; |
|
282 | + if ( isset( $expectedErrors[ $line ] ) === true ) { |
|
283 | + $allProblems[ $line ][ 'expected_errors' ] = $expectedErrors[ $line ]; |
|
284 | 284 | } else { |
285 | - $allProblems[$line]['expected_errors'] = 0; |
|
285 | + $allProblems[ $line ][ 'expected_errors' ] = 0; |
|
286 | 286 | } |
287 | 287 | |
288 | - unset($expectedErrors[$line]); |
|
288 | + unset( $expectedErrors[ $line ] ); |
|
289 | 289 | }//end foreach |
290 | 290 | |
291 | - foreach ($expectedErrors as $line => $numErrors) { |
|
292 | - if (isset($allProblems[$line]) === false) { |
|
293 | - $allProblems[$line] = [ |
|
291 | + foreach ( $expectedErrors as $line => $numErrors ) { |
|
292 | + if ( isset( $allProblems[ $line ] ) === false ) { |
|
293 | + $allProblems[ $line ] = [ |
|
294 | 294 | 'expected_errors' => 0, |
295 | 295 | 'expected_warnings' => 0, |
296 | - 'found_errors' => [], |
|
297 | - 'found_warnings' => [], |
|
296 | + 'found_errors' => [ ], |
|
297 | + 'found_warnings' => [ ], |
|
298 | 298 | ]; |
299 | 299 | } |
300 | 300 | |
301 | - $allProblems[$line]['expected_errors'] = $numErrors; |
|
301 | + $allProblems[ $line ][ 'expected_errors' ] = $numErrors; |
|
302 | 302 | } |
303 | 303 | |
304 | - foreach ($foundWarnings as $line => $lineWarnings) { |
|
305 | - foreach ($lineWarnings as $column => $warnings) { |
|
306 | - if (isset($allProblems[$line]) === false) { |
|
307 | - $allProblems[$line] = [ |
|
304 | + foreach ( $foundWarnings as $line => $lineWarnings ) { |
|
305 | + foreach ( $lineWarnings as $column => $warnings ) { |
|
306 | + if ( isset( $allProblems[ $line ] ) === false ) { |
|
307 | + $allProblems[ $line ] = [ |
|
308 | 308 | 'expected_errors' => 0, |
309 | 309 | 'expected_warnings' => 0, |
310 | - 'found_errors' => [], |
|
311 | - 'found_warnings' => [], |
|
310 | + 'found_errors' => [ ], |
|
311 | + 'found_warnings' => [ ], |
|
312 | 312 | ]; |
313 | 313 | } |
314 | 314 | |
315 | - $foundWarningsTemp = []; |
|
316 | - foreach ($allProblems[$line]['found_warnings'] as $foundWarning) { |
|
317 | - $foundWarningsTemp[] = $foundWarning; |
|
315 | + $foundWarningsTemp = [ ]; |
|
316 | + foreach ( $allProblems[ $line ][ 'found_warnings' ] as $foundWarning ) { |
|
317 | + $foundWarningsTemp[ ] = $foundWarning; |
|
318 | 318 | } |
319 | 319 | |
320 | - $warningsTemp = []; |
|
321 | - foreach ($warnings as $warning) { |
|
322 | - $warningsTemp[] = $warning['message'].' ('.$warning['source'].')'; |
|
320 | + $warningsTemp = [ ]; |
|
321 | + foreach ( $warnings as $warning ) { |
|
322 | + $warningsTemp[ ] = $warning[ 'message' ] . ' (' . $warning[ 'source' ] . ')'; |
|
323 | 323 | } |
324 | 324 | |
325 | - $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp); |
|
325 | + $allProblems[ $line ][ 'found_warnings' ] = array_merge( $foundWarningsTemp, $warningsTemp ); |
|
326 | 326 | }//end foreach |
327 | 327 | |
328 | - if (isset($expectedWarnings[$line]) === true) { |
|
329 | - $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; |
|
328 | + if ( isset( $expectedWarnings[ $line ] ) === true ) { |
|
329 | + $allProblems[ $line ][ 'expected_warnings' ] = $expectedWarnings[ $line ]; |
|
330 | 330 | } else { |
331 | - $allProblems[$line]['expected_warnings'] = 0; |
|
331 | + $allProblems[ $line ][ 'expected_warnings' ] = 0; |
|
332 | 332 | } |
333 | 333 | |
334 | - unset($expectedWarnings[$line]); |
|
334 | + unset( $expectedWarnings[ $line ] ); |
|
335 | 335 | }//end foreach |
336 | 336 | |
337 | - foreach ($expectedWarnings as $line => $numWarnings) { |
|
338 | - if (isset($allProblems[$line]) === false) { |
|
339 | - $allProblems[$line] = [ |
|
337 | + foreach ( $expectedWarnings as $line => $numWarnings ) { |
|
338 | + if ( isset( $allProblems[ $line ] ) === false ) { |
|
339 | + $allProblems[ $line ] = [ |
|
340 | 340 | 'expected_errors' => 0, |
341 | 341 | 'expected_warnings' => 0, |
342 | - 'found_errors' => [], |
|
343 | - 'found_warnings' => [], |
|
342 | + 'found_errors' => [ ], |
|
343 | + 'found_warnings' => [ ], |
|
344 | 344 | ]; |
345 | 345 | } |
346 | 346 | |
347 | - $allProblems[$line]['expected_warnings'] = $numWarnings; |
|
347 | + $allProblems[ $line ][ 'expected_warnings' ] = $numWarnings; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Order the messages by line number. |
351 | - ksort($allProblems); |
|
351 | + ksort( $allProblems ); |
|
352 | 352 | |
353 | - foreach ($allProblems as $line => $problems) { |
|
354 | - $numErrors = count($problems['found_errors']); |
|
355 | - $numWarnings = count($problems['found_warnings']); |
|
356 | - $expectedErrors = $problems['expected_errors']; |
|
357 | - $expectedWarnings = $problems['expected_warnings']; |
|
353 | + foreach ( $allProblems as $line => $problems ) { |
|
354 | + $numErrors = count( $problems[ 'found_errors' ] ); |
|
355 | + $numWarnings = count( $problems[ 'found_warnings' ] ); |
|
356 | + $expectedErrors = $problems[ 'expected_errors' ]; |
|
357 | + $expectedWarnings = $problems[ 'expected_warnings' ]; |
|
358 | 358 | |
359 | 359 | $errors = ''; |
360 | 360 | $foundString = ''; |
361 | 361 | |
362 | - if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { |
|
362 | + if ( $expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings ) { |
|
363 | 363 | $lineMessage = "[LINE $line]"; |
364 | 364 | $expectedMessage = 'Expected '; |
365 | - $foundMessage = 'in '.basename($testFile).' but found '; |
|
365 | + $foundMessage = 'in ' . basename( $testFile ) . ' but found '; |
|
366 | 366 | |
367 | - if ($expectedErrors !== $numErrors) { |
|
367 | + if ( $expectedErrors !== $numErrors ) { |
|
368 | 368 | $expectedMessage .= "$expectedErrors error(s)"; |
369 | 369 | $foundMessage .= "$numErrors error(s)"; |
370 | - if ($numErrors !== 0) { |
|
370 | + if ( $numErrors !== 0 ) { |
|
371 | 371 | $foundString .= 'error(s)'; |
372 | - $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); |
|
372 | + $errors .= implode( PHP_EOL . ' -> ', $problems[ 'found_errors' ] ); |
|
373 | 373 | } |
374 | 374 | |
375 | - if ($expectedWarnings !== $numWarnings) { |
|
375 | + if ( $expectedWarnings !== $numWarnings ) { |
|
376 | 376 | $expectedMessage .= ' and '; |
377 | 377 | $foundMessage .= ' and '; |
378 | - if ($numWarnings !== 0) { |
|
379 | - if ($foundString !== '') { |
|
378 | + if ( $numWarnings !== 0 ) { |
|
379 | + if ( $foundString !== '' ) { |
|
380 | 380 | $foundString .= ' and '; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
386 | - if ($expectedWarnings !== $numWarnings) { |
|
386 | + if ( $expectedWarnings !== $numWarnings ) { |
|
387 | 387 | $expectedMessage .= "$expectedWarnings warning(s)"; |
388 | 388 | $foundMessage .= "$numWarnings warning(s)"; |
389 | - if ($numWarnings !== 0) { |
|
389 | + if ( $numWarnings !== 0 ) { |
|
390 | 390 | $foundString .= 'warning(s)'; |
391 | - if (empty($errors) === false) { |
|
392 | - $errors .= PHP_EOL.' -> '; |
|
391 | + if ( empty( $errors ) === false ) { |
|
392 | + $errors .= PHP_EOL . ' -> '; |
|
393 | 393 | } |
394 | 394 | |
395 | - $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); |
|
395 | + $errors .= implode( PHP_EOL . ' -> ', $problems[ 'found_warnings' ] ); |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
399 | 399 | $fullMessage = "$lineMessage $expectedMessage $foundMessage."; |
400 | - if ($errors !== '') { |
|
401 | - $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; |
|
400 | + if ( $errors !== '' ) { |
|
401 | + $fullMessage .= " The $foundString found were:" . PHP_EOL . " -> $errors"; |
|
402 | 402 | } |
403 | 403 | |
404 | - $failureMessages[] = $fullMessage; |
|
404 | + $failureMessages[ ] = $fullMessage; |
|
405 | 405 | }//end if |
406 | 406 | }//end foreach |
407 | 407 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return void |
420 | 420 | */ |
421 | - public function setCliValues($filename, $config) |
|
421 | + public function setCliValues( $filename, $config ) |
|
422 | 422 | { |
423 | 423 | return; |
424 | 424 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static function main() |
27 | 27 | { |
28 | - TestRunner::run(self::suite()); |
|
28 | + TestRunner::run( self::suite() ); |
|
29 | 29 | |
30 | 30 | }//end main() |
31 | 31 | |
@@ -40,65 +40,65 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function suite() |
42 | 42 | { |
43 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; |
|
44 | - $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; |
|
45 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = []; |
|
43 | + $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CODES' ] = [ ]; |
|
44 | + $GLOBALS[ 'PHP_CODESNIFFER_FIXABLE_CODES' ] = [ ]; |
|
45 | + $GLOBALS[ 'PHP_CODESNIFFER_SNIFF_CASE_FILES' ] = [ ]; |
|
46 | 46 | |
47 | - $suite = new TestSuite('PHP CodeSniffer Standards'); |
|
47 | + $suite = new TestSuite( 'PHP CodeSniffer Standards' ); |
|
48 | 48 | |
49 | - $isInstalled = !is_file(__DIR__.'/../../autoload.php'); |
|
49 | + $isInstalled = ! is_file( __DIR__ . '/../../autoload.php' ); |
|
50 | 50 | |
51 | 51 | // Optionally allow for ignoring the tests for one or more standards. |
52 | - $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS'); |
|
53 | - if ($ignoreTestsForStandards === false) { |
|
54 | - $ignoreTestsForStandards = []; |
|
52 | + $ignoreTestsForStandards = getenv( 'PHPCS_IGNORE_TESTS' ); |
|
53 | + if ( $ignoreTestsForStandards === false ) { |
|
54 | + $ignoreTestsForStandards = [ ]; |
|
55 | 55 | } else { |
56 | - $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards); |
|
56 | + $ignoreTestsForStandards = explode( ',', $ignoreTestsForStandards ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $installedStandards = self::getInstalledStandardDetails(); |
60 | 60 | |
61 | - foreach ($installedStandards as $standard => $details) { |
|
62 | - Autoload::addSearchPath($details['path'], $details['namespace']); |
|
61 | + foreach ( $installedStandards as $standard => $details ) { |
|
62 | + Autoload::addSearchPath( $details[ 'path' ], $details[ 'namespace' ] ); |
|
63 | 63 | |
64 | 64 | // If the test is running PEAR installed, the built-in standards |
65 | 65 | // are split into different directories; one for the sniffs and |
66 | 66 | // a different file system location for tests. |
67 | - if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) { |
|
68 | - $testPath = realpath(__DIR__.'/../../src/Standards/'.$standard); |
|
67 | + if ( $isInstalled === true && is_dir( dirname( $details[ 'path' ] ) . DIRECTORY_SEPARATOR . 'Generic' ) === true ) { |
|
68 | + $testPath = realpath( __DIR__ . '/../../src/Standards/' . $standard ); |
|
69 | 69 | } else { |
70 | - $testPath = $details['path']; |
|
70 | + $testPath = $details[ 'path' ]; |
|
71 | 71 | } |
72 | 72 | |
73 | - if (in_array($standard, $ignoreTestsForStandards, true) === true) { |
|
73 | + if ( in_array( $standard, $ignoreTestsForStandards, true ) === true ) { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | |
77 | - $testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; |
|
78 | - if (is_dir($testsDir) === false) { |
|
77 | + $testsDir = $testPath . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR; |
|
78 | + if ( is_dir( $testsDir ) === false ) { |
|
79 | 79 | // No tests for this standard. |
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | |
83 | - $di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir)); |
|
83 | + $di = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $testsDir ) ); |
|
84 | 84 | |
85 | - foreach ($di as $file) { |
|
85 | + foreach ( $di as $file ) { |
|
86 | 86 | // Skip hidden files. |
87 | - if (substr($file->getFilename(), 0, 1) === '.') { |
|
87 | + if ( substr( $file->getFilename(), 0, 1 ) === '.' ) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Tests must have the extension 'php'. |
92 | - $parts = explode('.', $file); |
|
93 | - $ext = array_pop($parts); |
|
94 | - if ($ext !== 'php') { |
|
92 | + $parts = explode( '.', $file ); |
|
93 | + $ext = array_pop( $parts ); |
|
94 | + if ( $ext !== 'php' ) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
98 | - $className = Autoload::loadFile($file->getPathname()); |
|
99 | - $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path']; |
|
100 | - $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className] = $testsDir; |
|
101 | - $suite->addTestSuite($className); |
|
98 | + $className = Autoload::loadFile( $file->getPathname() ); |
|
99 | + $GLOBALS[ 'PHP_CODESNIFFER_STANDARD_DIRS' ][ $className ] = $details[ 'path' ]; |
|
100 | + $GLOBALS[ 'PHP_CODESNIFFER_TEST_DIRS' ][ $className ] = $testsDir; |
|
101 | + $suite->addTestSuite( $className ); |
|
102 | 102 | } |
103 | 103 | }//end foreach |
104 | 104 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected static function getInstalledStandardDetails() |
117 | 117 | { |
118 | - return Standards::getInstalledStandardDetails(true); |
|
118 | + return Standards::getInstalledStandardDetails( true ); |
|
119 | 119 | |
120 | 120 | }//end getInstalledStandardDetails() |
121 | 121 |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function testValidNotClassFormatPublic() |
25 | 25 | { |
26 | - $this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true)); |
|
27 | - $this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false)); |
|
26 | + $this->assertTrue( Common::isCamelCaps( 'thisIsCamelCaps', false, true, true ) ); |
|
27 | + $this->assertTrue( Common::isCamelCaps( 'thisISCamelCaps', false, true, false ) ); |
|
28 | 28 | |
29 | 29 | }//end testValidNotClassFormatPublic() |
30 | 30 | |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function testInvalidNotClassFormatPublic() |
38 | 38 | { |
39 | - $this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true)); |
|
40 | - $this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true)); |
|
41 | - $this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true)); |
|
39 | + $this->assertFalse( Common::isCamelCaps( '_thisIsCamelCaps', false, true, true ) ); |
|
40 | + $this->assertFalse( Common::isCamelCaps( 'thisISCamelCaps', false, true, true ) ); |
|
41 | + $this->assertFalse( Common::isCamelCaps( 'ThisIsCamelCaps', false, true, true ) ); |
|
42 | 42 | |
43 | - $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, true, true)); |
|
44 | - $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, true, true)); |
|
45 | - $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, true, true)); |
|
43 | + $this->assertFalse( Common::isCamelCaps( '3thisIsCamelCaps', false, true, true ) ); |
|
44 | + $this->assertFalse( Common::isCamelCaps( '*thisIsCamelCaps', false, true, true ) ); |
|
45 | + $this->assertFalse( Common::isCamelCaps( '-thisIsCamelCaps', false, true, true ) ); |
|
46 | 46 | |
47 | - $this->assertFalse(Common::isCamelCaps('this*IsCamelCaps', false, true, true)); |
|
48 | - $this->assertFalse(Common::isCamelCaps('this-IsCamelCaps', false, true, true)); |
|
49 | - $this->assertFalse(Common::isCamelCaps('this_IsCamelCaps', false, true, true)); |
|
50 | - $this->assertFalse(Common::isCamelCaps('this_is_camel_caps', false, true, true)); |
|
47 | + $this->assertFalse( Common::isCamelCaps( 'this*IsCamelCaps', false, true, true ) ); |
|
48 | + $this->assertFalse( Common::isCamelCaps( 'this-IsCamelCaps', false, true, true ) ); |
|
49 | + $this->assertFalse( Common::isCamelCaps( 'this_IsCamelCaps', false, true, true ) ); |
|
50 | + $this->assertFalse( Common::isCamelCaps( 'this_is_camel_caps', false, true, true ) ); |
|
51 | 51 | |
52 | 52 | }//end testInvalidNotClassFormatPublic() |
53 | 53 | |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function testValidNotClassFormatPrivate() |
61 | 61 | { |
62 | - $this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true)); |
|
63 | - $this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false)); |
|
64 | - $this->assertTrue(Common::isCamelCaps('_i18N', false, false, true)); |
|
65 | - $this->assertTrue(Common::isCamelCaps('_i18n', false, false, true)); |
|
62 | + $this->assertTrue( Common::isCamelCaps( '_thisIsCamelCaps', false, false, true ) ); |
|
63 | + $this->assertTrue( Common::isCamelCaps( '_thisISCamelCaps', false, false, false ) ); |
|
64 | + $this->assertTrue( Common::isCamelCaps( '_i18N', false, false, true ) ); |
|
65 | + $this->assertTrue( Common::isCamelCaps( '_i18n', false, false, true ) ); |
|
66 | 66 | |
67 | 67 | }//end testValidNotClassFormatPrivate() |
68 | 68 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function testInvalidNotClassFormatPrivate() |
76 | 76 | { |
77 | - $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true)); |
|
78 | - $this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true)); |
|
79 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true)); |
|
80 | - $this->assertFalse(Common::isCamelCaps('__thisIsCamelCaps', false, false, true)); |
|
81 | - $this->assertFalse(Common::isCamelCaps('__thisISCamelCaps', false, false, false)); |
|
77 | + $this->assertFalse( Common::isCamelCaps( 'thisIsCamelCaps', false, false, true ) ); |
|
78 | + $this->assertFalse( Common::isCamelCaps( '_thisISCamelCaps', false, false, true ) ); |
|
79 | + $this->assertFalse( Common::isCamelCaps( '_ThisIsCamelCaps', false, false, true ) ); |
|
80 | + $this->assertFalse( Common::isCamelCaps( '__thisIsCamelCaps', false, false, true ) ); |
|
81 | + $this->assertFalse( Common::isCamelCaps( '__thisISCamelCaps', false, false, false ) ); |
|
82 | 82 | |
83 | - $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, false, true)); |
|
84 | - $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, false, true)); |
|
85 | - $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, false, true)); |
|
86 | - $this->assertFalse(Common::isCamelCaps('_this_is_camel_caps', false, false, true)); |
|
83 | + $this->assertFalse( Common::isCamelCaps( '3thisIsCamelCaps', false, false, true ) ); |
|
84 | + $this->assertFalse( Common::isCamelCaps( '*thisIsCamelCaps', false, false, true ) ); |
|
85 | + $this->assertFalse( Common::isCamelCaps( '-thisIsCamelCaps', false, false, true ) ); |
|
86 | + $this->assertFalse( Common::isCamelCaps( '_this_is_camel_caps', false, false, true ) ); |
|
87 | 87 | |
88 | 88 | }//end testInvalidNotClassFormatPrivate() |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function testValidClassFormatPublic() |
97 | 97 | { |
98 | - $this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true)); |
|
99 | - $this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false)); |
|
100 | - $this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false)); |
|
98 | + $this->assertTrue( Common::isCamelCaps( 'ThisIsCamelCaps', true, true, true ) ); |
|
99 | + $this->assertTrue( Common::isCamelCaps( 'ThisISCamelCaps', true, true, false ) ); |
|
100 | + $this->assertTrue( Common::isCamelCaps( 'This3IsCamelCaps', true, true, false ) ); |
|
101 | 101 | |
102 | 102 | }//end testValidClassFormatPublic() |
103 | 103 | |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function testInvalidClassFormat() |
111 | 111 | { |
112 | - $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true)); |
|
113 | - $this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true)); |
|
114 | - $this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true)); |
|
112 | + $this->assertFalse( Common::isCamelCaps( 'thisIsCamelCaps', true ) ); |
|
113 | + $this->assertFalse( Common::isCamelCaps( 'This-IsCamelCaps', true ) ); |
|
114 | + $this->assertFalse( Common::isCamelCaps( 'This_Is_Camel_Caps', true ) ); |
|
115 | 115 | |
116 | 116 | }//end testInvalidClassFormat() |
117 | 117 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function testInvalidClassFormatPrivate() |
128 | 128 | { |
129 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true)); |
|
130 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false)); |
|
129 | + $this->assertFalse( Common::isCamelCaps( '_ThisIsCamelCaps', true, true ) ); |
|
130 | + $this->assertFalse( Common::isCamelCaps( '_ThisIsCamelCaps', true, false ) ); |
|
131 | 131 | |
132 | 132 | }//end testInvalidClassFormatPrivate() |
133 | 133 |
@@ -4,25 +4,25 @@ |
||
4 | 4 | $a = false; |
5 | 5 | |
6 | 6 | /* testControlStructure */ |
7 | -while(true) {} |
|
7 | +while ( true ) {} |
|
8 | 8 | $a = 1; |
9 | 9 | |
10 | 10 | /* testClosureAssignment */ |
11 | -$a = function($b=false;){}; |
|
11 | +$a = function( $b = false; ) {}; |
|
12 | 12 | |
13 | 13 | /* testHeredocFunctionArg */ |
14 | -myFunction(<<<END |
|
14 | +myFunction( <<<END |
|
15 | 15 | Foo |
16 | 16 | END |
17 | -, 'bar'); |
|
17 | +, 'bar' ); |
|
18 | 18 | |
19 | 19 | /* testSwitch */ |
20 | -switch ($a) { |
|
21 | - case 1: {break;} |
|
22 | - default: {break;} |
|
20 | +switch ( $a ) { |
|
21 | + case 1: {break; } |
|
22 | + default: {break; } |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /* testStatementAsArrayValue */ |
26 | -$a = [new Datetime]; |
|
27 | -$a = array(new Datetime); |
|
26 | +$a = [ new Datetime ]; |
|
27 | +$a = array( new Datetime ); |
|
28 | 28 | $a = new Datetime; |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function testSimpleAssignment() |
68 | 68 | { |
69 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSimpleAssignment */') + 2); |
|
70 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
69 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testSimpleAssignment */' ) + 2 ); |
|
70 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
71 | 71 | |
72 | 72 | $tokens = $this->phpcsFile->getTokens(); |
73 | - $this->assertSame($tokens[($start + 5)], $tokens[$found]); |
|
73 | + $this->assertSame( $tokens[ ( $start + 5 ) ], $tokens[ $found ] ); |
|
74 | 74 | |
75 | 75 | }//end testSimpleAssignment() |
76 | 76 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function testControlStructure() |
84 | 84 | { |
85 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testControlStructure */') + 2); |
|
86 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
85 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testControlStructure */' ) + 2 ); |
|
86 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
87 | 87 | |
88 | 88 | $tokens = $this->phpcsFile->getTokens(); |
89 | - $this->assertSame($tokens[($start + 6)], $tokens[$found]); |
|
89 | + $this->assertSame( $tokens[ ( $start + 6 ) ], $tokens[ $found ] ); |
|
90 | 90 | |
91 | 91 | }//end testControlStructure() |
92 | 92 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function testClosureAssignment() |
100 | 100 | { |
101 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testClosureAssignment */') + 2); |
|
102 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
101 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testClosureAssignment */' ) + 2 ); |
|
102 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
103 | 103 | |
104 | 104 | $tokens = $this->phpcsFile->getTokens(); |
105 | - $this->assertSame($tokens[($start + 13)], $tokens[$found]); |
|
105 | + $this->assertSame( $tokens[ ( $start + 13 ) ], $tokens[ $found ] ); |
|
106 | 106 | |
107 | 107 | }//end testClosureAssignment() |
108 | 108 | |
@@ -115,25 +115,25 @@ discard block |
||
115 | 115 | public function testHeredocFunctionArg() |
116 | 116 | { |
117 | 117 | // Find the end of the function. |
118 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testHeredocFunctionArg */') + 2); |
|
119 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
118 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testHeredocFunctionArg */' ) + 2 ); |
|
119 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
120 | 120 | |
121 | 121 | $tokens = $this->phpcsFile->getTokens(); |
122 | - $this->assertSame($tokens[($start + 10)], $tokens[$found]); |
|
122 | + $this->assertSame( $tokens[ ( $start + 10 ) ], $tokens[ $found ] ); |
|
123 | 123 | |
124 | 124 | // Find the end of the heredoc. |
125 | 125 | $start += 2; |
126 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
126 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
127 | 127 | |
128 | 128 | $tokens = $this->phpcsFile->getTokens(); |
129 | - $this->assertSame($tokens[($start + 4)], $tokens[$found]); |
|
129 | + $this->assertSame( $tokens[ ( $start + 4 ) ], $tokens[ $found ] ); |
|
130 | 130 | |
131 | 131 | // Find the end of the last arg. |
132 | - $start = ($found + 2); |
|
133 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
132 | + $start = ( $found + 2 ); |
|
133 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
134 | 134 | |
135 | 135 | $tokens = $this->phpcsFile->getTokens(); |
136 | - $this->assertSame($tokens[$start], $tokens[$found]); |
|
136 | + $this->assertSame( $tokens[ $start ], $tokens[ $found ] ); |
|
137 | 137 | |
138 | 138 | }//end testHeredocFunctionArg() |
139 | 139 | |
@@ -146,25 +146,25 @@ discard block |
||
146 | 146 | public function testSwitch() |
147 | 147 | { |
148 | 148 | // Find the end of the switch. |
149 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSwitch */') + 2); |
|
150 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
149 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testSwitch */' ) + 2 ); |
|
150 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
151 | 151 | |
152 | 152 | $tokens = $this->phpcsFile->getTokens(); |
153 | - $this->assertSame($tokens[($start + 28)], $tokens[$found]); |
|
153 | + $this->assertSame( $tokens[ ( $start + 28 ) ], $tokens[ $found ] ); |
|
154 | 154 | |
155 | 155 | // Find the end of the case. |
156 | 156 | $start += 9; |
157 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
157 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
158 | 158 | |
159 | 159 | $tokens = $this->phpcsFile->getTokens(); |
160 | - $this->assertSame($tokens[($start + 8)], $tokens[$found]); |
|
160 | + $this->assertSame( $tokens[ ( $start + 8 ) ], $tokens[ $found ] ); |
|
161 | 161 | |
162 | 162 | // Find the end of default case. |
163 | 163 | $start += 11; |
164 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
164 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
165 | 165 | |
166 | 166 | $tokens = $this->phpcsFile->getTokens(); |
167 | - $this->assertSame($tokens[($start + 6)], $tokens[$found]); |
|
167 | + $this->assertSame( $tokens[ ( $start + 6 ) ], $tokens[ $found ] ); |
|
168 | 168 | |
169 | 169 | }//end testSwitch() |
170 | 170 | |
@@ -177,25 +177,25 @@ discard block |
||
177 | 177 | public function testStatementAsArrayValue() |
178 | 178 | { |
179 | 179 | // Test short array syntax. |
180 | - $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testStatementAsArrayValue */') + 7); |
|
181 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
180 | + $start = ( $this->phpcsFile->findNext( T_COMMENT, 0, null, false, '/* testStatementAsArrayValue */' ) + 7 ); |
|
181 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
182 | 182 | |
183 | 183 | $tokens = $this->phpcsFile->getTokens(); |
184 | - $this->assertSame($tokens[($start + 2)], $tokens[$found]); |
|
184 | + $this->assertSame( $tokens[ ( $start + 2 ) ], $tokens[ $found ] ); |
|
185 | 185 | |
186 | 186 | // Test long array syntax. |
187 | 187 | $start += 12; |
188 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
188 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
189 | 189 | |
190 | 190 | $tokens = $this->phpcsFile->getTokens(); |
191 | - $this->assertSame($tokens[($start + 2)], $tokens[$found]); |
|
191 | + $this->assertSame( $tokens[ ( $start + 2 ) ], $tokens[ $found ] ); |
|
192 | 192 | |
193 | 193 | // Test same statement outside of array. |
194 | 194 | $start += 10; |
195 | - $found = $this->phpcsFile->findEndOfStatement($start); |
|
195 | + $found = $this->phpcsFile->findEndOfStatement( $start ); |
|
196 | 196 | |
197 | 197 | $tokens = $this->phpcsFile->getTokens(); |
198 | - $this->assertSame($tokens[($start + 3)], $tokens[$found]); |
|
198 | + $this->assertSame( $tokens[ ( $start + 3 ) ], $tokens[ $found ] ); |
|
199 | 199 | |
200 | 200 | }//end testStatementAsArrayValue() |
201 | 201 |
@@ -1,29 +1,29 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /* testPassByReference */ |
4 | -function passByReference(&$var) {} |
|
4 | +function passByReference( &$var ) {} |
|
5 | 5 | |
6 | 6 | /* testArrayHint */ |
7 | -function arrayHint(array $var) {} |
|
7 | +function arrayHint( array $var ) {} |
|
8 | 8 | |
9 | 9 | /* testVariable */ |
10 | -function variable($var) {} |
|
10 | +function variable( $var ) {} |
|
11 | 11 | |
12 | 12 | /* testSingleDefaultValue */ |
13 | -function defaultValue($var1=self::CONSTANT) {} |
|
13 | +function defaultValue( $var1 = self::CONSTANT ) {} |
|
14 | 14 | |
15 | 15 | /* testDefaultValues */ |
16 | -function defaultValues($var1=1, $var2='value') {} |
|
16 | +function defaultValues( $var1 = 1, $var2 = 'value' ) {} |
|
17 | 17 | |
18 | 18 | /* testTypeHint */ |
19 | -function typeHint(foo $var1, bar $var2) {} |
|
19 | +function typeHint( foo $var1, bar $var2 ) {} |
|
20 | 20 | |
21 | 21 | class MyClass { |
22 | -/* testSelfTypeHint */ function typeSelfHint(self $var) {} |
|
22 | +/* testSelfTypeHint */ function typeSelfHint( self $var ) {} |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /* testNullableTypeHint */ |
26 | -function nullableTypeHint(?int $var1, ?\bar $var2) {} |
|
26 | +function nullableTypeHint( ?int $var1, ?\bar $var2 ) {} |
|
27 | 27 | |
28 | 28 | /* testBitwiseAndConstantExpressionDefaultValue */ |
29 | -function myFunction($a = 10 & 20) {} |
|
29 | +function myFunction( $a = 10 & 20 ) {} |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | /* testMethodParam */ |
95 | - public function methodName($param) { |
|
95 | + public function methodName( $param ) { |
|
96 | 96 | /* testImportedGlobal */ |
97 | 97 | global $importedGlobal = true; |
98 | 98 | |
@@ -117,13 +117,12 @@ discard block |
||
117 | 117 | /* testNotAVariable */ |
118 | 118 | return; |
119 | 119 | |
120 | -$a = ( $foo == $bar ? new stdClass() : |
|
121 | - new class() { |
|
120 | +$a = ( $foo == $bar ? new stdClass() : new class() { |
|
122 | 121 | /* testNestedProperty 1 */ |
123 | 122 | public $var = true; |
124 | 123 | |
125 | 124 | /* testNestedMethodParam 1 */ |
126 | - public function something($var = false) {} |
|
125 | + public function something( $var = false ) {} |
|
127 | 126 | } |
128 | 127 | ); |
129 | 128 |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - public function testGetMemberProperties($identifier, $expected) |
|
72 | + public function testGetMemberProperties( $identifier, $expected ) |
|
73 | 73 | { |
74 | - $start = ($this->phpcsFile->numTokens - 1); |
|
74 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
75 | 75 | $delim = $this->phpcsFile->findPrevious( |
76 | 76 | T_COMMENT, |
77 | 77 | $start, |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | false, |
80 | 80 | $identifier |
81 | 81 | ); |
82 | - $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1)); |
|
82 | + $variable = $this->phpcsFile->findNext( T_VARIABLE, ( $delim + 1 ) ); |
|
83 | 83 | |
84 | - $result = $this->phpcsFile->getMemberProperties($variable); |
|
85 | - $this->assertSame($expected, $result); |
|
84 | + $result = $this->phpcsFile->getMemberProperties( $variable ); |
|
85 | + $this->assertSame( $expected, $result ); |
|
86 | 86 | |
87 | 87 | }//end testGetMemberProperties() |
88 | 88 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | ], |
300 | 300 | [ |
301 | 301 | '/* testInterfaceProperty */', |
302 | - [], |
|
302 | + [ ], |
|
303 | 303 | ], |
304 | 304 | [ |
305 | 305 | '/* testNestedProperty 1 */', |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return void |
336 | 336 | */ |
337 | - public function testNotClassPropertyException($identifier) |
|
337 | + public function testNotClassPropertyException( $identifier ) |
|
338 | 338 | { |
339 | - $start = ($this->phpcsFile->numTokens - 1); |
|
339 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
340 | 340 | $delim = $this->phpcsFile->findPrevious( |
341 | 341 | T_COMMENT, |
342 | 342 | $start, |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | false, |
345 | 345 | $identifier |
346 | 346 | ); |
347 | - $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1)); |
|
347 | + $variable = $this->phpcsFile->findNext( T_VARIABLE, ( $delim + 1 ) ); |
|
348 | 348 | |
349 | - $result = $this->phpcsFile->getMemberProperties($variable); |
|
349 | + $result = $this->phpcsFile->getMemberProperties( $variable ); |
|
350 | 350 | |
351 | 351 | }//end testNotClassPropertyException() |
352 | 352 | |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | public function dataNotClassProperty() |
362 | 362 | { |
363 | 363 | return [ |
364 | - ['/* testMethodParam */'], |
|
365 | - ['/* testImportedGlobal */'], |
|
366 | - ['/* testLocalVariable */'], |
|
367 | - ['/* testGlobalVariable */'], |
|
368 | - ['/* testNestedMethodParam 1 */'], |
|
369 | - ['/* testNestedMethodParam 2 */'], |
|
364 | + [ '/* testMethodParam */' ], |
|
365 | + [ '/* testImportedGlobal */' ], |
|
366 | + [ '/* testLocalVariable */' ], |
|
367 | + [ '/* testGlobalVariable */' ], |
|
368 | + [ '/* testNestedMethodParam 1 */' ], |
|
369 | + [ '/* testNestedMethodParam 2 */' ], |
|
370 | 370 | ]; |
371 | 371 | |
372 | 372 | }//end dataNotClassProperty() |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function testNotAVariableException() |
384 | 384 | { |
385 | - $start = ($this->phpcsFile->numTokens - 1); |
|
385 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
386 | 386 | $delim = $this->phpcsFile->findPrevious( |
387 | 387 | T_COMMENT, |
388 | 388 | $start, |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | false, |
391 | 391 | '/* testNotAVariable */' |
392 | 392 | ); |
393 | - $next = $this->phpcsFile->findNext(T_WHITESPACE, ($delim + 1), null, true); |
|
393 | + $next = $this->phpcsFile->findNext( T_WHITESPACE, ( $delim + 1 ), null, true ); |
|
394 | 394 | |
395 | - $result = $this->phpcsFile->getMemberProperties($next); |
|
395 | + $result = $this->phpcsFile->getMemberProperties( $next ); |
|
396 | 396 | |
397 | 397 | }//end testNotAVariableException() |
398 | 398 |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - public function testFindExtendedClassName($identifier, $expected) |
|
73 | + public function testFindExtendedClassName( $identifier, $expected ) |
|
74 | 74 | { |
75 | - $start = ($this->phpcsFile->numTokens - 1); |
|
75 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
76 | 76 | $delim = $this->phpcsFile->findPrevious( |
77 | 77 | T_COMMENT, |
78 | 78 | $start, |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | false, |
81 | 81 | $identifier |
82 | 82 | ); |
83 | - $OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1)); |
|
83 | + $OOToken = $this->phpcsFile->findNext( [ T_CLASS, T_ANON_CLASS, T_INTERFACE ], ( $delim + 1 ) ); |
|
84 | 84 | |
85 | - $result = $this->phpcsFile->findExtendedClassName($OOToken); |
|
86 | - $this->assertSame($expected, $result); |
|
85 | + $result = $this->phpcsFile->findExtendedClassName( $OOToken ); |
|
86 | + $this->assertSame( $expected, $result ); |
|
87 | 87 | |
88 | 88 | }//end testFindExtendedClassName() |
89 | 89 |