Skip to content

Commit 6818068

Browse files
committed
minor #4541 Enhancement: Use default name property to configure command names (localheinz)
This PR was merged into the 2.15 branch. Discussion ---------- Enhancement: Use default name property to configure command names This PR * [x] uses the `$defaultName` property to configure command names Fixes #4539. Commits ------- ae86d4f Enhancement: Use default name property to configure command names
2 parents f6005d7 + ae86d4f commit 6818068

File tree

6 files changed

+7
-13
lines changed

6 files changed

+7
-13
lines changed

src/Console/Command/DescribeCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949
final class DescribeCommand extends Command
5050
{
51-
const COMMAND_NAME = 'describe';
51+
protected static $defaultName = 'describe';
5252

5353
/**
5454
* @var string[]
@@ -86,7 +86,6 @@ public function __construct(FixerFactory $fixerFactory = null)
8686
protected function configure()
8787
{
8888
$this
89-
->setName(self::COMMAND_NAME)
9089
->setDefinition(
9190
[
9291
new InputArgument('name', InputArgument::REQUIRED, 'Name of rule / set.'),

src/Console/Command/FixCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
final class FixCommand extends Command
4343
{
44-
const COMMAND_NAME = 'fix';
44+
protected static $defaultName = 'fix';
4545

4646
/**
4747
* @var EventDispatcherInterface
@@ -95,7 +95,6 @@ public function getHelp()
9595
protected function configure()
9696
{
9797
$this
98-
->setName(self::COMMAND_NAME)
9998
->setDefinition(
10099
[
101100
new InputArgument('path', InputArgument::IS_ARRAY, 'The path.'),

src/Console/Command/HelpCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
final class HelpCommand extends BaseHelpCommand
4343
{
44-
const COMMAND_NAME = 'help';
44+
protected static $defaultName = 'help';
4545

4646
/**
4747
* Returns help-copy suitable for console output.

src/Console/Command/ReadmeCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@
2525
*/
2626
final class ReadmeCommand extends Command
2727
{
28-
const COMMAND_NAME = 'readme';
28+
protected static $defaultName = 'readme';
2929

3030
/**
3131
* {@inheritdoc}
3232
*/
3333
protected function configure()
3434
{
35-
$this
36-
->setName(self::COMMAND_NAME)
37-
->setDescription('Generates the README content, based on the fix command help.')
38-
;
35+
$this->setDescription('Generates the README content, based on the fix command help.');
3936
}
4037

4138
/**

src/Console/Command/SelfUpdateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
final class SelfUpdateCommand extends Command
3434
{
35-
const COMMAND_NAME = 'self-update';
35+
protected static $defaultName = 'self-update';
3636

3737
/**
3838
* @var NewVersionCheckerInterface
@@ -67,7 +67,6 @@ public function __construct(
6767
protected function configure()
6868
{
6969
$this
70-
->setName(self::COMMAND_NAME)
7170
->setAliases(['selfupdate'])
7271
->setDefinition(
7372
[

tests/AutoReview/CommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class CommandTest extends TestCase
3434
*/
3535
public function testCommandHasNameConst(Command $command)
3636
{
37-
static::assertSame($command->getName(), \constant(\get_class($command).'::COMMAND_NAME'));
37+
static::assertNotNull($command->getDefaultName());
3838
}
3939

4040
public function provideCommandHasNameConstCases()

0 commit comments

Comments
 (0)