From 9b91d7b2f8094c075b84fcb718fff55dc5f4dc61 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:36:48 +0700 Subject: [PATCH] feat(`Context`): `with()` not accepts multiple argument. --- CHANGELOG.md | 1 + src/Context/Context.php | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c71df9c..d602d46b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * feat: Supports dynamic properties (including `stdClass`) on the target side. * fix(`Mapper`): Fix typehint. * test: test array cast to object mapping +* feat(`Context`): `with()` not accepts multiple argument. ## 1.0.0 diff --git a/src/Context/Context.php b/src/Context/Context.php index 58a859ac..c16ad4f3 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -56,11 +56,14 @@ private static function createFrom(array $context): self return new self($context); } - public function with(object $value): self + public function with(object ...$value): self { - $class = get_class($value); $context = $this->context; - $context[$class] = $value; + + foreach ($value as $object) { + $class = get_class($object); + $context[$class] = $object; + } return self::createFrom($context); }