CliDumper.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\VarDumper\Dumper;
  11. use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
  12. use Symfony\Component\VarDumper\Cloner\Cursor;
  13. use Symfony\Component\VarDumper\Cloner\Stub;
  14. /**
  15. * CliDumper dumps variables for command line output.
  16. *
  17. * @author Nicolas Grekas <p@tchwork.com>
  18. */
  19. class CliDumper extends AbstractDumper
  20. {
  21. public static bool $defaultColors;
  22. /** @var callable|resource|string|null */
  23. public static $defaultOutput = 'php://stdout';
  24. protected bool $colors;
  25. protected int $maxStringWidth = 0;
  26. protected array $styles = [
  27. // See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28. 'default' => '0;38;5;208',
  29. 'num' => '1;38;5;38',
  30. 'const' => '1;38;5;208',
  31. 'str' => '1;38;5;113',
  32. 'note' => '38;5;38',
  33. 'ref' => '38;5;247',
  34. 'public' => '',
  35. 'protected' => '',
  36. 'private' => '',
  37. 'meta' => '38;5;170',
  38. 'key' => '38;5;113',
  39. 'index' => '38;5;38',
  40. ];
  41. protected static string $controlCharsRx = '/[\x00-\x1F\x7F]+/';
  42. protected static array $controlCharsMap = [
  43. "\t" => '\t',
  44. "\n" => '\n',
  45. "\v" => '\v',
  46. "\f" => '\f',
  47. "\r" => '\r',
  48. "\033" => '\e',
  49. ];
  50. protected static string $unicodeCharsRx = "/[\u{00A0}\u{00AD}\u{034F}\u{061C}\u{115F}\u{1160}\u{17B4}\u{17B5}\u{180E}\u{2000}-\u{200F}\u{202F}\u{205F}\u{2060}-\u{2064}\u{206A}-\u{206F}\u{3000}\u{2800}\u{3164}\u{FEFF}\u{FFA0}\u{1D159}\u{1D173}-\u{1D17A}]/u";
  51. protected bool $collapseNextHash = false;
  52. protected bool $expandNextHash = false;
  53. private array $displayOptions = [
  54. 'fileLinkFormat' => null,
  55. ];
  56. private bool $handlesHrefGracefully;
  57. public function __construct($output = null, ?string $charset = null, int $flags = 0)
  58. {
  59. parent::__construct($output, $charset, $flags);
  60. if ('\\' === \DIRECTORY_SEPARATOR && !$this->isWindowsTrueColor()) {
  61. // Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI
  62. $this->setStyles([
  63. 'default' => '31',
  64. 'num' => '1;34',
  65. 'const' => '1;31',
  66. 'str' => '1;32',
  67. 'note' => '34',
  68. 'ref' => '1;30',
  69. 'meta' => '35',
  70. 'key' => '32',
  71. 'index' => '34',
  72. ]);
  73. }
  74. $this->displayOptions['fileLinkFormat'] = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter() : (\ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l');
  75. }
  76. /**
  77. * Enables/disables colored output.
  78. */
  79. public function setColors(bool $colors): void
  80. {
  81. $this->colors = $colors;
  82. }
  83. /**
  84. * Sets the maximum number of characters per line for dumped strings.
  85. */
  86. public function setMaxStringWidth(int $maxStringWidth): void
  87. {
  88. $this->maxStringWidth = $maxStringWidth;
  89. }
  90. /**
  91. * Configures styles.
  92. *
  93. * @param array $styles A map of style names to style definitions
  94. */
  95. public function setStyles(array $styles): void
  96. {
  97. $this->styles = $styles + $this->styles;
  98. }
  99. /**
  100. * Configures display options.
  101. *
  102. * @param array $displayOptions A map of display options to customize the behavior
  103. */
  104. public function setDisplayOptions(array $displayOptions): void
  105. {
  106. $this->displayOptions = $displayOptions + $this->displayOptions;
  107. }
  108. public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value): void
  109. {
  110. $this->dumpKey($cursor);
  111. $this->collapseNextHash = $this->expandNextHash = false;
  112. $style = 'const';
  113. $attr = $cursor->attr;
  114. switch ($type) {
  115. case 'default':
  116. $style = 'default';
  117. break;
  118. case 'label':
  119. $this->styles += ['label' => $this->styles['default']];
  120. $style = 'label';
  121. break;
  122. case 'integer':
  123. $style = 'num';
  124. if (isset($this->styles['integer'])) {
  125. $style = 'integer';
  126. }
  127. break;
  128. case 'double':
  129. $style = 'num';
  130. if (isset($this->styles['float'])) {
  131. $style = 'float';
  132. }
  133. $value = match (true) {
  134. \INF === $value => 'INF',
  135. -\INF === $value => '-INF',
  136. is_nan($value) => 'NAN',
  137. default => !str_contains($value = (string) $value, $this->decimalPoint) ? $value .= $this->decimalPoint.'0' : $value,
  138. };
  139. break;
  140. case 'NULL':
  141. $value = 'null';
  142. break;
  143. case 'boolean':
  144. $value = $value ? 'true' : 'false';
  145. break;
  146. default:
  147. $attr += ['value' => $this->utf8Encode($value)];
  148. $value = $this->utf8Encode($type);
  149. break;
  150. }
  151. $this->line .= $this->style($style, $value, $attr);
  152. $this->endValue($cursor);
  153. }
  154. public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut): void
  155. {
  156. $this->dumpKey($cursor);
  157. $this->collapseNextHash = $this->expandNextHash = false;
  158. $attr = $cursor->attr;
  159. if ($bin) {
  160. $str = $this->utf8Encode($str);
  161. }
  162. if ('' === $str) {
  163. $this->line .= '""';
  164. if ($cut) {
  165. $this->line .= '…'.$cut;
  166. }
  167. $this->endValue($cursor);
  168. } else {
  169. $attr += [
  170. 'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
  171. 'binary' => $bin,
  172. ];
  173. $str = $bin && str_contains($str, "\0") ? [$str] : explode("\n", $str);
  174. if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
  175. unset($str[1]);
  176. $str[0] .= "\n";
  177. }
  178. $m = \count($str) - 1;
  179. $i = $lineCut = 0;
  180. if (self::DUMP_STRING_LENGTH & $this->flags) {
  181. $this->line .= '('.$attr['length'].') ';
  182. }
  183. if ($bin) {
  184. $this->line .= 'b';
  185. }
  186. if ($m) {
  187. $this->line .= '"""';
  188. $this->dumpLine($cursor->depth);
  189. } else {
  190. $this->line .= '"';
  191. }
  192. foreach ($str as $str) {
  193. if ($i < $m) {
  194. $str .= "\n";
  195. }
  196. if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
  197. $str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
  198. $lineCut = $len - $this->maxStringWidth;
  199. }
  200. if ($m && 0 < $cursor->depth) {
  201. $this->line .= $this->indentPad;
  202. }
  203. if ('' !== $str) {
  204. $this->line .= $this->style('str', $str, $attr);
  205. }
  206. if ($i++ == $m) {
  207. if ($m) {
  208. if ('' !== $str) {
  209. $this->dumpLine($cursor->depth);
  210. if (0 < $cursor->depth) {
  211. $this->line .= $this->indentPad;
  212. }
  213. }
  214. $this->line .= '"""';
  215. } else {
  216. $this->line .= '"';
  217. }
  218. if ($cut < 0) {
  219. $this->line .= '…';
  220. $lineCut = 0;
  221. } elseif ($cut) {
  222. $lineCut += $cut;
  223. }
  224. }
  225. if ($lineCut) {
  226. $this->line .= '…'.$lineCut;
  227. $lineCut = 0;
  228. }
  229. if ($i > $m) {
  230. $this->endValue($cursor);
  231. } else {
  232. $this->dumpLine($cursor->depth);
  233. }
  234. }
  235. }
  236. }
  237. public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild): void
  238. {
  239. $this->colors ??= $this->supportsColors();
  240. $this->dumpKey($cursor);
  241. $this->expandNextHash = false;
  242. $attr = $cursor->attr;
  243. if ($this->collapseNextHash) {
  244. $cursor->skipChildren = true;
  245. $this->collapseNextHash = $hasChild = false;
  246. }
  247. $class = $this->utf8Encode($class);
  248. if (Cursor::HASH_OBJECT === $type) {
  249. $prefix = $class && 'stdClass' !== $class ? $this->style('note', $class, $attr).(empty($attr['cut_hash']) ? ' {' : '') : '{';
  250. } elseif (Cursor::HASH_RESOURCE === $type) {
  251. $prefix = $this->style('note', $class.' resource', $attr).($hasChild ? ' {' : ' ');
  252. } else {
  253. $prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '[';
  254. }
  255. if (($cursor->softRefCount || 0 < $cursor->softRefHandle) && empty($attr['cut_hash'])) {
  256. $prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), ['count' => $cursor->softRefCount]);
  257. } elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) {
  258. $prefix .= $this->style('ref', '&'.$cursor->hardRefTo, ['count' => $cursor->hardRefCount]);
  259. } elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) {
  260. $prefix = substr($prefix, 0, -1);
  261. }
  262. $this->line .= $prefix;
  263. if ($hasChild) {
  264. $this->dumpLine($cursor->depth);
  265. }
  266. }
  267. public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut): void
  268. {
  269. if (empty($cursor->attr['cut_hash'])) {
  270. $this->dumpEllipsis($cursor, $hasChild, $cut);
  271. $this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : ''));
  272. }
  273. $this->endValue($cursor);
  274. }
  275. /**
  276. * Dumps an ellipsis for cut children.
  277. *
  278. * @param bool $hasChild When the dump of the hash has child item
  279. * @param int $cut The number of items the hash has been cut by
  280. */
  281. protected function dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut): void
  282. {
  283. if ($cut) {
  284. $this->line .= ' …';
  285. if (0 < $cut) {
  286. $this->line .= $cut;
  287. }
  288. if ($hasChild) {
  289. $this->dumpLine($cursor->depth + 1);
  290. }
  291. }
  292. }
  293. /**
  294. * Dumps a key in a hash structure.
  295. */
  296. protected function dumpKey(Cursor $cursor): void
  297. {
  298. if (null !== $key = $cursor->hashKey) {
  299. if ($cursor->hashKeyIsBinary) {
  300. $key = $this->utf8Encode($key);
  301. }
  302. $attr = ['binary' => $cursor->hashKeyIsBinary];
  303. $bin = $cursor->hashKeyIsBinary ? 'b' : '';
  304. $style = 'key';
  305. switch ($cursor->hashType) {
  306. default:
  307. case Cursor::HASH_INDEXED:
  308. if (self::DUMP_LIGHT_ARRAY & $this->flags) {
  309. break;
  310. }
  311. $style = 'index';
  312. // no break
  313. case Cursor::HASH_ASSOC:
  314. if (\is_int($key)) {
  315. $this->line .= $this->style($style, $key).' => ';
  316. } else {
  317. $this->line .= $bin.'"'.$this->style($style, $key).'" => ';
  318. }
  319. break;
  320. case Cursor::HASH_RESOURCE:
  321. $key = "\0~\0".$key;
  322. // no break
  323. case Cursor::HASH_OBJECT:
  324. if (!isset($key[0]) || "\0" !== $key[0]) {
  325. $this->line .= '+'.$bin.$this->style('public', $key).': ';
  326. } elseif (0 < strpos($key, "\0", 1)) {
  327. $key = explode("\0", substr($key, 1), 2);
  328. switch ($key[0][0]) {
  329. case '+': // User inserted keys
  330. $attr['dynamic'] = true;
  331. $this->line .= '+'.$bin.'"'.$this->style('public', $key[1], $attr).'": ';
  332. break 2;
  333. case '~':
  334. $style = 'meta';
  335. if (isset($key[0][1])) {
  336. parse_str(substr($key[0], 1), $attr);
  337. $attr += ['binary' => $cursor->hashKeyIsBinary];
  338. }
  339. break;
  340. case '*':
  341. $style = 'protected';
  342. $bin = '#'.$bin;
  343. break;
  344. default:
  345. $attr['class'] = $key[0];
  346. $style = 'private';
  347. $bin = '-'.$bin;
  348. break;
  349. }
  350. if (isset($attr['collapse'])) {
  351. if ($attr['collapse']) {
  352. $this->collapseNextHash = true;
  353. } else {
  354. $this->expandNextHash = true;
  355. }
  356. }
  357. $this->line .= $bin.$this->style($style, $key[1], $attr).($attr['separator'] ?? ': ');
  358. } else {
  359. // This case should not happen
  360. $this->line .= '-'.$bin.'"'.$this->style('private', $key, ['class' => '']).'": ';
  361. }
  362. break;
  363. }
  364. if ($cursor->hardRefTo) {
  365. $this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), ['count' => $cursor->hardRefCount]).' ';
  366. }
  367. }
  368. }
  369. /**
  370. * Decorates a value with some style.
  371. *
  372. * @param string $style The type of style being applied
  373. * @param string $value The value being styled
  374. * @param array $attr Optional context information
  375. */
  376. protected function style(string $style, string $value, array $attr = []): string
  377. {
  378. $this->colors ??= $this->supportsColors();
  379. $this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
  380. && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
  381. && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
  382. if (isset($attr['ellipsis'], $attr['ellipsis-type'])) {
  383. $prefix = substr($value, 0, -$attr['ellipsis']);
  384. if ('cli' === \PHP_SAPI && 'path' === $attr['ellipsis-type'] && isset($_SERVER[$pwd = '\\' === \DIRECTORY_SEPARATOR ? 'CD' : 'PWD']) && str_starts_with($prefix, $_SERVER[$pwd])) {
  385. $prefix = '.'.substr($prefix, \strlen($_SERVER[$pwd]));
  386. }
  387. if (!empty($attr['ellipsis-tail'])) {
  388. $prefix .= substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']);
  389. $value = substr($value, -$attr['ellipsis'] + $attr['ellipsis-tail']);
  390. } else {
  391. $value = substr($value, -$attr['ellipsis']);
  392. }
  393. $value = $this->style('default', $prefix).$this->style($style, $value);
  394. goto href;
  395. }
  396. $map = static::$controlCharsMap;
  397. $startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : '';
  398. $endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : '';
  399. $value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) {
  400. $s = $startCchr;
  401. $c = $c[$i = 0];
  402. do {
  403. $s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
  404. } while (isset($c[++$i]));
  405. return $s.$endCchr;
  406. }, $value, -1, $cchrCount);
  407. if (!($attr['binary'] ?? false)) {
  408. $value = preg_replace_callback(static::$unicodeCharsRx, function ($c) use (&$cchrCount, $startCchr, $endCchr) {
  409. ++$cchrCount;
  410. return $startCchr.'\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'.$endCchr;
  411. }, $value);
  412. }
  413. if ($this->colors && '' !== $value) {
  414. if ($cchrCount && "\033" === $value[0]) {
  415. $value = substr($value, \strlen($startCchr));
  416. } else {
  417. $value = "\033[{$this->styles[$style]}m".$value;
  418. }
  419. if ($cchrCount && str_ends_with($value, $endCchr)) {
  420. $value = substr($value, 0, -\strlen($endCchr));
  421. } else {
  422. $value .= "\033[{$this->styles['default']}m";
  423. }
  424. }
  425. href:
  426. if ($this->colors && $this->handlesHrefGracefully) {
  427. if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) {
  428. if ('note' === $style) {
  429. $value .= "\033]8;;{$href}\033\\^\033]8;;\033\\";
  430. } else {
  431. $attr['href'] = $href;
  432. }
  433. }
  434. if (isset($attr['href'])) {
  435. if ('label' === $style) {
  436. $value .= '^';
  437. }
  438. $value = "\033]8;;{$attr['href']}\033\\{$value}\033]8;;\033\\";
  439. }
  440. }
  441. if ('label' === $style && '' !== $value) {
  442. $value .= ' ';
  443. }
  444. return $value;
  445. }
  446. protected function supportsColors(): bool
  447. {
  448. if ($this->outputStream !== static::$defaultOutput) {
  449. return $this->hasColorSupport($this->outputStream);
  450. }
  451. if (isset(static::$defaultColors)) {
  452. return static::$defaultColors;
  453. }
  454. if (isset($_SERVER['argv'][1])) {
  455. $colors = $_SERVER['argv'];
  456. $i = \count($colors);
  457. while (--$i > 0) {
  458. if (isset($colors[$i][5])) {
  459. switch ($colors[$i]) {
  460. case '--ansi':
  461. case '--color':
  462. case '--color=yes':
  463. case '--color=force':
  464. case '--color=always':
  465. case '--colors=always':
  466. return static::$defaultColors = true;
  467. case '--no-ansi':
  468. case '--color=no':
  469. case '--color=none':
  470. case '--color=never':
  471. case '--colors=never':
  472. return static::$defaultColors = false;
  473. }
  474. }
  475. }
  476. }
  477. $h = stream_get_meta_data($this->outputStream) + ['wrapper_type' => null];
  478. $h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'w') : $this->outputStream;
  479. return static::$defaultColors = $this->hasColorSupport($h);
  480. }
  481. protected function dumpLine(int $depth, bool $endOfValue = false): void
  482. {
  483. if ($this->colors ??= $this->supportsColors()) {
  484. $this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
  485. }
  486. parent::dumpLine($depth);
  487. }
  488. protected function endValue(Cursor $cursor): void
  489. {
  490. if (-1 === $cursor->hashType) {
  491. return;
  492. }
  493. if (Stub::ARRAY_INDEXED === $cursor->hashType || Stub::ARRAY_ASSOC === $cursor->hashType) {
  494. if (self::DUMP_TRAILING_COMMA & $this->flags && 0 < $cursor->depth) {
  495. $this->line .= ',';
  496. } elseif (self::DUMP_COMMA_SEPARATOR & $this->flags && 1 < $cursor->hashLength - $cursor->hashIndex) {
  497. $this->line .= ',';
  498. }
  499. }
  500. $this->dumpLine($cursor->depth, true);
  501. }
  502. /**
  503. * Returns true if the stream supports colorization.
  504. *
  505. * Reference: Composer\XdebugHandler\Process::supportsColor
  506. * https://github.com/composer/xdebug-handler
  507. */
  508. private function hasColorSupport(mixed $stream): bool
  509. {
  510. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  511. return false;
  512. }
  513. // Follow https://no-color.org/
  514. if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
  515. return false;
  516. }
  517. // Detect msysgit/mingw and assume this is a tty because detection
  518. // does not work correctly, see https://github.com/composer/composer/issues/9690
  519. if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
  520. return false;
  521. }
  522. if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($stream)) {
  523. return true;
  524. }
  525. if ('Hyper' === getenv('TERM_PROGRAM')
  526. || false !== getenv('COLORTERM')
  527. || false !== getenv('ANSICON')
  528. || 'ON' === getenv('ConEmuANSI')
  529. ) {
  530. return true;
  531. }
  532. if ('dumb' === $term = (string) getenv('TERM')) {
  533. return false;
  534. }
  535. // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
  536. return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
  537. }
  538. /**
  539. * Returns true if the Windows terminal supports true color.
  540. *
  541. * Note that this does not check an output stream, but relies on environment
  542. * variables from known implementations, or a PHP and Windows version that
  543. * supports true color.
  544. */
  545. private function isWindowsTrueColor(): bool
  546. {
  547. $result = 183 <= getenv('ANSICON_VER')
  548. || 'ON' === getenv('ConEmuANSI')
  549. || 'xterm' === getenv('TERM')
  550. || 'Hyper' === getenv('TERM_PROGRAM');
  551. if (!$result) {
  552. $version = sprintf(
  553. '%s.%s.%s',
  554. PHP_WINDOWS_VERSION_MAJOR,
  555. PHP_WINDOWS_VERSION_MINOR,
  556. PHP_WINDOWS_VERSION_BUILD
  557. );
  558. $result = $version >= '10.0.15063';
  559. }
  560. return $result;
  561. }
  562. private function getSourceLink(string $file, int $line): string|false
  563. {
  564. if ($fmt = $this->displayOptions['fileLinkFormat']) {
  565. return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : ($fmt->format($file, $line) ?: 'file://'.$file.'#L'.$line);
  566. }
  567. return false;
  568. }
  569. }