Skip to content

Commit

Permalink
Add rawValue to InterpolatedStringPart and doc strings
Browse files Browse the repository at this point in the history
For doc strings, the rawValue (on either the String_ or
InterpolatedStringPrts) does not include the leading indentation
(which is available as docIndentation) or the trailing newline on
the last part.
  • Loading branch information
nikic committed Sep 24, 2023
1 parent 5edc190 commit f5adbb5
Show file tree
Hide file tree
Showing 5 changed files with 678 additions and 622 deletions.
7 changes: 4 additions & 3 deletions grammar/php.y
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ exit_expr:

backticks_expr:
/* empty */ { $$ = array(); }
| T_ENCAPSED_AND_WHITESPACE
{ $$ = array(Node\InterpolatedStringPart[Scalar\String_::parseEscapeSequences($1, '`', $this->phpVersion->supportsUnicodeEscapes())]); }
| encaps_string_part
{ $$ = array($1); parseEncapsed($$, '`', $this->phpVersion->supportsUnicodeEscapes()); }
| encaps_list { parseEncapsed($1, '`', $this->phpVersion->supportsUnicodeEscapes()); $$ = $1; }
;

Expand Down Expand Up @@ -1353,7 +1353,8 @@ encaps_list:
;

encaps_string_part:
T_ENCAPSED_AND_WHITESPACE { $$ = Node\InterpolatedStringPart[$1]; }
T_ENCAPSED_AND_WHITESPACE
{ $attrs = attributes(); $attrs['rawValue'] = $1; $$ = new Node\InterpolatedStringPart($1, $attrs); }
;

encaps_str_varname:
Expand Down

0 comments on commit f5adbb5

Please sign in to comment.