Skip to content

Commit

Permalink
Allow both '{' and T_CURLY_OPEN as curly bracket (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Quissens authored Dec 3, 2020
1 parent bc7a9bf commit c64986f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/PhpParser/Internal/TokenStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function haveParens(int $startPos, int $endPos) : bool {
* @return bool
*/
public function haveBraces(int $startPos, int $endPos) : bool {
return $this->haveTokenImmediatelyBefore($startPos, '{')
return ($this->haveTokenImmediatelyBefore($startPos, '{')
|| $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
&& $this->haveTokenImmediatelyAfter($endPos, '}');
}

Expand Down Expand Up @@ -201,6 +202,7 @@ public function haveTokenInRange(int $startPos, int $endPos, $tokenType) {

public function haveBracesInRange(int $startPos, int $endPos) {
return $this->haveTokenInRange($startPos, $endPos, '{')
|| $this->haveTokenInRange($startPos, $endPos, T_CURLY_OPEN)
|| $this->haveTokenInRange($startPos, $endPos, '}');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Rewrite string with variable interpolation
-----
<?php
"{$e}";
-----
$stmts[0]->expr->parts[0]->setAttribute('origNode', null);
-----
<?php
"{$e}";

0 comments on commit c64986f

Please sign in to comment.