From 672622950f861fd7d989208a34469f8dbdeaece1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 11 Feb 2021 15:54:05 +0000 Subject: [PATCH] ObjectSet: make add() and remove() variadic to match ds there are still some variadic usages in the code, which, infuriatingly, phpstan does not detect (phpstan/phpstan#4528). --- src/utils/ObjectSet.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/ObjectSet.php b/src/utils/ObjectSet.php index adb0ad1c27..0b6b0049d6 100644 --- a/src/utils/ObjectSet.php +++ b/src/utils/ObjectSet.php @@ -37,14 +37,18 @@ final class ObjectSet implements \IteratorAggregate{ */ private array $objects = []; - /** @phpstan-param T $object */ - public function add(object $object) : void{ - $this->objects[spl_object_id($object)] = $object; + /** @phpstan-param T ...$objects */ + public function add(object ...$objects) : void{ + foreach($objects as $object){ + $this->objects[spl_object_id($object)] = $object; + } } - /** @phpstan-param T $object */ - public function remove(object $object) : void{ - unset($this->objects[spl_object_id($object)]); + /** @phpstan-param T ...$objects */ + public function remove(object ...$objects) : void{ + foreach($objects as $object){ + unset($this->objects[spl_object_id($object)]); + } } public function clear() : void{