Skip to content

Commit fbb065b

Browse files
committed
use configuration option instead of CLI argument
1 parent 3f117b8 commit fbb065b

File tree

4 files changed

+44
-51
lines changed

4 files changed

+44
-51
lines changed

src/Config.php

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
* @property string $stdinContent Content passed directly to PHPCS on STDIN.
6666
* @property string $stdinPath The path to use for content passed on STDIN.
6767
* @property bool $trackTime Whether or not to track sniff run time.
68-
* @property bool $allowEmptyFileList Suppresses "No files were checked" error.
6968
*
7069
* @property array<string, string> $extensions File extensions that should be checked, and what tokenizer is used.
7170
* E.g., array('inc' => 'PHP');
@@ -161,43 +160,42 @@ class Config
161160
* @var array<string, mixed>
162161
*/
163162
private $settings = [
164-
'files' => null,
165-
'standards' => null,
166-
'verbosity' => null,
167-
'interactive' => null,
168-
'parallel' => null,
169-
'cache' => null,
170-
'cacheFile' => null,
171-
'colors' => null,
172-
'explain' => null,
173-
'local' => null,
174-
'showSources' => null,
175-
'showProgress' => null,
176-
'quiet' => null,
177-
'annotations' => null,
178-
'tabWidth' => null,
179-
'encoding' => null,
180-
'extensions' => null,
181-
'sniffs' => null,
182-
'exclude' => null,
183-
'ignored' => null,
184-
'reportFile' => null,
185-
'generator' => null,
186-
'filter' => null,
187-
'bootstrap' => null,
188-
'reports' => null,
189-
'basepath' => null,
190-
'reportWidth' => null,
191-
'errorSeverity' => null,
192-
'warningSeverity' => null,
193-
'recordErrors' => null,
194-
'suffix' => null,
195-
'stdin' => null,
196-
'stdinContent' => null,
197-
'stdinPath' => null,
198-
'trackTime' => null,
199-
'unknown' => null,
200-
'allowEmptyFileList' => null,
163+
'files' => null,
164+
'standards' => null,
165+
'verbosity' => null,
166+
'interactive' => null,
167+
'parallel' => null,
168+
'cache' => null,
169+
'cacheFile' => null,
170+
'colors' => null,
171+
'explain' => null,
172+
'local' => null,
173+
'showSources' => null,
174+
'showProgress' => null,
175+
'quiet' => null,
176+
'annotations' => null,
177+
'tabWidth' => null,
178+
'encoding' => null,
179+
'extensions' => null,
180+
'sniffs' => null,
181+
'exclude' => null,
182+
'ignored' => null,
183+
'reportFile' => null,
184+
'generator' => null,
185+
'filter' => null,
186+
'bootstrap' => null,
187+
'reports' => null,
188+
'basepath' => null,
189+
'reportWidth' => null,
190+
'errorSeverity' => null,
191+
'warningSeverity' => null,
192+
'recordErrors' => null,
193+
'suffix' => null,
194+
'stdin' => null,
195+
'stdinContent' => null,
196+
'stdinPath' => null,
197+
'trackTime' => null,
198+
'unknown' => null,
201199
];
202200

203201
/**
@@ -583,7 +581,6 @@ public function restoreDefaults()
583581
$this->stdinPath = null;
584582
$this->trackTime = false;
585583
$this->unknown = [];
586-
$this->allowEmptyFileList = false;
587584

588585
$standard = self::getConfigData('default_standard');
589586
if ($standard !== null) {
@@ -831,14 +828,6 @@ public function processLongArgument(string $arg, int $pos)
831828
$this->annotations = false;
832829
$this->overriddenDefaults['annotations'] = true;
833830
break;
834-
case 'allow-empty-file-list':
835-
if (isset($this->overriddenDefaults['allowEmptyFileList']) === true) {
836-
break;
837-
}
838-
839-
$this->allowEmptyFileList = true;
840-
$this->overriddenDefaults['allowEmptyFileList'] = true;
841-
break;
842831
case 'config-set':
843832
if (isset($this->cliArgs[($pos + 1)]) === false
844833
|| isset($this->cliArgs[($pos + 2)]) === false

src/Runner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private function run()
351351
}
352352

353353
$numFiles = count($todo);
354-
if ($numFiles === 0 && $this->config->allowEmptyFileList === false) {
354+
if ($numFiles === 0 && Config::getConfigData('allow_empty_file_list') !== '1') {
355355
$error = 'ERROR: No files were checked.' . PHP_EOL;
356356
$error .= 'All specified files were excluded or did not match filtering rules.' . PHP_EOL . PHP_EOL;
357357
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);

src/Util/Help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ private function getAllOptions()
579579

580580
'config-explain' => [
581581
'text' => 'Default values for a selection of options can be stored in a user-specific CodeSniffer.conf configuration file.' . "\n"
582-
. 'This applies to the following options: "default_standard", "report_format", "tab_width", "encoding", "severity", "error_severity", "warning_severity", "show_warnings", "report_width", "show_progress", "quiet", "colors", "cache", "parallel", "installed_paths", "php_version", "ignore_errors_on_exit", "ignore_warnings_on_exit", "ignore_non_auto_fixable_on_exit".',
582+
. 'This applies to the following options: "default_standard", "report_format", "tab_width", "encoding", "severity", "error_severity", "warning_severity", "show_warnings", "report_width", "show_progress", "quiet", "colors", "cache", "parallel", "installed_paths", "php_version", "ignore_errors_on_exit", "ignore_warnings_on_exit", "ignore_non_auto_fixable_on_exit", "allow_empty_file_list".',
583583
],
584584
'config-show' => [
585585
'argument' => '--config-show',

tests/Core/Runner/RunAllFilesExcludedErrorTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function testPhpcsAllowEmpty($sourceDir, $extraArgs)
9090
$this->markTestSkipped('This test needs CS mode to run');
9191
}
9292

93-
$extraArgs[] = '--allow-empty-file-list';
93+
$extraArgs[] = '--runtime-set';
94+
$extraArgs[] = 'allow_empty_file_list';
95+
$extraArgs[] = '1';
9496
$this->setupTest($sourceDir, $extraArgs);
9597

9698
$runner = new Runner();
@@ -119,7 +121,9 @@ public function testPhpcbfAllowEmpty($sourceDir, $extraArgs)
119121
$this->markTestSkipped('This test needs CBF mode to run');
120122
}
121123

122-
$extraArgs[] = '--allow-empty-file-list';
124+
$extraArgs[] = '--runtime-set';
125+
$extraArgs[] = 'allow_empty_file_list';
126+
$extraArgs[] = '1';
123127
$this->setupTest($sourceDir, $extraArgs);
124128

125129
$runner = new Runner();

0 commit comments

Comments
 (0)