Skip to content

Commit cd6e3bd

Browse files
committed
refactor: remove unused conditional for < 80300
1 parent 7a26b08 commit cd6e3bd

5 files changed

Lines changed: 8 additions & 49 deletions

File tree

‎system/Debug/BaseExceptionHandler.php‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,9 @@ protected static function highlightFile(string $file, int $lineNumber, int $line
184184
$source = str_replace(["\r\n", "\r"], "\n", $source);
185185
$source = explode("\n", highlight_string($source, true));
186186

187-
if (PHP_VERSION_ID < 80300) {
188-
$source = str_replace('<br />', "\n", $source[1]);
189-
$source = explode("\n", str_replace("\r\n", "\n", $source));
190-
} else {
191-
// We have to remove these tags since we're preparing the result
192-
// ourselves and these tags are added manually at the end.
193-
$source = str_replace(['<pre><code>', '</code></pre>'], '', $source);
194-
}
187+
// We have to remove these tags since we're preparing the result
188+
// ourselves and these tags are added manually at the end.
189+
$source = str_replace(['<pre><code>', '</code></pre>'], '', $source);
195190

196191
// Get just the part to show
197192
$start = max($lineNumber - (int) round($lines / 2), 0);

‎tests/_support/Debug/highlightFile_pre_80300.html‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎tests/system/Debug/ExceptionHandlerTest.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,7 @@ public function testHighlightFile(): void
427427
$highlightFile = self::getPrivateMethodInvoker($this->handler, 'highlightFile');
428428
$result = $highlightFile(SUPPORTPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Hello.php', 16);
429429

430-
$resultFile = match (true) {
431-
PHP_VERSION_ID < 80300 => 'highlightFile_pre_80300.html',
432-
default => 'highlightFile.html',
433-
};
434-
435-
$expected = file_get_contents(SUPPORTPATH . 'Debug' . DIRECTORY_SEPARATOR . $resultFile);
430+
$expected = file_get_contents(SUPPORTPATH . 'Debug' . DIRECTORY_SEPARATOR . 'highlightFile.html');
436431

437432
$this->assertSame($expected, $result);
438433

‎tests/system/Helpers/TextHelperTest.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,7 @@ public function testCensoredWordsNonReplacement(): void
301301

302302
public function testHighlightCode(): void
303303
{
304-
// PHP 8.3 changes the output.
305-
if (PHP_VERSION_ID >= 80300) {
306-
$expect = '<pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">); </span><span style="color: #0000BB">?&gt; ?&gt;</span></code></pre>';
307-
} else {
308-
$expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
309-
}
304+
$expect = '<pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">); </span><span style="color: #0000BB">?&gt; ?&gt;</span></code></pre>';
310305

311306
$this->assertSame($expect, highlight_code('<?php var_dump($this); ?>'));
312307
}

‎tests/system/View/ParserFilterTest.php‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,9 @@ public function testHighlightCode(): void
182182

183183
$template = '{ value1|highlight_code }';
184184

185-
// PHP 8.3 changes the output.
186-
if (PHP_VERSION_ID >= 80300) {
187-
$expected = <<<'EOF'
188-
<pre><code style="color: #000000"><span style="color: #0000BB">Sincerely ?&gt;</span></code></pre>
189-
EOF;
190-
} else {
191-
$expected = <<<'EOF'
192-
<code><span style="color: #000000">
193-
<span style="color: #0000BB">Sincerely&nbsp;</span>
194-
</span>
195-
</code>
196-
EOF;
197-
}
185+
$expected = <<<'EOF'
186+
<pre><code style="color: #000000"><span style="color: #0000BB">Sincerely ?&gt;</span></code></pre>
187+
EOF;
198188

199189
$this->assertSame($expected, $parser->renderString($template));
200190
}

0 commit comments

Comments
 (0)