@@ -79,9 +79,9 @@ |
||
79 | 79 | |
80 | 80 | $lastLine++; |
81 | 81 | $lineTokens[$lastLine] = array( |
82 | - 'start' => $stackPtr, |
|
83 | - 'end' => null, |
|
84 | - ); |
|
82 | + 'start' => $stackPtr, |
|
83 | + 'end' => null, |
|
84 | + ); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
34 | 34 | { |
35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $totalErrors, |
334 | 334 | $totalWarnings, |
335 | 335 | $totalFixable, |
336 | - $showSources=false, |
|
337 | - $width=80, |
|
338 | - $interactive=false, |
|
339 | - $toScreen=true |
|
336 | + $showSources = false, |
|
337 | + $width = 80, |
|
338 | + $interactive = false, |
|
339 | + $toScreen = true |
|
340 | 340 | ) { |
341 | 341 | if ($cachedData === '') { |
342 | 342 | return; |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * its data should be counted in the grand totals. |
25 | 25 | * |
26 | 26 | * @param array $report Prepared report data. |
27 | - * @param \Symplify\PHP7_CodeSniffer\File $phpcsFile The file being reported on. |
|
27 | + * @param File $phpcsFile The file being reported on. |
|
28 | 28 | * @param bool $showSources Show sources? |
29 | 29 | * @param int $width Maximum allowed line width. |
30 | 30 | * |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
34 | 34 | { |
35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $totalErrors, |
334 | 334 | $totalWarnings, |
335 | 335 | $totalFixable, |
336 | - $showSources=false, |
|
337 | - $width=80, |
|
338 | - $interactive=false, |
|
339 | - $toScreen=true |
|
336 | + $showSources = false, |
|
337 | + $width = 80, |
|
338 | + $interactive = false, |
|
339 | + $toScreen = true |
|
340 | 340 | ) { |
341 | 341 | if ($cachedData === '') { |
342 | 342 | return; |
@@ -10,7 +10,6 @@ |
||
10 | 10 | namespace Symplify\PHP7_CodeSniffer\Reports; |
11 | 11 | |
12 | 12 | use Symplify\PHP7_CodeSniffer\Files\File; |
13 | -use Symplify\PHP7_CodeSniffer\Util; |
|
14 | 13 | |
15 | 14 | class Diff implements Report |
16 | 15 | { |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * its data should be counted in the grand totals. |
25 | 25 | * |
26 | 26 | * @param array $report Prepared report data. |
27 | - * @param \Symplify\PHP7_CodeSniffer\File $phpcsFile The file being reported on. |
|
27 | + * @param File $phpcsFile The file being reported on. |
|
28 | 28 | * @param bool $showSources Show sources? |
29 | 29 | * @param int $width Maximum allowed line width. |
30 | 30 | * |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
34 | 34 | { |
35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $totalErrors, |
334 | 334 | $totalWarnings, |
335 | 335 | $totalFixable, |
336 | - $showSources=false, |
|
337 | - $width=80, |
|
338 | - $interactive=false, |
|
339 | - $toScreen=true |
|
336 | + $showSources = false, |
|
337 | + $width = 80, |
|
338 | + $interactive = false, |
|
339 | + $toScreen = true |
|
340 | 340 | ) { |
341 | 341 | if ($cachedData === '') { |
342 | 342 | return; |
@@ -27,11 +27,11 @@ |
||
27 | 27 | * its data should be counted in the grand totals. |
28 | 28 | * |
29 | 29 | * @param array $report Prepared report data. |
30 | - * @param \Symplify\PHP7_CodeSniffer\File $phpcsFile The file being reported on. |
|
30 | + * @param File $phpcsFile The file being reported on. |
|
31 | 31 | * @param bool $showSources Show sources? |
32 | 32 | * @param int $width Maximum allowed line width. |
33 | 33 | * |
34 | - * @return bool |
|
34 | + * @return null|boolean |
|
35 | 35 | */ |
36 | 36 | public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
37 | 37 | { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
34 | 34 | { |
35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $totalErrors, |
334 | 334 | $totalWarnings, |
335 | 335 | $totalFixable, |
336 | - $showSources=false, |
|
337 | - $width=80, |
|
338 | - $interactive=false, |
|
339 | - $toScreen=true |
|
336 | + $showSources = false, |
|
337 | + $width = 80, |
|
338 | + $interactive = false, |
|
339 | + $toScreen = true |
|
340 | 340 | ) { |
341 | 341 | if ($cachedData === '') { |
342 | 342 | return; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
34 | 34 | { |
35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $totalErrors, |
334 | 334 | $totalWarnings, |
335 | 335 | $totalFixable, |
336 | - $showSources=false, |
|
337 | - $width=80, |
|
338 | - $interactive=false, |
|
339 | - $toScreen=true |
|
336 | + $showSources = false, |
|
337 | + $width = 80, |
|
338 | + $interactive = false, |
|
339 | + $toScreen = true |
|
340 | 340 | ) { |
341 | 341 | if ($cachedData === '') { |
342 | 342 | return; |
@@ -51,9 +51,9 @@ |
||
51 | 51 | |
52 | 52 | if (substr($class, 0, 16) === 'PHP_CodeSniffer\\') { |
53 | 53 | if (substr($class, 0, 22) === 'PHP_CodeSniffer\Tests\\') { |
54 | - $path = __DIR__ . $ds .$ds.substr(str_replace('\\', $ds, $class), 22).'.php'; |
|
54 | + $path = __DIR__.$ds.$ds.substr(str_replace('\\', $ds, $class), 22).'.php'; |
|
55 | 55 | } else { |
56 | - $path = __DIR__ . $ds .$ds.substr(str_replace('\\', $ds, $class), 16).'.php'; |
|
56 | + $path = __DIR__.$ds.$ds.substr(str_replace('\\', $ds, $class), 16).'.php'; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 |
@@ -76,31 +76,31 @@ discard block |
||
76 | 76 | * @var array<string, mixed> |
77 | 77 | */ |
78 | 78 | private $settings = array( |
79 | - 'files' => null, |
|
80 | - 'standards' => null, |
|
81 | - 'verbosity' => null, |
|
82 | - 'interactive' => null, |
|
83 | - 'explain' => null, |
|
84 | - 'local' => null, |
|
85 | - 'showSources' => null, |
|
86 | - 'showProgress' => null, |
|
87 | - 'tabWidth' => null, |
|
88 | - 'extensions' => null, |
|
89 | - 'sniffs' => null, |
|
90 | - 'ignored' => null, |
|
91 | - 'reportFile' => null, |
|
92 | - 'filter' => null, |
|
93 | - 'bootstrap' => null, |
|
94 | - 'reports' => null, |
|
95 | - 'basepath' => null, |
|
96 | - 'reportWidth' => null, |
|
97 | - 'errorSeverity' => null, |
|
98 | - 'warningSeverity' => null, |
|
99 | - 'recordErrors' => null, |
|
100 | - 'suffix' => null, |
|
101 | - 'stdin' => null, |
|
102 | - 'stdinContent' => null, |
|
103 | - 'stdinPath' => null, |
|
79 | + 'files' => null, |
|
80 | + 'standards' => null, |
|
81 | + 'verbosity' => null, |
|
82 | + 'interactive' => null, |
|
83 | + 'explain' => null, |
|
84 | + 'local' => null, |
|
85 | + 'showSources' => null, |
|
86 | + 'showProgress' => null, |
|
87 | + 'tabWidth' => null, |
|
88 | + 'extensions' => null, |
|
89 | + 'sniffs' => null, |
|
90 | + 'ignored' => null, |
|
91 | + 'reportFile' => null, |
|
92 | + 'filter' => null, |
|
93 | + 'bootstrap' => null, |
|
94 | + 'reports' => null, |
|
95 | + 'basepath' => null, |
|
96 | + 'reportWidth' => null, |
|
97 | + 'errorSeverity' => null, |
|
98 | + 'warningSeverity' => null, |
|
99 | + 'recordErrors' => null, |
|
100 | + 'suffix' => null, |
|
101 | + 'stdin' => null, |
|
102 | + 'stdinContent' => null, |
|
103 | + 'stdinPath' => null, |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | /** |
@@ -393,11 +393,11 @@ discard block |
||
393 | 393 | $this->showProgress = false; |
394 | 394 | $this->tabWidth = 0; |
395 | 395 | $this->extensions = array( |
396 | - 'php' => 'PHP', |
|
397 | - 'inc' => 'PHP', |
|
398 | - 'js' => 'JS', |
|
399 | - 'css' => 'CSS', |
|
400 | - ); |
|
396 | + 'php' => 'PHP', |
|
397 | + 'inc' => 'PHP', |
|
398 | + 'js' => 'JS', |
|
399 | + 'css' => 'CSS', |
|
400 | + ); |
|
401 | 401 | $this->sniffs = array(); |
402 | 402 | $this->ignored = array(); |
403 | 403 | $this->filter = null; |
@@ -174,35 +174,35 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | switch ($name) { |
177 | - case 'reportWidth' : |
|
178 | - // Support auto terminal width. |
|
179 | - if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
180 | - $value = (int) $matches[1]; |
|
181 | - } else { |
|
182 | - $value = (int) $value; |
|
183 | - } |
|
184 | - break; |
|
185 | - case 'standards' : |
|
186 | - $cleaned = array(); |
|
187 | - |
|
188 | - // Check if the standard name is valid, or if the case is invalid. |
|
189 | - $installedStandards = Util\Standards::getInstalledStandards(); |
|
190 | - foreach ($value as $standard) { |
|
191 | - foreach ($installedStandards as $validStandard) { |
|
192 | - if (strtolower($standard) === strtolower($validStandard)) { |
|
193 | - $standard = $validStandard; |
|
194 | - break; |
|
195 | - } |
|
177 | + case 'reportWidth' : |
|
178 | + // Support auto terminal width. |
|
179 | + if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
180 | + $value = (int) $matches[1]; |
|
181 | + } else { |
|
182 | + $value = (int) $value; |
|
196 | 183 | } |
184 | + break; |
|
185 | + case 'standards' : |
|
186 | + $cleaned = array(); |
|
187 | + |
|
188 | + // Check if the standard name is valid, or if the case is invalid. |
|
189 | + $installedStandards = Util\Standards::getInstalledStandards(); |
|
190 | + foreach ($value as $standard) { |
|
191 | + foreach ($installedStandards as $validStandard) { |
|
192 | + if (strtolower($standard) === strtolower($validStandard)) { |
|
193 | + $standard = $validStandard; |
|
194 | + break; |
|
195 | + } |
|
196 | + } |
|
197 | 197 | |
198 | - $cleaned[] = $standard; |
|
199 | - } |
|
198 | + $cleaned[] = $standard; |
|
199 | + } |
|
200 | 200 | |
201 | - $value = $cleaned; |
|
202 | - break; |
|
203 | - default : |
|
204 | - // No validation required. |
|
205 | - break; |
|
201 | + $value = $cleaned; |
|
202 | + break; |
|
203 | + default : |
|
204 | + // No validation required. |
|
205 | + break; |
|
206 | 206 | }//end switch |
207 | 207 | |
208 | 208 | $this->settings[$name] = $value; |
@@ -441,60 +441,60 @@ discard block |
||
441 | 441 | public function processShortArgument($arg, $pos) |
442 | 442 | { |
443 | 443 | switch ($arg) { |
444 | - case 'h': |
|
445 | - case '?': |
|
446 | - $this->printUsage(); |
|
447 | - exit(0); |
|
448 | - case 'i' : |
|
449 | - Util\Standards::printInstalledStandards(); |
|
450 | - exit(0); |
|
451 | - case 'v' : |
|
452 | - $this->verbosity++; |
|
453 | - $this->overriddenDefaults['verbosity'] = true; |
|
454 | - break; |
|
455 | - case 'l' : |
|
456 | - $this->local = true; |
|
457 | - $this->overriddenDefaults['local'] = true; |
|
458 | - break; |
|
459 | - case 's' : |
|
460 | - $this->showSources = true; |
|
461 | - $this->overriddenDefaults['showSources'] = true; |
|
462 | - break; |
|
463 | - case 'e': |
|
464 | - $this->explain = true; |
|
465 | - $this->overriddenDefaults['explain'] = true; |
|
466 | - break; |
|
467 | - case 'p' : |
|
468 | - $this->showProgress = true; |
|
469 | - $this->overriddenDefaults['showProgress'] = true; |
|
470 | - break; |
|
471 | - case 'm' : |
|
472 | - $this->recordErrors = false; |
|
473 | - $this->overriddenDefaults['recordErrors'] = true; |
|
474 | - break; |
|
475 | - case 'd' : |
|
476 | - $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
477 | - $this->cliArgs[($pos + 1)] = ''; |
|
478 | - if (isset($ini[1]) === true) { |
|
479 | - ini_set($ini[0], $ini[1]); |
|
480 | - } else { |
|
481 | - ini_set($ini[0], true); |
|
482 | - } |
|
483 | - break; |
|
484 | - case 'n' : |
|
485 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
486 | - $this->warningSeverity = 0; |
|
487 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
488 | - } |
|
489 | - break; |
|
490 | - case 'w' : |
|
491 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
492 | - $this->warningSeverity = $this->errorSeverity; |
|
493 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
494 | - } |
|
495 | - break; |
|
496 | - default: |
|
497 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
444 | + case 'h': |
|
445 | + case '?': |
|
446 | + $this->printUsage(); |
|
447 | + exit(0); |
|
448 | + case 'i' : |
|
449 | + Util\Standards::printInstalledStandards(); |
|
450 | + exit(0); |
|
451 | + case 'v' : |
|
452 | + $this->verbosity++; |
|
453 | + $this->overriddenDefaults['verbosity'] = true; |
|
454 | + break; |
|
455 | + case 'l' : |
|
456 | + $this->local = true; |
|
457 | + $this->overriddenDefaults['local'] = true; |
|
458 | + break; |
|
459 | + case 's' : |
|
460 | + $this->showSources = true; |
|
461 | + $this->overriddenDefaults['showSources'] = true; |
|
462 | + break; |
|
463 | + case 'e': |
|
464 | + $this->explain = true; |
|
465 | + $this->overriddenDefaults['explain'] = true; |
|
466 | + break; |
|
467 | + case 'p' : |
|
468 | + $this->showProgress = true; |
|
469 | + $this->overriddenDefaults['showProgress'] = true; |
|
470 | + break; |
|
471 | + case 'm' : |
|
472 | + $this->recordErrors = false; |
|
473 | + $this->overriddenDefaults['recordErrors'] = true; |
|
474 | + break; |
|
475 | + case 'd' : |
|
476 | + $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
477 | + $this->cliArgs[($pos + 1)] = ''; |
|
478 | + if (isset($ini[1]) === true) { |
|
479 | + ini_set($ini[0], $ini[1]); |
|
480 | + } else { |
|
481 | + ini_set($ini[0], true); |
|
482 | + } |
|
483 | + break; |
|
484 | + case 'n' : |
|
485 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
486 | + $this->warningSeverity = 0; |
|
487 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
488 | + } |
|
489 | + break; |
|
490 | + case 'w' : |
|
491 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
492 | + $this->warningSeverity = $this->errorSeverity; |
|
493 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
494 | + } |
|
495 | + break; |
|
496 | + default: |
|
497 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
498 | 498 | }//end switch |
499 | 499 | |
500 | 500 | }//end processShortArgument() |
@@ -511,138 +511,138 @@ discard block |
||
511 | 511 | public function processLongArgument($arg, $pos) |
512 | 512 | { |
513 | 513 | switch ($arg) { |
514 | - case 'help': |
|
515 | - $this->printUsage(); |
|
516 | - exit(0); |
|
517 | - case 'version': |
|
518 | - echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION; |
|
519 | - exit(0); |
|
520 | - case 'cache': |
|
521 | - $this->cache = true; |
|
522 | - $this->overriddenDefaults['cache'] = true; |
|
523 | - break; |
|
524 | - case 'no-cache': |
|
525 | - $this->cache = false; |
|
526 | - $this->overriddenDefaults['cache'] = true; |
|
527 | - break; |
|
528 | - default: |
|
529 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
530 | - $sniffs = explode(',', substr($arg, 7)); |
|
531 | - foreach ($sniffs as $sniff) { |
|
532 | - if (substr_count($sniff, '.') !== 2) { |
|
533 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
534 | - $this->printUsage(); |
|
535 | - exit(2); |
|
514 | + case 'help': |
|
515 | + $this->printUsage(); |
|
516 | + exit(0); |
|
517 | + case 'version': |
|
518 | + echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION; |
|
519 | + exit(0); |
|
520 | + case 'cache': |
|
521 | + $this->cache = true; |
|
522 | + $this->overriddenDefaults['cache'] = true; |
|
523 | + break; |
|
524 | + case 'no-cache': |
|
525 | + $this->cache = false; |
|
526 | + $this->overriddenDefaults['cache'] = true; |
|
527 | + break; |
|
528 | + default: |
|
529 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
530 | + $sniffs = explode(',', substr($arg, 7)); |
|
531 | + foreach ($sniffs as $sniff) { |
|
532 | + if (substr_count($sniff, '.') !== 2) { |
|
533 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
534 | + $this->printUsage(); |
|
535 | + exit(2); |
|
536 | + } |
|
536 | 537 | } |
537 | - } |
|
538 | 538 | |
539 | - $this->sniffs = $sniffs; |
|
540 | - $this->overriddenDefaults['sniffs'] = true; |
|
541 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
542 | - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
539 | + $this->sniffs = $sniffs; |
|
540 | + $this->overriddenDefaults['sniffs'] = true; |
|
541 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
542 | + $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
543 | 543 | |
544 | - // It may not exist and return false instead, so use whatever they gave us. |
|
545 | - if ($this->stdinPath === false) { |
|
546 | - $this->stdinPath = trim(substr($arg, 11)); |
|
547 | - } |
|
548 | - |
|
549 | - $this->overriddenDefaults['stdinPath'] = true; |
|
550 | - } else if (substr($arg, 0, 9) === 'basepath=') { |
|
551 | - if (isset($this->overriddenDefaults['basepath']) === true) { |
|
552 | - break; |
|
553 | - } |
|
554 | - |
|
555 | - $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
544 | + // It may not exist and return false instead, so use whatever they gave us. |
|
545 | + if ($this->stdinPath === false) { |
|
546 | + $this->stdinPath = trim(substr($arg, 11)); |
|
547 | + } |
|
556 | 548 | |
557 | - // It may not exist and return false instead. |
|
558 | - if ($this->basepath === false) { |
|
559 | - $this->basepath = substr($arg, 9); |
|
560 | - } |
|
549 | + $this->overriddenDefaults['stdinPath'] = true; |
|
550 | + } else if (substr($arg, 0, 9) === 'basepath=') { |
|
551 | + if (isset($this->overriddenDefaults['basepath']) === true) { |
|
552 | + break; |
|
553 | + } |
|
561 | 554 | |
562 | - $this->overriddenDefaults['basepath'] = true; |
|
555 | + $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
563 | 556 | |
564 | - if (is_dir($this->basepath) === false) { |
|
565 | - echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
566 | - $this->printUsage(); |
|
567 | - exit(2); |
|
568 | - } |
|
569 | - } else if (substr($arg, 0, 7) === 'filter=') { |
|
570 | - if (isset($this->overriddenDefaults['filter']) === true) { |
|
571 | - break; |
|
572 | - } |
|
557 | + // It may not exist and return false instead. |
|
558 | + if ($this->basepath === false) { |
|
559 | + $this->basepath = substr($arg, 9); |
|
560 | + } |
|
573 | 561 | |
574 | - $this->filter = substr($arg, 7); |
|
575 | - $this->overriddenDefaults['filter'] = true; |
|
576 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
577 | - $standards = trim(substr($arg, 9)); |
|
578 | - if ($standards !== '') { |
|
579 | - $this->standards = explode(',', $standards); |
|
580 | - } |
|
562 | + $this->overriddenDefaults['basepath'] = true; |
|
581 | 563 | |
582 | - $this->overriddenDefaults['standards'] = true; |
|
583 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
584 | - $extensions = explode(',', substr($arg, 11)); |
|
585 | - $newExtensions = array(); |
|
586 | - foreach ($extensions as $ext) { |
|
587 | - $slash = strpos($ext, '/'); |
|
588 | - if ($slash !== false) { |
|
589 | - // They specified the tokenizer too. |
|
590 | - list($ext, $tokenizer) = explode('/', $ext); |
|
591 | - $newExtensions[$ext] = strtoupper($tokenizer); |
|
592 | - continue; |
|
564 | + if (is_dir($this->basepath) === false) { |
|
565 | + echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
566 | + $this->printUsage(); |
|
567 | + exit(2); |
|
568 | + } |
|
569 | + } else if (substr($arg, 0, 7) === 'filter=') { |
|
570 | + if (isset($this->overriddenDefaults['filter']) === true) { |
|
571 | + break; |
|
593 | 572 | } |
594 | 573 | |
595 | - if (isset($this->extensions[$ext]) === true) { |
|
596 | - $newExtensions[$ext] = $this->extensions[$ext]; |
|
597 | - } else { |
|
598 | - $newExtensions[$ext] = 'PHP'; |
|
574 | + $this->filter = substr($arg, 7); |
|
575 | + $this->overriddenDefaults['filter'] = true; |
|
576 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
577 | + $standards = trim(substr($arg, 9)); |
|
578 | + if ($standards !== '') { |
|
579 | + $this->standards = explode(',', $standards); |
|
599 | 580 | } |
600 | - } |
|
601 | 581 | |
602 | - $this->extensions = $newExtensions; |
|
603 | - $this->overriddenDefaults['extensions'] = true; |
|
604 | - } else if (substr($arg, 0, 7) === 'suffix=') { |
|
605 | - $this->suffix = explode(',', substr($arg, 7)); |
|
606 | - $this->overriddenDefaults['suffix'] = true; |
|
607 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
608 | - $this->errorSeverity = (int) substr($arg, 9); |
|
609 | - $this->warningSeverity = $this->errorSeverity; |
|
610 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
611 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
612 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
613 | - $this->errorSeverity = (int) substr($arg, 15); |
|
614 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
615 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
616 | - $this->warningSeverity = (int) substr($arg, 17); |
|
617 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
618 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
619 | - // Split the ignore string on commas, unless the comma is escaped |
|
620 | - // using 1 or 3 slashes (\, or \\\,). |
|
621 | - $patterns = preg_split( |
|
622 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
623 | - substr($arg, 7) |
|
624 | - ); |
|
625 | - |
|
626 | - $ignored = array(); |
|
627 | - foreach ($patterns as $pattern) { |
|
628 | - $pattern = trim($pattern); |
|
629 | - if ($pattern === '') { |
|
630 | - continue; |
|
582 | + $this->overriddenDefaults['standards'] = true; |
|
583 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
584 | + $extensions = explode(',', substr($arg, 11)); |
|
585 | + $newExtensions = array(); |
|
586 | + foreach ($extensions as $ext) { |
|
587 | + $slash = strpos($ext, '/'); |
|
588 | + if ($slash !== false) { |
|
589 | + // They specified the tokenizer too. |
|
590 | + list($ext, $tokenizer) = explode('/', $ext); |
|
591 | + $newExtensions[$ext] = strtoupper($tokenizer); |
|
592 | + continue; |
|
593 | + } |
|
594 | + |
|
595 | + if (isset($this->extensions[$ext]) === true) { |
|
596 | + $newExtensions[$ext] = $this->extensions[$ext]; |
|
597 | + } else { |
|
598 | + $newExtensions[$ext] = 'PHP'; |
|
599 | + } |
|
631 | 600 | } |
632 | 601 | |
633 | - $ignored[$pattern] = 'absolute'; |
|
634 | - } |
|
602 | + $this->extensions = $newExtensions; |
|
603 | + $this->overriddenDefaults['extensions'] = true; |
|
604 | + } else if (substr($arg, 0, 7) === 'suffix=') { |
|
605 | + $this->suffix = explode(',', substr($arg, 7)); |
|
606 | + $this->overriddenDefaults['suffix'] = true; |
|
607 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
608 | + $this->errorSeverity = (int) substr($arg, 9); |
|
609 | + $this->warningSeverity = $this->errorSeverity; |
|
610 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
611 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
612 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
613 | + $this->errorSeverity = (int) substr($arg, 15); |
|
614 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
615 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
616 | + $this->warningSeverity = (int) substr($arg, 17); |
|
617 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
618 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
619 | + // Split the ignore string on commas, unless the comma is escaped |
|
620 | + // using 1 or 3 slashes (\, or \\\,). |
|
621 | + $patterns = preg_split( |
|
622 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
623 | + substr($arg, 7) |
|
624 | + ); |
|
625 | + |
|
626 | + $ignored = array(); |
|
627 | + foreach ($patterns as $pattern) { |
|
628 | + $pattern = trim($pattern); |
|
629 | + if ($pattern === '') { |
|
630 | + continue; |
|
631 | + } |
|
635 | 632 | |
636 | - $this->ignored = $ignored; |
|
637 | - $this->overriddenDefaults['ignored'] = true; |
|
638 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
639 | - $this->tabWidth = (int) substr($arg, 10); |
|
640 | - $this->overriddenDefaults['tabWidth'] = true; |
|
641 | - } else { |
|
642 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
643 | - }//end if |
|
633 | + $ignored[$pattern] = 'absolute'; |
|
634 | + } |
|
635 | + |
|
636 | + $this->ignored = $ignored; |
|
637 | + $this->overriddenDefaults['ignored'] = true; |
|
638 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
639 | + $this->tabWidth = (int) substr($arg, 10); |
|
640 | + $this->overriddenDefaults['tabWidth'] = true; |
|
641 | + } else { |
|
642 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
643 | + }//end if |
|
644 | 644 | |
645 | - break; |
|
645 | + break; |
|
646 | 646 | }//end switch |
647 | 647 | |
648 | 648 | }//end processLongArgument() |
@@ -245,7 +245,7 @@ |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function __construct(array $cliArgs=array()) |
|
248 | + public function __construct(array $cliArgs = array()) |
|
249 | 249 | { |
250 | 250 | $checkStdin = false; |
251 | 251 | if (empty($cliArgs) === true) { |