Skip to content
Snippets Groups Projects
Commit 8fd571fc authored by Klaus Purer's avatar Klaus Purer
Browse files

fix(UnusedUseStatementSniff): Improve fixer for @var in function bodies

parent e7186a62
No related branches found
No related tags found
No related merge requests found
......@@ -178,9 +178,10 @@ class Drupal_Sniffs_Classes_UnusedUseStatementSniff implements PHP_CodeSniffer_S
&& $tokens[($tag + 1)]['code'] === T_DOC_COMMENT_WHITESPACE
&& isset($tokens[($tag + 2)]) === true
&& $tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING
&& $tokens[($tag + 2)]['content'] === $tokens[$classPtr]['content']
&& strpos($tokens[($tag + 2)]['content'], $tokens[$classPtr]['content']) === 0
) {
$phpcsFile->fixer->replaceToken(($tag + 2), '\\'.$fullNamespace);
$replacement = '\\'.$fullNamespace.substr($tokens[($tag + 2)]['content'], strlen($tokens[$classPtr]['content']));
$phpcsFile->fixer->replaceToken(($tag + 2), $replacement);
}
$tag = $phpcsFile->findNext(T_DOC_COMMENT_TAG, ($tag + 1));
......
......@@ -75,4 +75,15 @@ class Pum {
}
/**
* Inline var declarations should also get fixed to the full namespace.
*/
protected function test6($x) {
/** @var VarName $y */
$y = $x['test'];
/** @var AliasVarName2 $z */
$z = $x['test2'];
return $y;
}
}
......@@ -65,4 +65,15 @@ class Pum {
}
/**
* Inline var declarations should also get fixed to the full namespace.
*/
protected function test6($x) {
/** @var \Some\Data\VarName $y */
$y = $x['test'];
/** @var \Some\Data\VarName2 $z */
$z = $x['test2'];
return $y;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment