Skip to content

Commit 931cb88

Browse files
committed
bug symfony#54440 [Console] return null when message with name is not set (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] return null when message with name is not set | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT same as symfony#54419 but for the `5.4` branch Commits ------- 050d8e8 return null when message with name is not set
2 parents 9b2436d + 050d8e8 commit 931cb88

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ public function setMessage(string $message, string $name = 'message')
169169
$this->messages[$name] = $message;
170170
}
171171

172+
/**
173+
* @return string|null
174+
*/
172175
public function getMessage(string $name = 'message')
173176
{
174-
return $this->messages[$name];
177+
return $this->messages[$name] ?? null;
175178
}
176179

177180
public function getStartTime(): int

src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,4 +1173,11 @@ public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
11731173
stream_get_contents($output->getStream())
11741174
);
11751175
}
1176+
1177+
public function testGetNotSetMessage()
1178+
{
1179+
$progressBar = new ProgressBar($this->getOutputStream());
1180+
1181+
$this->assertNull($progressBar->getMessage());
1182+
}
11761183
}

0 commit comments

Comments
 (0)