Skip to content

Commit

Permalink
Allow both '{' as T_CURLY_OPEN as curly bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Quissens committed Nov 25, 2020
1 parent 1d1bc8a commit abfbbca
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
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
@@ -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 abfbbca

Please sign in to comment.