comparison vendor/symfony/var-dumper/Dumper/CliDumper.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 5fb285c0d0e3
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
49 "\v" => '\v', 49 "\v" => '\v',
50 "\f" => '\f', 50 "\f" => '\f',
51 "\r" => '\r', 51 "\r" => '\r',
52 "\033" => '\e', 52 "\033" => '\e',
53 ); 53 );
54
55 protected $collapseNextHash = false;
56 protected $expandNextHash = false;
54 57
55 /** 58 /**
56 * {@inheritdoc} 59 * {@inheritdoc}
57 */ 60 */
58 public function __construct($output = null, $charset = null, $flags = 0) 61 public function __construct($output = null, $charset = null, $flags = 0)
251 * {@inheritdoc} 254 * {@inheritdoc}
252 */ 255 */
253 public function enterHash(Cursor $cursor, $type, $class, $hasChild) 256 public function enterHash(Cursor $cursor, $type, $class, $hasChild)
254 { 257 {
255 $this->dumpKey($cursor); 258 $this->dumpKey($cursor);
259
260 if ($this->collapseNextHash) {
261 $cursor->skipChildren = true;
262 $this->collapseNextHash = $hasChild = false;
263 }
256 264
257 $class = $this->utf8Encode($class); 265 $class = $this->utf8Encode($class);
258 if (Cursor::HASH_OBJECT === $type) { 266 if (Cursor::HASH_OBJECT === $type) {
259 $prefix = $class && 'stdClass' !== $class ? $this->style('note', $class).' {' : '{'; 267 $prefix = $class && 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
260 } elseif (Cursor::HASH_RESOURCE === $type) { 268 } elseif (Cursor::HASH_RESOURCE === $type) {
368 $style = 'private'; 376 $style = 'private';
369 $bin = '-'.$bin; 377 $bin = '-'.$bin;
370 break; 378 break;
371 } 379 }
372 380
373 $this->line .= $bin.$this->style($style, $key[1], $attr).': '; 381 if (isset($attr['collapse'])) {
382 if ($attr['collapse']) {
383 $this->collapseNextHash = true;
384 } else {
385 $this->expandNextHash = true;
386 }
387 }
388
389 $this->line .= $bin.$this->style($style, $key[1], $attr).(isset($attr['separator']) ? $attr['separator'] : ': ');
374 } else { 390 } else {
375 // This case should not happen 391 // This case should not happen
376 $this->line .= '-'.$bin.'"'.$this->style('private', $key, array('class' => '')).'": '; 392 $this->line .= '-'.$bin.'"'.$this->style('private', $key, array('class' => '')).'": ';
377 } 393 }
378 break; 394 break;
395 */ 411 */
396 protected function style($style, $value, $attr = array()) 412 protected function style($style, $value, $attr = array())
397 { 413 {
398 if (null === $this->colors) { 414 if (null === $this->colors) {
399 $this->colors = $this->supportsColors(); 415 $this->colors = $this->supportsColors();
416 }
417
418 if (isset($attr['ellipsis'], $attr['ellipsis-type'])) {
419 $prefix = substr($value, 0, -$attr['ellipsis']);
420 if ('cli' === PHP_SAPI && 'path' === $attr['ellipsis-type'] && isset($_SERVER[$pwd = '\\' === DIRECTORY_SEPARATOR ? 'CD' : 'PWD']) && 0 === strpos($prefix, $_SERVER[$pwd])) {
421 $prefix = '.'.substr($prefix, strlen($_SERVER[$pwd]));
422 }
423 if (!empty($attr['ellipsis-tail'])) {
424 $prefix .= substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']);
425 $value = substr($value, -$attr['ellipsis'] + $attr['ellipsis-tail']);
426 } else {
427 $value = substr($value, -$attr['ellipsis']);
428 }
429
430 return $this->style('default', $prefix).$this->style($style, $value);
400 } 431 }
401 432
402 $style = $this->styles[$style]; 433 $style = $this->styles[$style];
403 434
404 $map = static::$controlCharsMap; 435 $map = static::$controlCharsMap;