Updated Rector to commit cd0881eb628353d14f1cd344a9fed48c2e13f0bf

cd0881eb62 [CodeQuality] Skip direct InlineHTML on CompleteMissingIfElseBracketRector (#5125)
This commit is contained in:
Tomas Votruba 2023-10-06 02:33:05 +00:00
parent 9144868d77
commit bcf39e1dff
2 changed files with 8 additions and 20 deletions

View File

@ -57,7 +57,7 @@ CODE_SAMPLE
return null;
}
$oldTokens = $this->file->getOldTokens();
if ($this->isIfConditionFollowedByOpeningCurlyBracket($node, $oldTokens)) {
if ($this->shouldSkip($node, $oldTokens)) {
return null;
}
// invoke reprint with brackets
@ -68,29 +68,17 @@ CODE_SAMPLE
* @param mixed[] $oldTokens
* @param \PhpParser\Node\Stmt\If_|\PhpParser\Node\Stmt\ElseIf_|\PhpParser\Node\Stmt\Else_ $if
*/
private function isIfConditionFollowedByOpeningCurlyBracket($if, array $oldTokens) : bool
private function shouldSkip($if, array $oldTokens) : bool
{
for ($i = $if->getStartTokenPos(); $i < $if->getEndTokenPos(); ++$i) {
if ($oldTokens[$i] !== ')') {
if ($oldTokens[$i] === ';') {
// all good
return \true;
}
continue;
}
// 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($nextToken, ['{', ':'], \true)) {
if ($oldTokens[$i] === ';') {
// all good
return \true;
}
}
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 = '96a1476e3e88b749a08408a9b827ce84f35bc237';
public const PACKAGE_VERSION = 'cd0881eb628353d14f1cd344a9fed48c2e13f0bf';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-10-06 06:20:17';
public const RELEASE_DATE = '2023-10-06 09:30:19';
/**
* @var int
*/