Skip to content

Commit 4c2ca3a

Browse files
committed
fix: syntax for php 8.3
1 parent 7185a0e commit 4c2ca3a

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/Php.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,29 @@ protected static function formatCode(string $source, int $line, string $cssCodeC
195195

196196
protected static function formatXhtmlHighlight(string $source): array
197197
{
198-
return \array_slice(
199-
\explode(
200-
"\n",
198+
$highlightString = \highlight_string($source, true);
199+
$highlightString = \str_replace(
200+
['&nbsp;', '<code style="color: #000000">', '<code>', '</code>', '<pre>', '</pre>', '<br />'],
201+
[' ', '', '', '', '', '', "\n"],
202+
\preg_replace(
203+
'#color="(.*?)"#',
204+
'style="color: $1"',
201205
\str_replace(
202-
['&nbsp;', '<code>', '</code>', '<br />'],
203-
[' ', '', '', "\n"],
204-
\preg_replace(
205-
'#color="(.*?)"#',
206-
'style="color: $1"',
207-
\str_replace(
208-
['<font ', '</font>'],
209-
['<span ', '</span>'],
210-
\highlight_string($source, true)
211-
)
212-
)
206+
['<font ', '</font>'],
207+
['<span ', '</span>'],
208+
$highlightString
213209
)
214-
),
210+
)
211+
);
212+
213+
$arr = \explode("\n", $highlightString);
214+
215+
if (\PHP_VERSION_ID >= 80300) {
216+
return $arr;
217+
}
218+
219+
return \array_slice(
220+
$arr,
215221
1,
216222
-2
217223
);

0 commit comments

Comments
 (0)