mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 8d524d4c3b4a8b506d558eec23caf1923e59bb81
8d524d4c3b
[PostRector] Skip remove unused imports on used in multiple docs in single node (#5604)
This commit is contained in:
parent
12e1b38e32
commit
de79e08a92
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'df8d2b78edd46542e6426fec606c3ea98d712532';
|
||||
public const PACKAGE_VERSION = '8d524d4c3b4a8b506d558eec23caf1923e59bb81';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-02-11 15:57:49';
|
||||
public const RELEASE_DATE = '2024-02-12 15:43:59';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -4,6 +4,8 @@ declare (strict_types=1);
|
||||
namespace Rector\PostRector\Rector;
|
||||
|
||||
use RectorPrefix202402\Nette\Utils\Strings;
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
@ -101,15 +103,29 @@ final class UnusedImportRemovingPostRector extends \Rector\PostRector\Rector\Abs
|
||||
{
|
||||
$names = [];
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($namespace, function (Node $node) use(&$names) {
|
||||
if (!$node->hasAttribute(AttributeKey::COMMENTS)) {
|
||||
$comments = $node->getComments();
|
||||
if ($comments === []) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$names = \array_merge($names, $phpDocInfo->getAnnotationClassNames());
|
||||
$constFetchNodeNames = $phpDocInfo->getConstFetchNodeClassNames();
|
||||
$names = \array_merge($names, $constFetchNodeNames);
|
||||
$genericTagClassNames = $phpDocInfo->getGenericTagClassNames();
|
||||
$names = \array_merge($names, $genericTagClassNames);
|
||||
$docs = \array_filter($comments, static function (Comment $comment) : bool {
|
||||
return $comment instanceof Doc;
|
||||
});
|
||||
if ($docs === []) {
|
||||
return null;
|
||||
}
|
||||
$totalDocs = \count($docs);
|
||||
foreach ($docs as $doc) {
|
||||
$nodeToCheck = $totalDocs === 1 ? $node : clone $node;
|
||||
if ($totalDocs > 1) {
|
||||
$nodeToCheck->setDocComment($doc);
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($nodeToCheck);
|
||||
$names = \array_merge($names, $phpDocInfo->getAnnotationClassNames());
|
||||
$constFetchNodeNames = $phpDocInfo->getConstFetchNodeClassNames();
|
||||
$names = \array_merge($names, $constFetchNodeNames);
|
||||
$genericTagClassNames = $phpDocInfo->getGenericTagClassNames();
|
||||
$names = \array_merge($names, $genericTagClassNames);
|
||||
}
|
||||
});
|
||||
return $names;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user