Fixes #10. Don't count string interpolation as a scope beginning

This commit is contained in:
ErickSkrauch 2023-03-22 18:42:23 +01:00
parent 6f14beec28
commit 2d215dc761
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
2 changed files with 19 additions and 1 deletions

View File

@ -67,8 +67,12 @@ final class BlankLineBeforeReturnFixer extends AbstractFixer implements Whitespa
break;
}
/** @var Token $backwardToken */
$backwardToken = $tokens[$backwardIndex];
if ($backwardToken->getContent() === '{') {
/** @var Token $nextToken */
$nextToken = $tokens[$backwardIndex + 1];
// Exclude string interpolation: "str {$var}"
if ($backwardToken->getContent() === '{' && !$nextToken->isGivenKind(T_VARIABLE)) {
break;
}

View File

@ -180,6 +180,20 @@ return $c;',
}
',
];
yield [
'<?php
if ($condition) {
$a = "Interpolation {$var}.";
return true;
}',
];
yield [
'<?php
if ($condition) {
$a = "Deprecated interpolation ${var}.";
return true;
}',
];
}
/**