diff --git a/src/Library/Container.php b/src/Library/Container.php index 085b1f40..b16df7b2 100644 --- a/src/Library/Container.php +++ b/src/Library/Container.php @@ -46,7 +46,6 @@ use CuyZ\Valinor\Mapper\Tree\Builder\StrictNodeBuilder; use CuyZ\Valinor\Mapper\Tree\Builder\UnionNodeBuilder; use CuyZ\Valinor\Mapper\Tree\Builder\ValueAlteringNodeBuilder; -use CuyZ\Valinor\Mapper\Tree\Builder\VisitorNodeBuilder; use CuyZ\Valinor\Mapper\Tree\Visitor\AttributeShellVisitor; use CuyZ\Valinor\Mapper\Tree\Visitor\ShellVisitor; use CuyZ\Valinor\Mapper\TreeMapper; @@ -125,7 +124,6 @@ public function __construct(Settings $settings) $builder = new CasterProxyNodeBuilder($builder); $builder = new IterableNodeBuilder($builder); - $builder = new VisitorNodeBuilder($builder, $settings->nodeVisitors); $builder = new ValueAlteringNodeBuilder( $builder, new FunctionsContainer( diff --git a/src/Library/Settings.php b/src/Library/Settings.php index cf165bbb..7f29dfc4 100644 --- a/src/Library/Settings.php +++ b/src/Library/Settings.php @@ -5,7 +5,6 @@ namespace CuyZ\Valinor\Library; use CuyZ\Valinor\Mapper\Tree\Message\ErrorMessage; -use CuyZ\Valinor\Mapper\Tree\Node; use DateTimeImmutable; use DateTimeInterface; use Psr\SimpleCache\CacheInterface; @@ -26,9 +25,6 @@ final class Settings /** @var list */ public array $valueModifier = []; - /** @var array */ - public array $nodeVisitors = []; - /** @var CacheInterface */ public CacheInterface $cache; diff --git a/src/Mapper/Tree/Builder/VisitorNodeBuilder.php b/src/Mapper/Tree/Builder/VisitorNodeBuilder.php deleted file mode 100644 index 3ee1df23..00000000 --- a/src/Mapper/Tree/Builder/VisitorNodeBuilder.php +++ /dev/null @@ -1,37 +0,0 @@ - */ - private array $callbacks; - - /** - * @param array $callbacks - */ - public function __construct(NodeBuilder $delegate, array $callbacks) - { - $this->delegate = $delegate; - $this->callbacks = $callbacks; - } - - public function build(Shell $shell, RootNodeBuilder $rootBuilder): Node - { - $node = $this->delegate->build($shell, $rootBuilder); - - foreach ($this->callbacks as $callback) { - $callback($node); - } - - return $node; - } -} diff --git a/src/MapperBuilder.php b/src/MapperBuilder.php index d9eb8a95..2b3474da 100644 --- a/src/MapperBuilder.php +++ b/src/MapperBuilder.php @@ -8,7 +8,6 @@ use CuyZ\Valinor\Library\Container; use CuyZ\Valinor\Library\Settings; use CuyZ\Valinor\Mapper\Tree\Message\ErrorMessage; -use CuyZ\Valinor\Mapper\Tree\Node; use CuyZ\Valinor\Mapper\TreeMapper; use Psr\SimpleCache\CacheInterface; use Throwable; @@ -225,16 +224,6 @@ public function alter(callable $callback): self return $clone; } - /** - * @param callable(Node): void $callback - */ - public function visit(callable $callback): self - { - $this->settings->nodeVisitors[] = $callback; - - return $this; - } - /** * Enables flexible mode for the mapper: * diff --git a/tests/Integration/Mapping/VisitorMappingTest.php b/tests/Integration/Mapping/VisitorMappingTest.php deleted file mode 100644 index d1cbadfd..00000000 --- a/tests/Integration/Mapping/VisitorMappingTest.php +++ /dev/null @@ -1,44 +0,0 @@ -visit(function (Node $node) use (&$visits): void { - if ($node->isRoot()) { - $visits[] = '#1'; - } - }) - ->visit(function (Node $node) use (&$visits): void { - if ($node->isRoot()) { - $visits[] = '#2'; - } - }) - ->visit(function () use ($error): void { - throw $error; - }) - ->mapper() - ->map(SimpleObject::class, ['value' => 'foo']); - } catch (MappingError $exception) { - self::assertSame('some error message', (string)$exception->node()->messages()[0]); - } - - self::assertSame(['#1', '#2'], $visits); - } -}