4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Argument;
14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15 use Symfony\Component\DependencyInjection\Reference;
18 * Represents a collection of values to lazily iterate over.
20 * @author Titouan Galopin <galopintitouan@gmail.com>
22 class IteratorArgument implements ArgumentInterface
27 * @param Reference[] $values
29 public function __construct(array $values)
31 $this->setValues($values);
35 * @return array The values to lazily iterate over
37 public function getValues()
43 * @param Reference[] $values The service references to lazily iterate over
45 public function setValues(array $values)
47 foreach ($values as $k => $v) {
48 if (null !== $v && !$v instanceof Reference) {
49 throw new InvalidArgumentException(sprintf('An IteratorArgument must hold only Reference instances, "%s" given.', \is_object($v) ? \get_class($v) : \gettype($v)));
53 $this->values = $values;