Skip to content

Commit 9e11317

Browse files
committed
Modernize: Util\Help: use constant array in class constant
This changes the format/type of a `public` constant, but as the class is `final` and marked as `@internal`, i.e. not in the public API, this should not be regarded as a BC-break.
1 parent b8d295e commit 9e11317

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ public function printShortUsage($return=false)
15121512
*/
15131513
public function printPHPCSUsage()
15141514
{
1515-
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
1515+
$longOptions = Help::DEFAULT_LONG_OPTIONS;
15161516
$longOptions[] = 'cache';
15171517
$longOptions[] = 'no-cache';
15181518
$longOptions[] = 'report';
@@ -1538,7 +1538,7 @@ public function printPHPCSUsage()
15381538
*/
15391539
public function printPHPCBFUsage()
15401540
{
1541-
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
1541+
$longOptions = Help::DEFAULT_LONG_OPTIONS;
15421542
$longOptions[] = 'suffix';
15431543
$shortOptions = Help::DEFAULT_SHORT_OPTIONS;
15441544

src/Util/Help.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,36 @@ final class Help
3434
/**
3535
* Long options which are available for both the `phpcs` as well as the `phpcbf` command.
3636
*
37-
* {@internal This should be a constant array, but those aren't supported until PHP 5.6.}
38-
*
39-
* @var string Comma-separated list of the option names.
37+
* @var array<string> List of the option names.
4038
*/
41-
public const DEFAULT_LONG_OPTIONS = 'basepath,bootstrap,colors,encoding,error-severity,exclude,extensions,file,file-list,filter,ignore,ignore-annotations,no-colors,parallel,php-ini,report-width,runtime-set,severity,sniffs,standard,stdin-path,tab-width,version,vv,vvv,warning-severity';
39+
public const DEFAULT_LONG_OPTIONS = [
40+
'basepath',
41+
'bootstrap',
42+
'colors',
43+
'encoding',
44+
'error-severity',
45+
'exclude',
46+
'extensions',
47+
'file',
48+
'file-list',
49+
'filter',
50+
'ignore',
51+
'ignore-annotations',
52+
'no-colors',
53+
'parallel',
54+
'php-ini',
55+
'report-width',
56+
'runtime-set',
57+
'severity',
58+
'sniffs',
59+
'standard',
60+
'stdin-path',
61+
'tab-width',
62+
'version',
63+
'vv',
64+
'vvv',
65+
'warning-severity',
66+
];
4267

4368
/**
4469
* Minimum screen width.

tests/Core/Util/Help/HelpTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function testOptionFiltering($longOptions, $shortOptions, $expected)
190190
*/
191191
public static function dataOptionFiltering()
192192
{
193-
$allLongOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
193+
$allLongOptions = Help::DEFAULT_LONG_OPTIONS;
194194
$allLongOptions[] = 'cache';
195195
$allLongOptions[] = 'no-cache';
196196
$allLongOptions[] = 'report';
@@ -248,7 +248,7 @@ public static function dataOptionFiltering()
248248
],
249249
],
250250
'Default options only' => [
251-
'longOptions' => explode(',', Help::DEFAULT_LONG_OPTIONS),
251+
'longOptions' => Help::DEFAULT_LONG_OPTIONS,
252252
'shortOptions' => Help::DEFAULT_SHORT_OPTIONS,
253253
'expected' => [
254254
'Scan targets' => 8,

0 commit comments

Comments
 (0)