Skip to content

Commit 91cad8a

Browse files
authored
Merge pull request #1223 from PHPCSStandards/phpcs-4.0/feature/modernize-use-class-constants-for-constant-arrays-2
Modernize: Util\Help: use constant array in class constant
2 parents 22e353c + 9e11317 commit 91cad8a

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
@@ -1514,7 +1514,7 @@ public function printShortUsage($return=false)
15141514
*/
15151515
public function printPHPCSUsage()
15161516
{
1517-
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
1517+
$longOptions = Help::DEFAULT_LONG_OPTIONS;
15181518
$longOptions[] = 'cache';
15191519
$longOptions[] = 'no-cache';
15201520
$longOptions[] = 'report';
@@ -1540,7 +1540,7 @@ public function printPHPCSUsage()
15401540
*/
15411541
public function printPHPCBFUsage()
15421542
{
1543-
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
1543+
$longOptions = Help::DEFAULT_LONG_OPTIONS;
15441544
$longOptions[] = 'suffix';
15451545
$shortOptions = Help::DEFAULT_SHORT_OPTIONS;
15461546

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)