File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
library/Icingadb/Command/Object Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 5
5
namespace Icinga \Module \Icingadb \Command \Object ;
6
6
7
7
use ArrayIterator ;
8
+ use Generator ;
8
9
use Icinga \Module \Icingadb \Command \IcingaCommand ;
10
+ use InvalidArgumentException ;
9
11
use ipl \Orm \Model ;
12
+ use LogicException ;
10
13
use Traversable ;
11
14
12
15
/**
@@ -24,12 +27,18 @@ abstract class ObjectsCommand extends IcingaCommand
24
27
/**
25
28
* Set the involved objects
26
29
*
27
- * @param Traversable<Model> $objects
30
+ * @param Traversable<Model> $objects Except generators
28
31
*
29
32
* @return $this
33
+ *
34
+ * @throws InvalidArgumentException If a generator is passed
30
35
*/
31
36
public function setObjects (Traversable $ objects ): self
32
37
{
38
+ if ($ objects instanceof Generator) {
39
+ throw new InvalidArgumentException ('Generators are not supported ' );
40
+ }
41
+
33
42
$ this ->objects = $ objects ;
34
43
35
44
return $ this ;
@@ -57,7 +66,7 @@ public function setObject(Model $object): self
57
66
public function getObjects (): Traversable
58
67
{
59
68
if ($ this ->objects === null ) {
60
- throw new \ LogicException (
69
+ throw new LogicException (
61
70
'You are accessing an unset property. Please make sure to set it beforehand. '
62
71
);
63
72
}
You can’t perform that action at this time.
0 commit comments