Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38f7a6f

Browse files
committed
[Console] fixed PHP comptability
1 parent244d3b8 commit38f7a6f

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

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

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ProgressBar
4444
private$formatLineCount;
4545
private$messages;
4646

47-
staticprivate$formatters;
48-
staticprivate$formats;
47+
privatestatic$formatters;
48+
privatestatic$formats;
4949

5050
/**
5151
* Constructor.
@@ -86,6 +86,18 @@ public static function setPlaceholderFormatterDefinition($name, $callable)
8686
self::$formatters[$name] =$callable;
8787
}
8888

89+
/**
90+
* Gets the placeholder formatter for a given name.
91+
*
92+
* @param string $name The placeholder name (including the delimiter char like %)
93+
*
94+
* @return callable|null A PHP callable
95+
*/
96+
publicstaticfunctiongetPlaceholderFormatterDefinition($name)
97+
{
98+
returnisset(self::$formatters[$name]) ?self::$formatters[$name] :null;
99+
}
100+
89101
/**
90102
* Sets a format for a given name.
91103
*
@@ -103,6 +115,18 @@ public static function setFormatDefinition($name, $format)
103115
self::$formats[$name] =$format;
104116
}
105117

118+
/**
119+
* Gets the format for a given name.
120+
*
121+
* @param string $name The format name
122+
*
123+
* @return string|null A format string
124+
*/
125+
publicstaticfunctiongetFormatDefinition($name)
126+
{
127+
returnisset(self::$formats[$name]) ?self::$formats[$name] :null;
128+
}
129+
106130
publicfunctionsetMessage($message,$name ='message')
107131
{
108132
$this->messages[$name] =$message;
@@ -116,7 +140,7 @@ public function getMessage($name = 'message')
116140
/**
117141
* Gets the progress bar start time.
118142
*
119-
* @returnint The progress bar start time
143+
* @returninteger The progress bar start time
120144
*/
121145
publicfunctiongetStartTime()
122146
{
@@ -126,7 +150,7 @@ public function getStartTime()
126150
/**
127151
* Gets the progress bar maximal steps.
128152
*
129-
* @returnint The progress bar max steps
153+
* @returninteger The progress bar max steps
130154
*/
131155
publicfunctiongetMaxSteps()
132156
{
@@ -136,7 +160,7 @@ public function getMaxSteps()
136160
/**
137161
* Gets the progress bar step.
138162
*
139-
* @returnint The progress bar step
163+
* @returninteger The progress bar step
140164
*/
141165
publicfunctiongetStep()
142166
{
@@ -146,7 +170,7 @@ public function getStep()
146170
/**
147171
* Gets the progress bar step width.
148172
*
149-
* @returnint The progress bar step width
173+
* @returninteger The progress bar step width
150174
*/
151175
publicfunctiongetStepWidth()
152176
{
@@ -156,7 +180,7 @@ public function getStepWidth()
156180
/**
157181
* Gets the current progress bar percent.
158182
*
159-
* @returnint The current progress bar percent
183+
* @returninteger The current progress bar percent
160184
*/
161185
publicfunctiongetProgressPercent()
162186
{
@@ -166,7 +190,7 @@ public function getProgressPercent()
166190
/**
167191
* Sets the progress bar width.
168192
*
169-
* @paramint $size The progress bar size
193+
* @paraminteger $size The progress bar size
170194
*/
171195
publicfunctionsetBarWidth($size)
172196
{
@@ -176,7 +200,7 @@ public function setBarWidth($size)
176200
/**
177201
* Gets the progress bar width.
178202
*
179-
* @returnint The progress bar size
203+
* @returninteger The progress bar size
180204
*/
181205
publicfunctiongetBarWidth()
182206
{
@@ -257,7 +281,7 @@ public function setFormat($format)
257281
/**
258282
* Sets the redraw frequency.
259283
*
260-
* @paramint $freq The frequency in steps
284+
* @paraminteger $freq The frequency in steps
261285
*/
262286
publicfunctionsetRedrawFrequency($freq)
263287
{
@@ -365,8 +389,8 @@ public function display()
365389

366390
$self =$this;
367391
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i",function ($matches)use ($self) {
368-
if (isset(self::$formatters[$matches[1]])) {
369-
$text =call_user_func(self::$formatters[$matches[1]],$self);
392+
if ($formatter =$self::getPlaceholderFormatterDefinition($matches[1])) {
393+
$text =call_user_func($formatter,$self);
370394
}elseif (isset($this->messages[$matches[1]])) {
371395
$text =$this->messages[$matches[1]];
372396
}else {
@@ -433,7 +457,7 @@ private function determineBestFormat()
433457
}
434458
}
435459

436-
staticprivatefunctioninitPlaceholderFormatters()
460+
privatestaticfunctioninitPlaceholderFormatters()
437461
{
438462
returnarray(
439463
'bar' =>function (ProgressBar$bar) {
@@ -490,7 +514,7 @@ static private function initPlaceholderFormatters()
490514
);
491515
}
492516

493-
staticprivatefunctioninitFormats()
517+
privatestaticfunctioninitFormats()
494518
{
495519
returnarray(
496520
'quiet' =>' %percent%%',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp