File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -747,7 +747,7 @@ public function readIdentifier($prefix = null, $allowedChars = null)
747747 *
748748 * @return string|null the resulting string or null if none encountered.
749749 */
750- public function readString ($ raw = false )
750+ public function readString (array $ escapeSequences = null , $ raw = false )
751751 {
752752 if (!$ this ->peekQuote ()) {
753753 return ;
@@ -764,8 +764,12 @@ public function readString($raw = false)
764764
765765 //Handle escaping based on passed sequences
766766 if ($ char === '\\' ) {
767- //Peek the next char
768- $ string .= $ this ->consume (1 );
767+ $ nextChar = $ this ->consume (1 );
768+ $ string .= array_key_exists ($ nextChar , $ escapeSequences ?: [])
769+ //Peek the escape sequence
770+ ? $ escapeSequences [$ nextChar ]
771+ //Peek the next char
772+ : ($ raw ? $ char : '' ).$ nextChar ;
769773 continue ;
770774 }
771775
@@ -821,7 +825,7 @@ public function readExpression(array $breaks = null, array $brackets = null)
821825 //Append a string if any was found
822826 //Notice there can be brackets in strings, we dont want to
823827 //count those
824- $ expression .= $ this ->readString (true );
828+ $ expression .= $ this ->readString (null , true );
825829
826830 if (!$ this ->hasLength ()) {
827831 break ;
You can’t perform that action at this time.
0 commit comments