diff --git a/tests/LaravelPhpdocAlignmentFixer.php b/tests/LaravelPhpdocAlignmentFixer.php index 58b94491fc..85a85ebeb5 100644 --- a/tests/LaravelPhpdocAlignmentFixer.php +++ b/tests/LaravelPhpdocAlignmentFixer.php @@ -34,21 +34,24 @@ public function isRisky(): bool public function fix(\SplFileInfo $file, Tokens $tokens): void { for ($index = $tokens->count() - 1; $index > 0; --$index) { - if (! $tokens[$index]->isGivenKind([\T_DOC_COMMENT])) { + $token = $tokens[$index]; + assert($token instanceof Token); + + if (! $token->isGivenKind([\T_DOC_COMMENT])) { continue; } $newContent = preg_replace_callback( '/(?P@param)\s+(?P(?:' . TypeExpression::REGEX_TYPES . ')?)\s+(?P(?:&|\.{3})?\$\S+)/ux', fn ($matches) => $matches['tag'] . ' ' . $matches['hint'] . ' ' . $matches['var'], - $tokens[$index]->getContent(), + $token->getContent(), ); - if ($newContent == $tokens[$index]->getContent()) { + if ($newContent == $token->getContent()) { continue; } - $tokens[$index] = new Token([T_DOC_COMMENT, $newContent]); + $token = new Token([T_DOC_COMMENT, $newContent]); } }