function String_::parse
@internal
Parses a string token.
Parameters
string $str String token content:
bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes:
Return value
string The parsed string
1 call to String_::parse()
- String_::fromString in vendor/
nikic/ php-parser/ lib/ PhpParser/ Node/ Scalar/ String_.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Node/ Scalar/ String_.php, line 71
Class
Namespace
PhpParser\Node\ScalarCode
public static function parse(string $str, bool $parseUnicodeEscape = true) : string {
$bLength = 0;
if ('b' === $str[0] || 'B' === $str[0]) {
$bLength = 1;
}
if ('\'' === $str[$bLength]) {
return str_replace([
'\\\\',
'\\\'',
], [
'\\',
'\'',
], substr($str, $bLength + 1, -1));
}
else {
return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"', $parseUnicodeEscape);
}
}