Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ public function printShortUsage($return=false)
*/
public function printPHPCSUsage()
{
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
$longOptions = Help::DEFAULT_LONG_OPTIONS;
$longOptions[] = 'cache';
$longOptions[] = 'no-cache';
$longOptions[] = 'report';
Expand All @@ -1538,7 +1538,7 @@ public function printPHPCSUsage()
*/
public function printPHPCBFUsage()
{
$longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
$longOptions = Help::DEFAULT_LONG_OPTIONS;
$longOptions[] = 'suffix';
$shortOptions = Help::DEFAULT_SHORT_OPTIONS;

Expand Down
33 changes: 29 additions & 4 deletions src/Util/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,36 @@ final class Help
/**
* Long options which are available for both the `phpcs` as well as the `phpcbf` command.
*
* {@internal This should be a constant array, but those aren't supported until PHP 5.6.}
*
* @var string Comma-separated list of the option names.
* @var array<string> List of the option names.
*/
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';
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',
];

/**
* Minimum screen width.
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Util/Help/HelpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testOptionFiltering($longOptions, $shortOptions, $expected)
*/
public static function dataOptionFiltering()
{
$allLongOptions = explode(',', Help::DEFAULT_LONG_OPTIONS);
$allLongOptions = Help::DEFAULT_LONG_OPTIONS;
$allLongOptions[] = 'cache';
$allLongOptions[] = 'no-cache';
$allLongOptions[] = 'report';
Expand Down Expand Up @@ -248,7 +248,7 @@ public static function dataOptionFiltering()
],
],
'Default options only' => [
'longOptions' => explode(',', Help::DEFAULT_LONG_OPTIONS),
'longOptions' => Help::DEFAULT_LONG_OPTIONS,
'shortOptions' => Help::DEFAULT_SHORT_OPTIONS,
'expected' => [
'Scan targets' => 8,
Expand Down
Loading