@@ -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; |
@@ -184,35 +184,35 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | switch ($name) { |
187 | - case 'reportWidth' : |
|
188 | - // Support auto terminal width. |
|
189 | - if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
190 | - $value = (int) $matches[1]; |
|
191 | - } else { |
|
192 | - $value = (int) $value; |
|
193 | - } |
|
194 | - break; |
|
195 | - case 'standards' : |
|
196 | - $cleaned = array(); |
|
197 | - |
|
198 | - // Check if the standard name is valid, or if the case is invalid. |
|
199 | - $installedStandards = Util\Standards::getInstalledStandards(); |
|
200 | - foreach ($value as $standard) { |
|
201 | - foreach ($installedStandards as $validStandard) { |
|
202 | - if (strtolower($standard) === strtolower($validStandard)) { |
|
203 | - $standard = $validStandard; |
|
204 | - break; |
|
205 | - } |
|
187 | + case 'reportWidth' : |
|
188 | + // Support auto terminal width. |
|
189 | + if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
190 | + $value = (int) $matches[1]; |
|
191 | + } else { |
|
192 | + $value = (int) $value; |
|
206 | 193 | } |
194 | + break; |
|
195 | + case 'standards' : |
|
196 | + $cleaned = array(); |
|
197 | + |
|
198 | + // Check if the standard name is valid, or if the case is invalid. |
|
199 | + $installedStandards = Util\Standards::getInstalledStandards(); |
|
200 | + foreach ($value as $standard) { |
|
201 | + foreach ($installedStandards as $validStandard) { |
|
202 | + if (strtolower($standard) === strtolower($validStandard)) { |
|
203 | + $standard = $validStandard; |
|
204 | + break; |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | - $cleaned[] = $standard; |
|
209 | - } |
|
208 | + $cleaned[] = $standard; |
|
209 | + } |
|
210 | 210 | |
211 | - $value = $cleaned; |
|
212 | - break; |
|
213 | - default : |
|
214 | - // No validation required. |
|
215 | - break; |
|
211 | + $value = $cleaned; |
|
212 | + break; |
|
213 | + default : |
|
214 | + // No validation required. |
|
215 | + break; |
|
216 | 216 | }//end switch |
217 | 217 | |
218 | 218 | $this->settings[$name] = $value; |
@@ -469,64 +469,64 @@ discard block |
||
469 | 469 | public function processShortArgument($arg, $pos) |
470 | 470 | { |
471 | 471 | switch ($arg) { |
472 | - case 'h': |
|
473 | - case '?': |
|
474 | - $this->printUsage(); |
|
475 | - exit(0); |
|
476 | - case 'i' : |
|
477 | - Util\Standards::printInstalledStandards(); |
|
478 | - exit(0); |
|
479 | - case 'v' : |
|
480 | - $this->verbosity++; |
|
481 | - $this->overriddenDefaults['verbosity'] = true; |
|
482 | - break; |
|
483 | - case 'l' : |
|
484 | - $this->local = true; |
|
485 | - $this->overriddenDefaults['local'] = true; |
|
486 | - break; |
|
487 | - case 's' : |
|
488 | - $this->showSources = true; |
|
489 | - $this->overriddenDefaults['showSources'] = true; |
|
490 | - break; |
|
491 | - case 'e': |
|
492 | - $this->explain = true; |
|
493 | - $this->overriddenDefaults['explain'] = true; |
|
494 | - break; |
|
495 | - case 'p' : |
|
496 | - $this->showProgress = true; |
|
497 | - $this->overriddenDefaults['showProgress'] = true; |
|
498 | - break; |
|
499 | - case 'm' : |
|
500 | - $this->recordErrors = false; |
|
501 | - $this->overriddenDefaults['recordErrors'] = true; |
|
502 | - break; |
|
503 | - case 'd' : |
|
504 | - $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
505 | - $this->cliArgs[($pos + 1)] = ''; |
|
506 | - if (isset($ini[1]) === true) { |
|
507 | - ini_set($ini[0], $ini[1]); |
|
508 | - } else { |
|
509 | - ini_set($ini[0], true); |
|
510 | - } |
|
511 | - break; |
|
512 | - case 'n' : |
|
513 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
514 | - $this->warningSeverity = 0; |
|
515 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
516 | - } |
|
517 | - break; |
|
518 | - case 'w' : |
|
519 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
520 | - $this->warningSeverity = $this->errorSeverity; |
|
521 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
522 | - } |
|
523 | - break; |
|
524 | - default: |
|
525 | - if ($this->dieOnUnknownArg === false) { |
|
526 | - $this->values[$arg] = $arg; |
|
527 | - } else { |
|
528 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
529 | - } |
|
472 | + case 'h': |
|
473 | + case '?': |
|
474 | + $this->printUsage(); |
|
475 | + exit(0); |
|
476 | + case 'i' : |
|
477 | + Util\Standards::printInstalledStandards(); |
|
478 | + exit(0); |
|
479 | + case 'v' : |
|
480 | + $this->verbosity++; |
|
481 | + $this->overriddenDefaults['verbosity'] = true; |
|
482 | + break; |
|
483 | + case 'l' : |
|
484 | + $this->local = true; |
|
485 | + $this->overriddenDefaults['local'] = true; |
|
486 | + break; |
|
487 | + case 's' : |
|
488 | + $this->showSources = true; |
|
489 | + $this->overriddenDefaults['showSources'] = true; |
|
490 | + break; |
|
491 | + case 'e': |
|
492 | + $this->explain = true; |
|
493 | + $this->overriddenDefaults['explain'] = true; |
|
494 | + break; |
|
495 | + case 'p' : |
|
496 | + $this->showProgress = true; |
|
497 | + $this->overriddenDefaults['showProgress'] = true; |
|
498 | + break; |
|
499 | + case 'm' : |
|
500 | + $this->recordErrors = false; |
|
501 | + $this->overriddenDefaults['recordErrors'] = true; |
|
502 | + break; |
|
503 | + case 'd' : |
|
504 | + $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
505 | + $this->cliArgs[($pos + 1)] = ''; |
|
506 | + if (isset($ini[1]) === true) { |
|
507 | + ini_set($ini[0], $ini[1]); |
|
508 | + } else { |
|
509 | + ini_set($ini[0], true); |
|
510 | + } |
|
511 | + break; |
|
512 | + case 'n' : |
|
513 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
514 | + $this->warningSeverity = 0; |
|
515 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
516 | + } |
|
517 | + break; |
|
518 | + case 'w' : |
|
519 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
520 | + $this->warningSeverity = $this->errorSeverity; |
|
521 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
522 | + } |
|
523 | + break; |
|
524 | + default: |
|
525 | + if ($this->dieOnUnknownArg === false) { |
|
526 | + $this->values[$arg] = $arg; |
|
527 | + } else { |
|
528 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
529 | + } |
|
530 | 530 | }//end switch |
531 | 531 | |
532 | 532 | }//end processShortArgument() |
@@ -543,151 +543,151 @@ discard block |
||
543 | 543 | public function processLongArgument($arg, $pos) |
544 | 544 | { |
545 | 545 | switch ($arg) { |
546 | - case 'help': |
|
547 | - $this->printUsage(); |
|
548 | - exit(0); |
|
549 | - case 'version': |
|
550 | - echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION; |
|
551 | - exit(0); |
|
552 | - case 'cache': |
|
553 | - if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
554 | - $this->cache = true; |
|
546 | + case 'help': |
|
547 | + $this->printUsage(); |
|
548 | + exit(0); |
|
549 | + case 'version': |
|
550 | + echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION; |
|
551 | + exit(0); |
|
552 | + case 'cache': |
|
553 | + if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
554 | + $this->cache = true; |
|
555 | + $this->overriddenDefaults['cache'] = true; |
|
556 | + } |
|
557 | + break; |
|
558 | + case 'no-cache': |
|
559 | + $this->cache = false; |
|
555 | 560 | $this->overriddenDefaults['cache'] = true; |
556 | - } |
|
557 | - break; |
|
558 | - case 'no-cache': |
|
559 | - $this->cache = false; |
|
560 | - $this->overriddenDefaults['cache'] = true; |
|
561 | - break; |
|
562 | - default: |
|
563 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
564 | - $sniffs = explode(',', substr($arg, 7)); |
|
565 | - foreach ($sniffs as $sniff) { |
|
566 | - if (substr_count($sniff, '.') !== 2) { |
|
567 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
568 | - $this->printUsage(); |
|
569 | - exit(2); |
|
561 | + break; |
|
562 | + default: |
|
563 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
564 | + $sniffs = explode(',', substr($arg, 7)); |
|
565 | + foreach ($sniffs as $sniff) { |
|
566 | + if (substr_count($sniff, '.') !== 2) { |
|
567 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
568 | + $this->printUsage(); |
|
569 | + exit(2); |
|
570 | + } |
|
570 | 571 | } |
571 | - } |
|
572 | - |
|
573 | - $this->sniffs = $sniffs; |
|
574 | - $this->overriddenDefaults['sniffs'] = true; |
|
575 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
576 | - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
577 | 572 | |
578 | - // It may not exist and return false instead, so use whatever they gave us. |
|
579 | - if ($this->stdinPath === false) { |
|
580 | - $this->stdinPath = trim(substr($arg, 11)); |
|
581 | - } |
|
582 | - |
|
583 | - $this->overriddenDefaults['stdinPath'] = true; |
|
584 | - } else if (substr($arg, 0, 9) === 'basepath=') { |
|
585 | - if (isset($this->overriddenDefaults['basepath']) === true) { |
|
586 | - break; |
|
587 | - } |
|
573 | + $this->sniffs = $sniffs; |
|
574 | + $this->overriddenDefaults['sniffs'] = true; |
|
575 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
576 | + $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
588 | 577 | |
589 | - $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
578 | + // It may not exist and return false instead, so use whatever they gave us. |
|
579 | + if ($this->stdinPath === false) { |
|
580 | + $this->stdinPath = trim(substr($arg, 11)); |
|
581 | + } |
|
590 | 582 | |
591 | - // It may not exist and return false instead. |
|
592 | - if ($this->basepath === false) { |
|
593 | - $this->basepath = substr($arg, 9); |
|
594 | - } |
|
583 | + $this->overriddenDefaults['stdinPath'] = true; |
|
584 | + } else if (substr($arg, 0, 9) === 'basepath=') { |
|
585 | + if (isset($this->overriddenDefaults['basepath']) === true) { |
|
586 | + break; |
|
587 | + } |
|
595 | 588 | |
596 | - $this->overriddenDefaults['basepath'] = true; |
|
589 | + $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
597 | 590 | |
598 | - if (is_dir($this->basepath) === false) { |
|
599 | - echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
600 | - $this->printUsage(); |
|
601 | - exit(2); |
|
602 | - } |
|
603 | - } else if (substr($arg, 0, 7) === 'filter=') { |
|
604 | - if (isset($this->overriddenDefaults['filter']) === true) { |
|
605 | - break; |
|
606 | - } |
|
591 | + // It may not exist and return false instead. |
|
592 | + if ($this->basepath === false) { |
|
593 | + $this->basepath = substr($arg, 9); |
|
594 | + } |
|
607 | 595 | |
608 | - $this->filter = substr($arg, 7); |
|
609 | - $this->overriddenDefaults['filter'] = true; |
|
610 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
611 | - $standards = trim(substr($arg, 9)); |
|
612 | - if ($standards !== '') { |
|
613 | - $this->standards = explode(',', $standards); |
|
614 | - } |
|
596 | + $this->overriddenDefaults['basepath'] = true; |
|
615 | 597 | |
616 | - $this->overriddenDefaults['standards'] = true; |
|
617 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
618 | - $extensions = explode(',', substr($arg, 11)); |
|
619 | - $newExtensions = array(); |
|
620 | - foreach ($extensions as $ext) { |
|
621 | - $slash = strpos($ext, '/'); |
|
622 | - if ($slash !== false) { |
|
623 | - // They specified the tokenizer too. |
|
624 | - list($ext, $tokenizer) = explode('/', $ext); |
|
625 | - $newExtensions[$ext] = strtoupper($tokenizer); |
|
626 | - continue; |
|
598 | + if (is_dir($this->basepath) === false) { |
|
599 | + echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
600 | + $this->printUsage(); |
|
601 | + exit(2); |
|
602 | + } |
|
603 | + } else if (substr($arg, 0, 7) === 'filter=') { |
|
604 | + if (isset($this->overriddenDefaults['filter']) === true) { |
|
605 | + break; |
|
627 | 606 | } |
628 | 607 | |
629 | - if (isset($this->extensions[$ext]) === true) { |
|
630 | - $newExtensions[$ext] = $this->extensions[$ext]; |
|
631 | - } else { |
|
632 | - $newExtensions[$ext] = 'PHP'; |
|
608 | + $this->filter = substr($arg, 7); |
|
609 | + $this->overriddenDefaults['filter'] = true; |
|
610 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
611 | + $standards = trim(substr($arg, 9)); |
|
612 | + if ($standards !== '') { |
|
613 | + $this->standards = explode(',', $standards); |
|
633 | 614 | } |
634 | - } |
|
635 | 615 | |
636 | - $this->extensions = $newExtensions; |
|
637 | - $this->overriddenDefaults['extensions'] = true; |
|
638 | - } else if (substr($arg, 0, 7) === 'suffix=') { |
|
639 | - $this->suffix = explode(',', substr($arg, 7)); |
|
640 | - $this->overriddenDefaults['suffix'] = true; |
|
641 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
642 | - $this->errorSeverity = (int) substr($arg, 9); |
|
643 | - $this->warningSeverity = $this->errorSeverity; |
|
644 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
645 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
646 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
647 | - $this->errorSeverity = (int) substr($arg, 15); |
|
648 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
649 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
650 | - $this->warningSeverity = (int) substr($arg, 17); |
|
651 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
652 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
653 | - // Split the ignore string on commas, unless the comma is escaped |
|
654 | - // using 1 or 3 slashes (\, or \\\,). |
|
655 | - $patterns = preg_split( |
|
656 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
657 | - substr($arg, 7) |
|
658 | - ); |
|
659 | - |
|
660 | - $ignored = array(); |
|
661 | - foreach ($patterns as $pattern) { |
|
662 | - $pattern = trim($pattern); |
|
663 | - if ($pattern === '') { |
|
664 | - continue; |
|
616 | + $this->overriddenDefaults['standards'] = true; |
|
617 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
618 | + $extensions = explode(',', substr($arg, 11)); |
|
619 | + $newExtensions = array(); |
|
620 | + foreach ($extensions as $ext) { |
|
621 | + $slash = strpos($ext, '/'); |
|
622 | + if ($slash !== false) { |
|
623 | + // They specified the tokenizer too. |
|
624 | + list($ext, $tokenizer) = explode('/', $ext); |
|
625 | + $newExtensions[$ext] = strtoupper($tokenizer); |
|
626 | + continue; |
|
627 | + } |
|
628 | + |
|
629 | + if (isset($this->extensions[$ext]) === true) { |
|
630 | + $newExtensions[$ext] = $this->extensions[$ext]; |
|
631 | + } else { |
|
632 | + $newExtensions[$ext] = 'PHP'; |
|
633 | + } |
|
665 | 634 | } |
666 | 635 | |
667 | - $ignored[$pattern] = 'absolute'; |
|
668 | - } |
|
636 | + $this->extensions = $newExtensions; |
|
637 | + $this->overriddenDefaults['extensions'] = true; |
|
638 | + } else if (substr($arg, 0, 7) === 'suffix=') { |
|
639 | + $this->suffix = explode(',', substr($arg, 7)); |
|
640 | + $this->overriddenDefaults['suffix'] = true; |
|
641 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
642 | + $this->errorSeverity = (int) substr($arg, 9); |
|
643 | + $this->warningSeverity = $this->errorSeverity; |
|
644 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
645 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
646 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
647 | + $this->errorSeverity = (int) substr($arg, 15); |
|
648 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
649 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
650 | + $this->warningSeverity = (int) substr($arg, 17); |
|
651 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
652 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
653 | + // Split the ignore string on commas, unless the comma is escaped |
|
654 | + // using 1 or 3 slashes (\, or \\\,). |
|
655 | + $patterns = preg_split( |
|
656 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
657 | + substr($arg, 7) |
|
658 | + ); |
|
659 | + |
|
660 | + $ignored = array(); |
|
661 | + foreach ($patterns as $pattern) { |
|
662 | + $pattern = trim($pattern); |
|
663 | + if ($pattern === '') { |
|
664 | + continue; |
|
665 | + } |
|
669 | 666 | |
670 | - $this->ignored = $ignored; |
|
671 | - $this->overriddenDefaults['ignored'] = true; |
|
672 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
673 | - $this->tabWidth = (int) substr($arg, 10); |
|
674 | - $this->overriddenDefaults['tabWidth'] = true; |
|
675 | - } else { |
|
676 | - if ($this->dieOnUnknownArg === false) { |
|
677 | - $eqPos = strpos($arg, '='); |
|
678 | - if ($eqPos === false) { |
|
679 | - $this->values[$arg] = $arg; |
|
680 | - } else { |
|
681 | - $value = substr($arg, ($eqPos + 1)); |
|
682 | - $arg = substr($arg, 0, $eqPos); |
|
683 | - $this->values[$arg] = $value; |
|
667 | + $ignored[$pattern] = 'absolute'; |
|
684 | 668 | } |
669 | + |
|
670 | + $this->ignored = $ignored; |
|
671 | + $this->overriddenDefaults['ignored'] = true; |
|
672 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
673 | + $this->tabWidth = (int) substr($arg, 10); |
|
674 | + $this->overriddenDefaults['tabWidth'] = true; |
|
685 | 675 | } else { |
686 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
687 | - } |
|
688 | - }//end if |
|
676 | + if ($this->dieOnUnknownArg === false) { |
|
677 | + $eqPos = strpos($arg, '='); |
|
678 | + if ($eqPos === false) { |
|
679 | + $this->values[$arg] = $arg; |
|
680 | + } else { |
|
681 | + $value = substr($arg, ($eqPos + 1)); |
|
682 | + $arg = substr($arg, 0, $eqPos); |
|
683 | + $this->values[$arg] = $value; |
|
684 | + } |
|
685 | + } else { |
|
686 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
687 | + } |
|
688 | + }//end if |
|
689 | 689 | |
690 | - break; |
|
690 | + break; |
|
691 | 691 | }//end switch |
692 | 692 | |
693 | 693 | }//end processLongArgument() |
@@ -257,7 +257,7 @@ |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | - public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true) |
|
260 | + public function __construct(array $cliArgs = array(), $dieOnUnknownArg = true) |
|
261 | 261 | { |
262 | 262 | if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === true) { |
263 | 263 | // Let everything through during testing so that we can |