Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-kernel/Debug/FileLinkFormatter.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
32 * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand | 32 * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand |
33 */ | 33 */ |
34 public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) | 34 public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) |
35 { | 35 { |
36 $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | 36 $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); |
37 if ($fileLinkFormat && !is_array($fileLinkFormat)) { | 37 if ($fileLinkFormat && !\is_array($fileLinkFormat)) { |
38 $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f); | 38 $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f); |
39 $fileLinkFormat = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); | 39 $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); |
40 } | 40 } |
41 | 41 |
42 $this->fileLinkFormat = $fileLinkFormat; | 42 $this->fileLinkFormat = $fileLinkFormat; |
43 $this->requestStack = $requestStack; | 43 $this->requestStack = $requestStack; |
44 $this->baseDir = $baseDir; | 44 $this->baseDir = $baseDir; |
48 public function format($file, $line) | 48 public function format($file, $line) |
49 { | 49 { |
50 if ($fmt = $this->getFileLinkFormat()) { | 50 if ($fmt = $this->getFileLinkFormat()) { |
51 for ($i = 1; isset($fmt[$i]); ++$i) { | 51 for ($i = 1; isset($fmt[$i]); ++$i) { |
52 if (0 === strpos($file, $k = $fmt[$i++])) { | 52 if (0 === strpos($file, $k = $fmt[$i++])) { |
53 $file = substr_replace($file, $fmt[$i], 0, strlen($k)); | 53 $file = substr_replace($file, $fmt[$i], 0, \strlen($k)); |
54 break; | 54 break; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 return strtr($fmt[0], array('%f' => $file, '%l' => $line)); | 58 return strtr($fmt[0], ['%f' => $file, '%l' => $line]); |
59 } | 59 } |
60 | 60 |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 /** | |
65 * @internal | |
66 */ | |
64 public function serialize() | 67 public function serialize() |
65 { | 68 { |
66 return serialize($this->getFileLinkFormat()); | 69 return serialize($this->getFileLinkFormat()); |
67 } | 70 } |
68 | 71 |
72 /** | |
73 * @internal | |
74 */ | |
69 public function unserialize($serialized) | 75 public function unserialize($serialized) |
70 { | 76 { |
71 if (\PHP_VERSION_ID >= 70000) { | 77 if (\PHP_VERSION_ID >= 70000) { |
72 $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); | 78 $this->fileLinkFormat = unserialize($serialized, ['allowed_classes' => false]); |
73 } else { | 79 } else { |
74 $this->fileLinkFormat = unserialize($serialized); | 80 $this->fileLinkFormat = unserialize($serialized); |
75 } | 81 } |
76 } | 82 } |
77 | 83 |
97 if ($request instanceof Request) { | 103 if ($request instanceof Request) { |
98 if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { | 104 if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { |
99 return; | 105 return; |
100 } | 106 } |
101 | 107 |
102 return array( | 108 return [ |
103 $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, | 109 $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat, |
104 $this->baseDir.DIRECTORY_SEPARATOR, '', | 110 $this->baseDir.\DIRECTORY_SEPARATOR, '', |
105 ); | 111 ]; |
106 } | 112 } |
107 } | 113 } |
108 } | 114 } |
109 } | 115 } |