@@ -44,8 +44,8 @@ class ProgressBar
4444private $ formatLineCount ;
4545private $ messages ;
4646
47- static private $ formatters ;
48- static private $ formats ;
47+ private static $ formatters ;
48+ private static $ formats ;
4949
5050/**
5151 * Constructor.
@@ -86,6 +86,18 @@ public static function setPlaceholderFormatterDefinition($name, $callable)
8686self ::$ 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+ public static function getPlaceholderFormatterDefinition ($ name )
97+ {
98+ return isset (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)
103115self ::$ 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+ public static function getFormatDefinition ($ name )
126+ {
127+ return isset (self ::$ formats [$ name ]) ?self ::$ formats [$ name ] :null ;
128+ }
129+
106130public function setMessage ($ 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 */
121145public function getStartTime ()
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 */
131155public function getMaxSteps ()
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 */
141165public function getStep ()
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 */
151175public function getStepWidth ()
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 */
161185public function getProgressPercent ()
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 */
171195public function setBarWidth ($ 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 */
181205public function getBarWidth ()
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 */
262286public function setRedrawFrequency ($ 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- static private function initPlaceholderFormatters ()
460+ private static function initPlaceholderFormatters ()
437461 {
438462return array (
439463'bar ' =>function (ProgressBar $ bar ) {
@@ -490,7 +514,7 @@ static private function initPlaceholderFormatters()
490514 );
491515 }
492516
493- static private function initFormats ()
517+ private static function initFormats ()
494518 {
495519return array (
496520'quiet ' =>' %percent%% ' ,