Skip to content

Commit

Permalink
ObjectsCommand: Don't accept generators anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Mar 26, 2024
1 parent 3a07ce5 commit 698e44f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions library/Icingadb/Command/Object/ObjectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
namespace Icinga\Module\Icingadb\Command\Object;

use ArrayIterator;
use Generator;
use Icinga\Module\Icingadb\Command\IcingaCommand;
use InvalidArgumentException;
use ipl\Orm\Model;
use LogicException;
use Traversable;

/**
Expand All @@ -24,12 +27,18 @@ abstract class ObjectsCommand extends IcingaCommand
/**
* Set the involved objects
*
* @param Traversable<Model> $objects
* @param Traversable<Model> $objects Except generators
*
* @return $this
*
* @throws InvalidArgumentException If a generator is passed
*/
public function setObjects(Traversable $objects): self
{
if ($objects instanceof Generator) {
throw new InvalidArgumentException('Generators are not supported');
}

$this->objects = $objects;

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

0 comments on commit 698e44f

Please sign in to comment.