ArgumentTrait.php 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Loader\Configurator\Traits;
  11. trait ArgumentTrait
  12. {
  13. /**
  14. * Sets the arguments to pass to the service constructor/factory method.
  15. *
  16. * @return $this
  17. */
  18. final public function args(array $arguments): self
  19. {
  20. $this->definition->setArguments(static::processValue($arguments, true));
  21. return $this;
  22. }
  23. /**
  24. * Sets one argument to pass to the service constructor/factory method.
  25. *
  26. * @param string|int $key
  27. * @param mixed $value
  28. *
  29. * @return $this
  30. */
  31. final public function arg($key, $value): self
  32. {
  33. $this->definition->setArgument($key, static::processValue($value, true));
  34. return $this;
  35. }
  36. }