8000 minor #19035 [Console] added explanation of messages usage in a progr… · symfony/symfony@ad1ffc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad1ffc5

Browse files
committed
minor #19035 [Console] added explanation of messages usage in a progress bar (fabpot)
This PR was merged into the 2.7 branch. Discussion ---------- [Console] added explanation of messages usage in a progress bar | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19031 | License | MIT | Doc PR | symfony/symfony-docs#6544 The intent of progress bar messages is currently wrongly documented. This PR updates the phpdoc to hopefully better describe the usage of such messages. So, basically, messages are a way to add dynamic information in the progress bar; information that cannot be computed by the progress bar (like for all other placeholders). Commits ------- d92f3ea [Console] added explanation of messages usage in a progress bar
2 parents 3f192dc + d92f3ea commit ad1ffc5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ProgressBar
4141
private $stepWidth;
4242
private $percent = 0.0;
4343
private $formatLineCount;
44-
private $messages;
44+
private $messages = array();
4545
private $overwrite = true;
4646

4747
private static $formatters;
@@ -139,6 +139,16 @@ public static function getFormatDefinition($name)
139139
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
140140
}
141141

142+
/**
143+
* Associates a text with a named placeholder.
144+
*
145+
* The text is displayed when the progress bar is rendered but only
146+
* when the corresponding placeholder is part of the custom format line
147+
* (by wrapping the name with %).
148+
*
149+
* @param string $message The text to associate with the placeholder
150+
* @param string $name The name of the placeholder
151+
*/
142152
public function setMessage($message, $name = 'message')
143153
{
144154
$this->messages[$name] = $message;

0 commit comments

Comments
 (0)
0