mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
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:
parent
c61f66d973
commit
672622950f
@ -37,14 +37,18 @@ final class ObjectSet implements \IteratorAggregate{
|
|||||||
*/
|
*/
|
||||||
private array $objects = [];
|
private array $objects = [];
|
||||||
|
|
||||||
/** @phpstan-param T $object */
|
/** @phpstan-param T ...$objects */
|
||||||
public function add(object $object) : void{
|
public function add(object ...$objects) : void{
|
||||||
$this->objects[spl_object_id($object)] = $object;
|
foreach($objects as $object){
|
||||||
|
$this->objects[spl_object_id($object)] = $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-param T $object */
|
/** @phpstan-param T ...$objects */
|
||||||
public function remove(object $object) : void{
|
public function remove(object ...$objects) : void{
|
||||||
unset($this->objects[spl_object_id($object)]);
|
foreach($objects as $object){
|
||||||
|
unset($this->objects[spl_object_id($object)]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear() : void{
|
public function clear() : void{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user