mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
26bacab80c
c0070b1d30
[CodeQuality] Skip not ArrayType on ForeachItemsAssignToEmptyArrayToAssignRector (#2752)
36 lines
972 B
PHP
36 lines
972 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Comments;
|
|
|
|
use PhpParser\Node;
|
|
use Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser;
|
|
/**
|
|
* @see \Rector\Tests\Comments\CommentRemover\CommentRemoverTest
|
|
*/
|
|
final class CommentRemover
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser
|
|
*/
|
|
private $commentRemovingNodeTraverser;
|
|
public function __construct(CommentRemovingNodeTraverser $commentRemovingNodeTraverser)
|
|
{
|
|
$this->commentRemovingNodeTraverser = $commentRemovingNodeTraverser;
|
|
}
|
|
/**
|
|
* @param mixed[]|\PhpParser\Node|null $node
|
|
* @return Node[]|null
|
|
*/
|
|
public function removeFromNode($node) : ?array
|
|
{
|
|
if ($node === null) {
|
|
return null;
|
|
}
|
|
$copiedNodes = $node;
|
|
$nodes = \is_array($copiedNodes) ? $copiedNodes : [$copiedNodes];
|
|
return $this->commentRemovingNodeTraverser->traverse($nodes);
|
|
}
|
|
}
|