Skip to content

Commit 698e44f

Browse files
committed
ObjectsCommand: Don't accept generators anymore
1 parent 3a07ce5 commit 698e44f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

library/Icingadb/Command/Object/ObjectsCommand.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
namespace Icinga\Module\Icingadb\Command\Object;
66

77
use ArrayIterator;
8+
use Generator;
89
use Icinga\Module\Icingadb\Command\IcingaCommand;
10+
use InvalidArgumentException;
911
use ipl\Orm\Model;
12+
use LogicException;
1013
use Traversable;
1114

1215
/**
@@ -24,12 +27,18 @@ abstract class ObjectsCommand extends IcingaCommand
2427
/**
2528
* Set the involved objects
2629
*
27-
* @param Traversable<Model> $objects
30+
* @param Traversable<Model> $objects Except generators
2831
*
2932
* @return $this
33+
*
34+
* @throws InvalidArgumentException If a generator is passed
3035
*/
3136
public function setObjects(Traversable $objects): self
3237
{
38+
if ($objects instanceof Generator) {
39+
throw new InvalidArgumentException('Generators are not supported');
40+
}
41+
3342
$this->objects = $objects;
3443

3544
return $this;
@@ -57,7 +66,7 @@ public function setObject(Model $object): self
5766
public function getObjects(): Traversable
5867
{
5968
if ($this->objects === null) {
60-
throw new \LogicException(
69+
throw new LogicException(
6170
'You are accessing an unset property. Please make sure to set it beforehand.'
6271
);
6372
}

0 commit comments

Comments
 (0)