Allow both '{' and T_CURLY_OPEN as curly bracket (#732)

This commit is contained in:
Tommy Quissens 2020-12-03 18:42:00 +01:00 committed by GitHub
parent bc7a9bf9c2
commit c64986fa55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -46,7 +46,8 @@ class TokenStream
* @return bool * @return bool
*/ */
public function haveBraces(int $startPos, int $endPos) : 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, '}'); && $this->haveTokenImmediatelyAfter($endPos, '}');
} }
@ -201,6 +202,7 @@ class TokenStream
public function haveBracesInRange(int $startPos, int $endPos) { public function haveBracesInRange(int $startPos, int $endPos) {
return $this->haveTokenInRange($startPos, $endPos, '{') return $this->haveTokenInRange($startPos, $endPos, '{')
|| $this->haveTokenInRange($startPos, $endPos, T_CURLY_OPEN)
|| $this->haveTokenInRange($startPos, $endPos, '}'); || $this->haveTokenInRange($startPos, $endPos, '}');
} }

View File

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