Updated Rector to commit 12184ca4ab6f82eae141058284fdd6b44a496c64

12184ca4ab Revert "[CodeQuality] Only check start from current Stmt token pos up until open parentheses on CompleteMissingIfElseBracketRector (#5127)" (#5128)
This commit is contained in:
Tomas Votruba 2023-10-06 06:22:34 +00:00
parent 4d1e798d62
commit b68f693036
2 changed files with 19 additions and 17 deletions

View File

@ -70,27 +70,29 @@ CODE_SAMPLE
*/
private function isIfConditionFollowedByOpeningCurlyBracket($if, array $oldTokens) : bool
{
$startStmt = \current($if->stmts);
if ($startStmt === \false) {
return \true;
}
$startTokenPos = $startStmt->getStartTokenPos();
$i = $startTokenPos - 1;
$ifStartTokenPos = $if->getStartTokenPos();
while (isset($oldTokens[$i])) {
if ($i === $ifStartTokenPos) {
return \false;
for ($i = $if->getStartTokenPos(); $i < $if->getEndTokenPos(); ++$i) {
if ($oldTokens[$i] !== ')') {
if ($oldTokens[$i] === ';') {
// all good
return \true;
}
continue;
}
if ($oldTokens[$i] === ')') {
break;
// first closing bracket must be followed by curly opening brackets
// what is next token?
$nextToken = $oldTokens[$i + 1];
if (\is_array($nextToken) && \trim((string) $nextToken[1]) === '') {
// next token is whitespace
$nextToken = $oldTokens[$i + 2];
}
if (\in_array($oldTokens[$i], [':', '{'], \true)) {
if (\in_array($nextToken, ['{', ':'], \true)) {
// all good
return \true;
}
--$i;
}
return \false;
$startStmt = \current($if->stmts);
$lastStmt = \end($if->stmts);
return $startStmt === \false || $lastStmt === \false;
}
/**
* @param \PhpParser\Node\Stmt\If_|\PhpParser\Node\Stmt\ElseIf_|\PhpParser\Node\Stmt\Else_ $if

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'af065e78332e3654a4591cd317fc51acea6155d9';
public const PACKAGE_VERSION = '12184ca4ab6f82eae141058284fdd6b44a496c64';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-10-06 13:11:25';
public const RELEASE_DATE = '2023-10-06 06:19:51';
/**
* @var int
*/