Using tempest/highlight 2.10.2, the following piece of code results in a fatal error:
<?php
use Tempest\Highlight\Highlighter;
require_once __DIR__ . '/../vendor/autoload.php';
$highlighter = new Highlighter();
$code = '$foo = {_"SELECT * FROM users"_};';
$highlighter->parse($code, 'php');
PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, null given in /vendor/tempest/highlight/src/Languages/Base/Injections/AdditionInjection.php:21
Stack trace:
#0 /vendor/tempest/highlight/src/Languages/Base/Injections/AdditionInjection.php(21): str_replace()
#1 /vendor/tempest/highlight/src/Highlighter.php(146): Tempest\Highlight\Languages\Base\Injections\AdditionInjection->parse()
#2 /vendor/tempest/highlight/src/Highlighter.php(96): Tempest\Highlight\Highlighter->parseContent()
#3 reproduce.php(11): Tempest\Highlight\Highlighter->parse()
#4 {main}
thrown in /vendor/tempest/highlight/src/Languages/Base/Injections/AdditionInjection.php on line 21
Using tempest/highlight 2.10.2, the following piece of code results in a fatal error:
It looks like the
preg_replace('/\R/u', PHP_EOL, $content)
call in https://github.com/tempestphp/highlight/blob/2.10.2/src/Languages/Base/Injections/AdditionInjection.php#L19 is returningnull
.Using Xdebug, if I evaluate
preg_last_error_msg()
right after this line I get the following error message:Note that I'm using the emphasis tags
{_ _}
around the string. Without those it works fine:Details of my PHP version: