Skip to content

Commit 236b667

Browse files
authored
fix: AsCommand properties not being set on commands (#56235)
The Symfony Command uses the AsCommand attribute to set properties on the command class. However, the properties are only set if they are identical to an empty string. The Laravel Command class overrides the properties and removes the default value which causes the properties to be null and therefore not set.
1 parent a944904 commit 236b667

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Illuminate/Console/Command.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ class Command extends SymfonyCommand
4545
/**
4646
* The console command description.
4747
*
48-
* @var string|null
48+
* @var string
4949
*/
50-
protected $description;
50+
protected $description = '';
5151

5252
/**
5353
* The console command help text.
5454
*
5555
* @var string
5656
*/
57-
protected $help;
57+
protected $help = '';
5858

5959
/**
6060
* Indicates whether the command should be shown in the Artisan command list.
@@ -101,11 +101,13 @@ public function __construct()
101101
// Once we have constructed the command, we'll set the description and other
102102
// related properties of the command. If a signature wasn't used to build
103103
// the command we'll set the arguments and the options on this command.
104-
if (isset($this->description)) {
105-
$this->setDescription((string) $this->description);
104+
if (! empty($this->description)) {
105+
$this->setDescription($this->description);
106106
}
107107

108-
$this->setHelp((string) $this->help);
108+
if (! empty($this->help)) {
109+
$this->setHelp($this->help);
110+
}
109111

110112
$this->setHidden($this->isHidden());
111113

0 commit comments

Comments
 (0)