diff --git a/src/Parser/StringUnescaper.php b/src/Parser/StringUnescaper.php index 70524055..a3bbeedd 100644 --- a/src/Parser/StringUnescaper.php +++ b/src/Parser/StringUnescaper.php @@ -2,6 +2,7 @@ namespace PHPStan\PhpDocParser\Parser; +use PHPStan\ShouldNotHappenException; use function chr; use function hexdec; use function octdec; @@ -56,6 +57,9 @@ static function ($matches) { return chr((int) hexdec(substr($str, 1))); } if ($str[0] === 'u') { + if (!isset($matches[2])) { + throw new ShouldNotHappenException(); + } return self::codePointToUtf8((int) hexdec($matches[2])); }