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).
This commit is contained in:
Dylan K. Taylor 2021-02-11 15:54:05 +00:00
parent c61f66d973
commit 672622950f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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{