From 7e1aee8d3358ba7ddd077e7ae5729d444c7e35b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 24 Feb 2023 16:00:57 +0100 Subject: [PATCH] Enhancement: Use variadics --- CHANGELOG.md | 5 +++++ psalm-baseline.xml | 3 --- src/Builder/NodeBuilder.php | 4 ++-- src/Builder/NodeBuilderInterface.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cba8e6e..9bcd770 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), For a full diff see [`0.7.0...master`][0.7.0...master]. +### Changed + +- Made use of variadic parameters in `NodeBuilderInterface::leafs()` and `NodeBuilder::leafs()` ([#168]), by [@localheinz] + ## [`0.7.0`][0.7.0] For a full diff see [0.6.0...0.7.0`][0.6.0...0.7.0]. @@ -239,6 +243,7 @@ For a full diff see [`fcfd14e...v0.1.1`][fcfd14e...0.1.1]. [#152]: https://github.com/nicmart/Tree/pull/152 [#153]: https://github.com/nicmart/Tree/pull/153 [#154]: https://github.com/nicmart/Tree/pull/154 +[#168]: https://github.com/nicmart/Tree/pull/168 [@asalazar-pley]: https://github.com/asalazar-pley [@Djuki]: https://github.com/Djuki diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 0402db4..93efa93 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -4,9 +4,6 @@ $value - - $value1 - diff --git a/src/Builder/NodeBuilder.php b/src/Builder/NodeBuilder.php index e4ae012..a7cb6ff 100644 --- a/src/Builder/NodeBuilder.php +++ b/src/Builder/NodeBuilder.php @@ -52,9 +52,9 @@ public function leaf(mixed $value = null): static return $this; } - public function leafs(mixed $value1 /* , $value2, ... */): static + public function leafs(mixed ...$values): static { - foreach (\func_get_args() as $value) { + foreach ($values as $value) { $this->leaf($value); } diff --git a/src/Builder/NodeBuilderInterface.php b/src/Builder/NodeBuilderInterface.php index 76655c3..c474978 100644 --- a/src/Builder/NodeBuilderInterface.php +++ b/src/Builder/NodeBuilderInterface.php @@ -43,7 +43,7 @@ public function leaf(mixed $value = null): static; /** * Add several leafs to the node. */ - public function leafs(mixed $value /* , $value2, ... */): static; + public function leafs(mixed ...$values): static; /** * Add a child to the node enter in its scope.