function PhpDumper::exportParameters
Throws
1 call to PhpDumper::exportParameters()
- PhpDumper::addDefaultParametersMethod in vendor/
symfony/ dependency-injection/ Dumper/ PhpDumper.php
File
-
vendor/
symfony/ dependency-injection/ Dumper/ PhpDumper.php, line 1728
Class
- PhpDumper
- PhpDumper dumps a service container as a PHP class.
Namespace
Symfony\Component\DependencyInjection\DumperCode
private function exportParameters(array $parameters, string $path = '', int $indent = 12, bool &$hasEnum = false) : string {
$php = [];
foreach ($parameters as $key => $value) {
if (\is_array($value)) {
$value = $this->exportParameters($value, $path . '/' . $key, $indent + 4, $hasEnum);
}
elseif ($value instanceof ArgumentInterface) {
throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain special arguments. "%s" found in "%s".', get_debug_type($value), $path . '/' . $key));
}
elseif ($value instanceof Variable) {
throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path . '/' . $key));
}
elseif ($value instanceof Definition) {
throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->getClass(), $path . '/' . $key));
}
elseif ($value instanceof Reference) {
throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path . '/' . $key));
}
elseif ($value instanceof Expression) {
throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path . '/' . $key));
}
elseif ($value instanceof \UnitEnum) {
$hasEnum = true;
$value = \sprintf('\\%s::%s', $value::class, $value->name);
}
else {
$value = $this->export($value);
}
$php[] = \sprintf('%s%s => %s,', str_repeat(' ', $indent), $this->export($key), $value);
}
return \sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', $indent - 4));
}