function StringUnescaper::codePointToUtf8
* Implementation based on https://github.com/nikic/PHP-Parser/blob/b0edd4c41111042d43bb45c6c657b2…
1 call to StringUnescaper::codePointToUtf8()
- StringUnescaper::parseEscapeSequences in vendor/
phpstan/ phpdoc-parser/ src/ Parser/ StringUnescaper.php - * Implementation based on https://github.com/nikic/PHP-Parser/blob/b0edd4c41111042d43bb45c6c657b2…
File
-
vendor/
phpstan/ phpdoc-parser/ src/ Parser/ StringUnescaper.php, line 75
Class
Namespace
PHPStan\PhpDocParser\ParserCode
private static function codePointToUtf8(int $num) : string {
if ($num <= 0x7f) {
return chr($num);
}
if ($num <= 0x7ff) {
return chr(($num >> 6) + 0xc0) . chr(($num & 0x3f) + 0x80);
}
if ($num <= 0xffff) {
return chr(($num >> 12) + 0xe0) . chr(($num >> 6 & 0x3f) + 0x80) . chr(($num & 0x3f) + 0x80);
}
if ($num <= 0x1fffff) {
return chr(($num >> 18) + 0xf0) . chr(($num >> 12 & 0x3f) + 0x80) . chr(($num >> 6 & 0x3f) + 0x80) . chr(($num & 0x3f) + 0x80);
}
// Invalid UTF-8 codepoint escape sequence: Codepoint too large
return "�";
}