Thanks to visit codestin.com
Credit goes to github.com

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/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public function setHelp($help)
*/
public function getHelp()
{
return $this->help ?: $this->description;
return $this->help;
}

/**
Expand All @@ -513,7 +513,7 @@ public function getProcessedHelp()
$_SERVER['PHP_SELF'].' '.$name,
);

return str_replace($placeholders, $replacements, $this->getHelp());
return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Console/Tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function testGetSetHelp()
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
$command->setHelp('');
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
$this->assertEquals('', $command->getHelp(), '->getHelp() does not fall back to the description');
}

public function testGetProcessedHelp()
Expand All @@ -141,6 +141,10 @@ public function testGetProcessedHelp()
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly');
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%');

$command = new \TestCommand();
$command->setHelp('');
$this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description');
}

public function testGetSetAliases()
Expand Down