Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Dumper/HtmlDumper.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
28 protected $dumpSuffix = '</pre><script>Sfdump(%s)</script>'; | 28 protected $dumpSuffix = '</pre><script>Sfdump(%s)</script>'; |
29 protected $dumpId = 'sf-dump'; | 29 protected $dumpId = 'sf-dump'; |
30 protected $colors = true; | 30 protected $colors = true; |
31 protected $headerIsDumped = false; | 31 protected $headerIsDumped = false; |
32 protected $lastDepth = -1; | 32 protected $lastDepth = -1; |
33 protected $styles = array( | 33 protected $styles = [ |
34 'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', | 34 'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', |
35 'num' => 'font-weight:bold; color:#1299DA', | 35 'num' => 'font-weight:bold; color:#1299DA', |
36 'const' => 'font-weight:bold', | 36 'const' => 'font-weight:bold', |
37 'str' => 'font-weight:bold; color:#56DB3A', | 37 'str' => 'font-weight:bold; color:#56DB3A', |
38 'note' => 'color:#1299DA', | 38 'note' => 'color:#1299DA', |
42 'private' => 'color:#FFFFFF', | 42 'private' => 'color:#FFFFFF', |
43 'meta' => 'color:#B729D9', | 43 'meta' => 'color:#B729D9', |
44 'key' => 'color:#56DB3A', | 44 'key' => 'color:#56DB3A', |
45 'index' => 'color:#1299DA', | 45 'index' => 'color:#1299DA', |
46 'ellipsis' => 'color:#FF8400', | 46 'ellipsis' => 'color:#FF8400', |
47 ); | 47 ]; |
48 | 48 |
49 private $displayOptions = array( | 49 private $displayOptions = [ |
50 'maxDepth' => 1, | 50 'maxDepth' => 1, |
51 'maxStringLength' => 160, | 51 'maxStringLength' => 160, |
52 'fileLinkFormat' => null, | 52 'fileLinkFormat' => null, |
53 ); | 53 ]; |
54 private $extraDisplayOptions = array(); | 54 private $extraDisplayOptions = []; |
55 | 55 |
56 /** | 56 /** |
57 * {@inheritdoc} | 57 * {@inheritdoc} |
58 */ | 58 */ |
59 public function __construct($output = null, $charset = null, $flags = 0) | 59 public function __construct($output = null, $charset = null, $flags = 0) |
106 } | 106 } |
107 | 107 |
108 /** | 108 /** |
109 * {@inheritdoc} | 109 * {@inheritdoc} |
110 */ | 110 */ |
111 public function dump(Data $data, $output = null, array $extraDisplayOptions = array()) | 111 public function dump(Data $data, $output = null, array $extraDisplayOptions = []) |
112 { | 112 { |
113 $this->extraDisplayOptions = $extraDisplayOptions; | 113 $this->extraDisplayOptions = $extraDisplayOptions; |
114 $result = parent::dump($data, $output); | 114 $result = parent::dump($data, $output); |
115 $this->dumpId = 'sf-dump-'.mt_rand(); | 115 $this->dumpId = 'sf-dump-'.mt_rand(); |
116 | 116 |
783 } | 783 } |
784 | 784 |
785 /** | 785 /** |
786 * {@inheritdoc} | 786 * {@inheritdoc} |
787 */ | 787 */ |
788 protected function style($style, $value, $attr = array()) | 788 protected function style($style, $value, $attr = []) |
789 { | 789 { |
790 if ('' === $value) { | 790 if ('' === $value) { |
791 return ''; | 791 return ''; |
792 } | 792 } |
793 | 793 |
824 if (isset($attr['ellipsis-type'])) { | 824 if (isset($attr['ellipsis-type'])) { |
825 $class = sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']); | 825 $class = sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']); |
826 } | 826 } |
827 $label = esc(substr($value, -$attr['ellipsis'])); | 827 $label = esc(substr($value, -$attr['ellipsis'])); |
828 $style = str_replace(' title="', " title=\"$v\n", $style); | 828 $style = str_replace(' title="', " title=\"$v\n", $style); |
829 $v = sprintf('<span class=%s>%s</span>', $class, substr($v, 0, -strlen($label))); | 829 $v = sprintf('<span class=%s>%s</span>', $class, substr($v, 0, -\strlen($label))); |
830 | 830 |
831 if (!empty($attr['ellipsis-tail'])) { | 831 if (!empty($attr['ellipsis-tail'])) { |
832 $tail = strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']))); | 832 $tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']))); |
833 $v .= sprintf('<span class=sf-dump-ellipsis>%s</span>%s', substr($label, 0, $tail), substr($label, $tail)); | 833 $v .= sprintf('<span class=sf-dump-ellipsis>%s</span>%s', substr($label, 0, $tail), substr($label, $tail)); |
834 } else { | 834 } else { |
835 $v .= $label; | 835 $v .= $label; |
836 } | 836 } |
837 } | 837 } |
838 | 838 |
839 $v = "<span class=sf-dump-{$style}>".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { | 839 $v = "<span class=sf-dump-{$style}>".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { |
840 $s = '<span class=sf-dump-default>'; | 840 $s = '<span class=sf-dump-default>'; |
841 $c = $c[$i = 0]; | 841 $c = $c[$i = 0]; |
842 do { | 842 do { |
843 $s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', ord($c[$i])); | 843 $s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', \ord($c[$i])); |
844 } while (isset($c[++$i])); | 844 } while (isset($c[++$i])); |
845 | 845 |
846 return $s.'</span>'; | 846 return $s.'</span>'; |
847 }, $v).'</span>'; | 847 }, $v).'</span>'; |
848 | 848 |
871 if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) { | 871 if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) { |
872 $this->line = $this->getDumpHeader().$this->line; | 872 $this->line = $this->getDumpHeader().$this->line; |
873 } | 873 } |
874 | 874 |
875 if (-1 === $depth) { | 875 if (-1 === $depth) { |
876 $args = array('"'.$this->dumpId.'"'); | 876 $args = ['"'.$this->dumpId.'"']; |
877 if ($this->extraDisplayOptions) { | 877 if ($this->extraDisplayOptions) { |
878 $args[] = json_encode($this->extraDisplayOptions, JSON_FORCE_OBJECT); | 878 $args[] = json_encode($this->extraDisplayOptions, JSON_FORCE_OBJECT); |
879 } | 879 } |
880 // Replace is for BC | 880 // Replace is for BC |
881 $this->line .= sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args)); | 881 $this->line .= sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args)); |
893 private function getSourceLink($file, $line) | 893 private function getSourceLink($file, $line) |
894 { | 894 { |
895 $options = $this->extraDisplayOptions + $this->displayOptions; | 895 $options = $this->extraDisplayOptions + $this->displayOptions; |
896 | 896 |
897 if ($fmt = $options['fileLinkFormat']) { | 897 if ($fmt = $options['fileLinkFormat']) { |
898 return is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); | 898 return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); |
899 } | 899 } |
900 | 900 |
901 return false; | 901 return false; |
902 } | 902 } |
903 } | 903 } |