Updated Rector to commit af065e78332e3654a4591cd317fc51acea6155d9

af065e7833 [CodeQuality] Only check start from current Stmt token pos up until open parentheses on CompleteMissingIfElseBracketRector (#5127)
This commit is contained in:
Tomas Votruba 2023-10-06 06:14:15 +00:00
parent b14cc5b488
commit 4d1e798d62
2 changed files with 17 additions and 19 deletions

View File

@ -70,29 +70,27 @@ CODE_SAMPLE
*/
private function isIfConditionFollowedByOpeningCurlyBracket($if, array $oldTokens) : bool
{
for ($i = $if->getStartTokenPos(); $i < $if->getEndTokenPos(); ++$i) {
if ($oldTokens[$i] !== ')') {
if ($oldTokens[$i] === ';') {
// all good
return \true;
}
continue;
$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;
}
// 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 ($oldTokens[$i] === ')') {
break;
}
if (\in_array($nextToken, ['{', ':'], \true)) {
if (\in_array($oldTokens[$i], [':', '{'], \true)) {
// all good
return \true;
}
--$i;
}
$startStmt = \current($if->stmts);
$lastStmt = \end($if->stmts);
return $startStmt === \false || $lastStmt === \false;
return \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 = 'bb7d02879296e7d43f2718b1de8298380a20243b';
public const PACKAGE_VERSION = 'af065e78332e3654a4591cd317fc51acea6155d9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-10-06 09:51:24';
public const RELEASE_DATE = '2023-10-06 13:11:25';
/**
* @var int
*/