comparison vendor/symfony/console/Helper/ProgressIndicator.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
46 if (null === $format) { 46 if (null === $format) {
47 $format = $this->determineBestFormat(); 47 $format = $this->determineBestFormat();
48 } 48 }
49 49
50 if (null === $indicatorValues) { 50 if (null === $indicatorValues) {
51 $indicatorValues = array('-', '\\', '|', '/'); 51 $indicatorValues = ['-', '\\', '|', '/'];
52 } 52 }
53 53
54 $indicatorValues = array_values($indicatorValues); 54 $indicatorValues = array_values($indicatorValues);
55 55
56 if (2 > count($indicatorValues)) { 56 if (2 > \count($indicatorValues)) {
57 throw new InvalidArgumentException('Must have at least 2 indicator value characters.'); 57 throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
58 } 58 }
59 59
60 $this->format = self::getFormatDefinition($format); 60 $this->format = self::getFormatDefinition($format);
61 $this->indicatorChangeInterval = $indicatorChangeInterval; 61 $this->indicatorChangeInterval = $indicatorChangeInterval;
194 194
195 $self = $this; 195 $self = $this;
196 196
197 $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) { 197 $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
198 if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { 198 if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
199 return call_user_func($formatter, $self); 199 return \call_user_func($formatter, $self);
200 } 200 }
201 201
202 return $matches[0]; 202 return $matches[0];
203 }, $this->format)); 203 }, $this->format));
204 } 204 }
237 return round(microtime(true) * 1000); 237 return round(microtime(true) * 1000);
238 } 238 }
239 239
240 private static function initPlaceholderFormatters() 240 private static function initPlaceholderFormatters()
241 { 241 {
242 return array( 242 return [
243 'indicator' => function (ProgressIndicator $indicator) { 243 'indicator' => function (self $indicator) {
244 return $indicator->indicatorValues[$indicator->indicatorCurrent % count($indicator->indicatorValues)]; 244 return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)];
245 }, 245 },
246 'message' => function (ProgressIndicator $indicator) { 246 'message' => function (self $indicator) {
247 return $indicator->message; 247 return $indicator->message;
248 }, 248 },
249 'elapsed' => function (ProgressIndicator $indicator) { 249 'elapsed' => function (self $indicator) {
250 return Helper::formatTime(time() - $indicator->startTime); 250 return Helper::formatTime(time() - $indicator->startTime);
251 }, 251 },
252 'memory' => function () { 252 'memory' => function () {
253 return Helper::formatMemory(memory_get_usage(true)); 253 return Helper::formatMemory(memory_get_usage(true));
254 }, 254 },
255 ); 255 ];
256 } 256 }
257 257
258 private static function initFormats() 258 private static function initFormats()
259 { 259 {
260 return array( 260 return [
261 'normal' => ' %indicator% %message%', 261 'normal' => ' %indicator% %message%',
262 'normal_no_ansi' => ' %message%', 262 'normal_no_ansi' => ' %message%',
263 263
264 'verbose' => ' %indicator% %message% (%elapsed:6s%)', 264 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
265 'verbose_no_ansi' => ' %message% (%elapsed:6s%)', 265 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
266 266
267 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)', 267 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
268 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)', 268 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
269 ); 269 ];
270 } 270 }
271 } 271 }