Skip to content

Commit c64986f

Browse files
author
Tommy Quissens
authored
Allow both '{' and T_CURLY_OPEN as curly bracket (nikic#732)
1 parent bc7a9bf commit c64986f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/PhpParser/Internal/TokenStream.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function haveParens(int $startPos, int $endPos) : bool {
4646
* @return bool
4747
*/
4848
public function haveBraces(int $startPos, int $endPos) : bool {
49-
return $this->haveTokenImmediatelyBefore($startPos, '{')
49+
return ($this->haveTokenImmediatelyBefore($startPos, '{')
50+
|| $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
5051
&& $this->haveTokenImmediatelyAfter($endPos, '}');
5152
}
5253

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

202203
public function haveBracesInRange(int $startPos, int $endPos) {
203204
return $this->haveTokenInRange($startPos, $endPos, '{')
205+
|| $this->haveTokenInRange($startPos, $endPos, T_CURLY_OPEN)
204206
|| $this->haveTokenInRange($startPos, $endPos, '}');
205207
}
206208

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Rewrite string with variable interpolation
2+
-----
3+
<?php
4+
"{$e}";
5+
-----
6+
$stmts[0]->expr->parts[0]->setAttribute('origNode', null);
7+
-----
8+
<?php
9+
"{$e}";

0 commit comments

Comments
 (0)