mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
30 lines
678 B
PHP
30 lines
678 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Rector\Dispatcher;
|
|
|
|
use PhpParser\Node;
|
|
use Rector\Contract\Dispatcher\ReconstructorInterface;
|
|
|
|
final class NodeDispatcher
|
|
{
|
|
/**
|
|
* @var ReconstructorInterface[]
|
|
*/
|
|
private $reconstructors;
|
|
|
|
public function addReconstructor(ReconstructorInterface $reconstructor): void
|
|
{
|
|
$this->reconstructors[] = $reconstructor;
|
|
}
|
|
|
|
public function dispatch(Node $node): void
|
|
{
|
|
// todo: build hash map
|
|
foreach ($this->reconstructors as $reconstructor) {
|
|
if ($reconstructor->isCandidate($node)) {
|
|
$reconstructor->reconstruct($node);
|
|
}
|
|
}
|
|
}
|
|
}
|