Skip to content

Commit

Permalink
minor #5516 DX: AbstractDoctrineAnnotationFixer - no need for import …
Browse files Browse the repository at this point in the history
…aliases (keradus)

This PR was squashed before being merged into the 2.18 branch.

Discussion
----------

DX: AbstractDoctrineAnnotationFixer - no need for import aliases

Commits
-------

401dab1 DX: AbstractDoctrineAnnotationFixer - no need for import aliases
  • Loading branch information
keradus committed Mar 1, 2021
2 parents 4463550 + 401dab1 commit c244b07
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/AbstractDoctrineAnnotationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
use PhpCsFixer\Tokenizer\CT;
use PhpCsFixer\Tokenizer\Token as PhpToken;
use PhpCsFixer\Tokenizer\Tokens as PhpTokens;
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixer\Tokenizer\TokensAnalyzer;

/**
Expand All @@ -34,32 +34,32 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
/**
* {@inheritdoc}
*/
public function isCandidate(PhpTokens $tokens)
public function isCandidate(Tokens $tokens)
{
return $tokens->isTokenKindFound(T_DOC_COMMENT);
}

/**
* {@inheritdoc}
*/
protected function applyFix(\SplFileInfo $file, PhpTokens $phpTokens)
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
{
// fetch indexes one time, this is safe as we never add or remove a token during fixing
$analyzer = new TokensAnalyzer($phpTokens);
$analyzer = new TokensAnalyzer($tokens);
$this->classyElements = $analyzer->getClassyElements();

/** @var PhpToken $docCommentToken */
foreach ($phpTokens->findGivenKind(T_DOC_COMMENT) as $index => $docCommentToken) {
if (!$this->nextElementAcceptsDoctrineAnnotations($phpTokens, $index)) {
/** @var Token $docCommentToken */
foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $index => $docCommentToken) {
if (!$this->nextElementAcceptsDoctrineAnnotations($tokens, $index)) {
continue;
}

$tokens = DoctrineAnnotationTokens::createFromDocComment(
$doctrineAnnotationTokens = DoctrineAnnotationTokens::createFromDocComment(
$docCommentToken,
$this->configuration['ignored_tags']
);
$this->fixAnnotations($tokens);
$phpTokens[$index] = new PhpToken([T_DOC_COMMENT, $tokens->getCode()]);
$this->fixAnnotations($doctrineAnnotationTokens);
$tokens[$index] = new Token([T_DOC_COMMENT, $doctrineAnnotationTokens->getCode()]);
}
}

Expand Down Expand Up @@ -199,7 +199,7 @@ protected function createConfigurationDefinition()
*
* @return bool
*/
private function nextElementAcceptsDoctrineAnnotations(PhpTokens $tokens, $index)
private function nextElementAcceptsDoctrineAnnotations(Tokens $tokens, $index)
{
do {
$index = $tokens->getNextMeaningfulToken($index);
Expand Down

0 comments on commit c244b07

Please sign in to comment.