Skip to content

Commit

Permalink
stan
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Aug 8, 2023
1 parent 1295ac8 commit d47c590
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/LaravelPhpdocAlignmentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<tag>@param)\s+(?P<hint>(?:' . TypeExpression::REGEX_TYPES . ')?)\s+(?P<var>(?:&|\.{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]);

Check failure on line 54 in tests/LaravelPhpdocAlignmentFixer.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.0 with Laravel ^9 and highest dependencies

Parameter #1 $token of class PhpCsFixer\Tokenizer\Token constructor expects array{int, string}|string, array{389, string|null} given.

Check failure on line 54 in tests/LaravelPhpdocAlignmentFixer.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.1 with Laravel ^9 and highest dependencies

Parameter #1 $token of class PhpCsFixer\Tokenizer\Token constructor expects array{int, string}|string, array{388, string|null} given.

Check failure on line 54 in tests/LaravelPhpdocAlignmentFixer.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.1 with Laravel ^10 and highest dependencies

Parameter #1 $token of class PhpCsFixer\Tokenizer\Token constructor expects array{int, string}|string, array{388, string|null} given.

Check failure on line 54 in tests/LaravelPhpdocAlignmentFixer.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.2 with Laravel ^9 and highest dependencies

Parameter #1 $token of class PhpCsFixer\Tokenizer\Token constructor expects array{int, string}|string, array{388, string|null} given.

Check failure on line 54 in tests/LaravelPhpdocAlignmentFixer.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.2 with Laravel ^10 and highest dependencies

Parameter #1 $token of class PhpCsFixer\Tokenizer\Token constructor expects array{int, string}|string, array{388, string|null} given.
}
}

Expand Down

0 comments on commit d47c590

Please sign in to comment.