code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
private function processValue(mixed $value, int $rootLevel = 0, int $level = 0) : mixed { if ($value instanceof ServiceClosureArgument) { $value->setValues($this->processValue($value->getValues(), 1, 1)); } elseif ($value instanceof ArgumentInterface) { $value->setValues($this->processValue($value->getValues(), $rootLevel, 1 + $level)); } elseif ($value instanceof Definition) { if ($value->isSynthetic() || $value->isAbstract()) { return $value; } $value->setArguments($this->processValue($value->getArguments(), 0)); $value->setProperties($this->processValue($value->getProperties(), 1)); $value->setMethodCalls($this->processValue($value->getMethodCalls(), 2)); } elseif (\is_array($value)) { $i = 0; foreach ($value as $k => $v) { try { if (\false !== $i && $k !== $i++) { $i = \false; } if ($v !== ($processedValue = $this->processValue($v, $rootLevel, 1 + $level))) { $value[$k] = $processedValue; } } catch (RuntimeException $e) { if ($rootLevel < $level || $rootLevel && !$level) { unset($value[$k]); } elseif ($rootLevel) { throw $e; } else { $value[$k] = null; } } } // Ensure numerically indexed arguments have sequential numeric keys. if (\false !== $i) { $value = \array_values($value); } } elseif ($value instanceof Reference) { if ($this->container->hasDefinition($id = (string) $value) ? !$this->container->getDefinition($id)->hasTag('container.excluded') : $this->container->hasAlias($id)) { return $value; } $currentDefinition = $this->container->getDefinition($this->currentId); // resolve decorated service behavior depending on decorator service if ($currentDefinition->innerServiceId === $id && ContainerInterface::NULL_ON_INVALID_REFERENCE === $currentDefinition->decorationOnInvalid) { return null; } $invalidBehavior = $value->getInvalidBehavior(); if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior && $value instanceof TypedReference && !$this->container->has($id)) { $e = new ServiceNotFoundException($id, $this->currentId); // since the error message varies by $id and $this->currentId, so should the id of the dummy errored definition $this->container->register($id = \sprintf('.errored.%s.%s', $this->currentId, $id), $value->getType())->addError($e->getMessage()); return new TypedReference($id, $value->getType(), $value->getInvalidBehavior()); } // resolve invalid behavior if (ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { $value = null; } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { if (0 < $level || $rootLevel) { throw $this->signalingException; } $value = null; } } return $value; }
Processes arguments to determine invalid references. @throws RuntimeException When an invalid reference is found
processValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php
MIT
public function getNode(string $id) : ServiceReferenceGraphNode { if (!isset($this->nodes[$id])) { throw new InvalidArgumentException(\sprintf('There is no node with id "%s".', $id)); } return $this->nodes[$id]; }
Gets a node by identifier. @throws InvalidArgumentException if no node matches the supplied identifier
getNode
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php
MIT
public function connect(?string $sourceId, mixed $sourceValue, ?string $destId, mixed $destValue = null, ?Reference $reference = null, bool $lazy = \false, bool $weak = \false, bool $byConstructor = \false) : void { if (null === $sourceId || null === $destId) { return; } $sourceNode = $this->createNode($sourceId, $sourceValue); $destNode = $this->createNode($destId, $destValue); $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak, $byConstructor); $sourceNode->addOutEdge($edge); $destNode->addInEdge($edge); }
Connects 2 nodes together in the Graph.
connect
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php
MIT
public function getValue() : mixed { return $this->value; }
Returns the value of the edge.
getValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
MIT
public function isLazy() : bool { return $this->lazy; }
Returns true if the edge is lazy, meaning it's a dependency not requiring direct instantiation.
isLazy
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
MIT
public function isWeak() : bool { return $this->weak; }
Returns true if the edge is weak, meaning it shouldn't prevent removing the target service.
isWeak
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
MIT
public function isReferencedByConstructor() : bool { return $this->byConstructor; }
Returns true if the edge links with a constructor argument.
isReferencedByConstructor
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php
MIT
public function isAlias() : bool { return $this->value instanceof Alias; }
Checks if the value of this node is an Alias.
isAlias
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
MIT
public function isDefinition() : bool { return $this->value instanceof Definition; }
Checks if the value of this node is a Definition.
isDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
MIT
public function getInEdges() : array { return $this->inEdges; }
Returns the in edges. @return ServiceReferenceGraphEdge[]
getInEdges
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
MIT
public function getOutEdges() : array { return $this->outEdges; }
Returns the out edges. @return ServiceReferenceGraphEdge[]
getOutEdges
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
MIT
public function getValue() : mixed { return $this->value; }
Returns the value of this Node.
getValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php
MIT
public function __construct(array $parameters) { $this->parameters = $parameters; }
@param array $parameters The container parameters to track
__construct
php
deptrac/deptrac
vendor/symfony/dependency-injection/Config/ContainerParametersResource.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Config/ContainerParametersResource.php
MIT
public function dump(array $options = []) : string { foreach (['graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing'] as $key) { if (isset($options[$key])) { $this->options[$key] = \array_merge($this->options[$key], $options[$key]); } } $this->nodes = $this->findNodes(); $this->edges = []; foreach ($this->container->getDefinitions() as $id => $definition) { $this->edges[$id] = \array_merge($this->findEdges($id, $definition->getArguments(), \true, ''), $this->findEdges($id, $definition->getProperties(), \false, '')); foreach ($definition->getMethodCalls() as $call) { $this->edges[$id] = \array_merge($this->edges[$id], $this->findEdges($id, $call[1], \false, $call[0] . '()')); } } return $this->container->resolveEnvPlaceholders($this->startDot() . $this->addNodes() . $this->addEdges() . $this->endDot(), '__ENV_%s__'); }
Dumps the service container as a graphviz graph. Available options: * graph: The default options for the whole graph * node: The default options for nodes * edge: The default options for edges * node.instance: The default options for services that are defined directly by object instances * node.definition: The default options for services that are defined via service definition instances * node.missing: The default options for missing services
dump
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php
MIT
private function findEdges(string $id, array $arguments, bool $required, string $name, bool $lazy = \false) : array { $edges = []; foreach ($arguments as $argument) { if ($argument instanceof Parameter) { $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; } elseif (\is_string($argument) && \preg_match('/^%([^%]+)%$/', $argument, $match)) { $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; } if ($argument instanceof Reference) { $lazyEdge = $lazy; if (!$this->container->has((string) $argument)) { $this->nodes[(string) $argument] = ['name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']]; } elseif ('service_container' !== (string) $argument) { $lazyEdge = $lazy || $this->container->getDefinition((string) $argument)->isLazy(); } $edges[] = [['name' => $name, 'required' => $required, 'to' => $argument, 'lazy' => $lazyEdge]]; } elseif ($argument instanceof ArgumentInterface) { $edges[] = $this->findEdges($id, $argument->getValues(), $required, $name, \true); } elseif ($argument instanceof Definition) { $edges[] = $this->findEdges($id, $argument->getArguments(), $required, ''); $edges[] = $this->findEdges($id, $argument->getProperties(), \false, ''); foreach ($argument->getMethodCalls() as $call) { $edges[] = $this->findEdges($id, $call[1], \false, $call[0] . '()'); } } elseif (\is_array($argument)) { $edges[] = $this->findEdges($id, $argument, $required, $name, $lazy); } } return \array_merge([], ...$edges); }
Finds all edges belonging to a specific service id.
findEdges
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php
MIT
public function setProxyDumper(DumperInterface $proxyDumper) { $this->proxyDumper = $proxyDumper; $this->hasProxyDumper = !$proxyDumper instanceof NullDumper; }
Sets the dumper to be used when dumping proxies in the generated container. @return void
setProxyDumper
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
public function dump(array $options = []) : string|array { $this->locatedIds = []; $this->targetDirRegex = null; $this->inlinedRequires = []; $this->exportedVariables = []; $this->dynamicParameters = []; $options = \array_merge([ 'class' => 'ProjectServiceContainer', 'base_class' => 'Container', 'namespace' => '', 'as_files' => \false, 'debug' => \true, 'hot_path_tag' => 'container.hot_path', 'preload_tags' => ['container.preload', 'container.no_preload'], 'inline_factories_parameter' => 'container.dumper.inline_factories', // @deprecated since Symfony 6.3 'inline_class_loader_parameter' => 'container.dumper.inline_class_loader', // @deprecated since Symfony 6.3 'inline_factories' => null, 'inline_class_loader' => null, 'preload_classes' => [], 'service_locator_tag' => 'container.service_locator', 'build_time' => \time(), ], $options); $this->addGetService = \false; $this->namespace = $options['namespace']; $this->asFiles = $options['as_files']; $this->hotPathTag = $options['hot_path_tag']; $this->preloadTags = $options['preload_tags']; $this->inlineFactories = \false; if (isset($options['inline_factories'])) { $this->inlineFactories = $this->asFiles && $options['inline_factories']; } elseif (!$options['inline_factories_parameter']) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/dependency-injection', '6.3', 'Option "inline_factories_parameter" passed to "%s()" is deprecated, use option "inline_factories" instead.', __METHOD__); } elseif ($this->container->hasParameter($options['inline_factories_parameter'])) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/dependency-injection', '6.3', 'Option "inline_factories_parameter" passed to "%s()" is deprecated, use option "inline_factories" instead.', __METHOD__); $this->inlineFactories = $this->asFiles && $this->container->getParameter($options['inline_factories_parameter']); } $this->inlineRequires = $options['debug']; if (isset($options['inline_class_loader'])) { $this->inlineRequires = $options['inline_class_loader']; } elseif (!$options['inline_class_loader_parameter']) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/dependency-injection', '6.3', 'Option "inline_class_loader_parameter" passed to "%s()" is deprecated, use option "inline_class_loader" instead.', __METHOD__); $this->inlineRequires = \false; } elseif ($this->container->hasParameter($options['inline_class_loader_parameter'])) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/dependency-injection', '6.3', 'Option "inline_class_loader_parameter" passed to "%s()" is deprecated, use option "inline_class_loader" instead.', __METHOD__); $this->inlineRequires = $this->container->getParameter($options['inline_class_loader_parameter']); } $this->serviceLocatorTag = $options['service_locator_tag']; $this->class = $options['class']; if (!\str_starts_with($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) { $baseClass = \sprintf('%s\\%s', $options['namespace'] ? '\\' . $options['namespace'] : '', $baseClass); $this->baseClass = $baseClass; } elseif ('Container' === $baseClass) { $this->baseClass = Container::class; } else { $this->baseClass = $baseClass; } $this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass); if (!$this->hasProxyDumper) { (new AnalyzeServiceReferencesPass(\true, \false))->process($this->container); (new CheckCircularReferencesPass())->process($this->container); } $this->analyzeReferences(); $this->docStar = $options['debug'] ? '*' : ''; if (!empty($options['file']) && \is_dir($dir = \dirname($options['file']))) { // Build a regexp where the first root dirs are mandatory, // but every other sub-dir is optional up to the full path in $dir // Mandate at least 1 root dir and not more than 5 optional dirs. $dir = \explode(\DIRECTORY_SEPARATOR, \realpath($dir)); $i = \count($dir); if (2 + (int) ('\\' === \DIRECTORY_SEPARATOR) <= $i) { $regex = ''; $lastOptionalDir = $i > 8 ? $i - 5 : 2 + (int) ('\\' === \DIRECTORY_SEPARATOR); $this->targetDirMaxMatches = $i - $lastOptionalDir; while (--$i >= $lastOptionalDir) { $regex = \sprintf('(%s%s)?', \preg_quote(\DIRECTORY_SEPARATOR . $dir[$i], '#'), $regex); } do { $regex = \preg_quote(\DIRECTORY_SEPARATOR . $dir[$i], '#') . $regex; } while (0 < --$i); $this->targetDirRegex = '#(^|file://|[:;, \\|\\r\\n])' . \preg_quote($dir[0], '#') . $regex . '#'; } } $proxyClasses = $this->inlineFactories ? $this->generateProxyClasses() : null; if ($options['preload_classes']) { $this->preload = \array_combine($options['preload_classes'], $options['preload_classes']); } $code = $this->addDefaultParametersMethod(); $code = $this->startClass($options['class'], $baseClass, $this->inlineFactories && $proxyClasses) . $this->addServices($services) . $this->addDeprecatedAliases() . $code; $proxyClasses ??= $this->generateProxyClasses(); if ($this->addGetService) { $code = \preg_replace("/\r?\n\r?\n public function __construct.+?\\{\r?\n/s", "\n protected \\Closure \$getService;\$0", $code, 1); } if ($this->asFiles) { $fileTemplate = <<<EOF <?php use DEPTRAC_INTERNAL\\Symfony\\Component\\DependencyInjection\\Argument\\RewindableGenerator; use DEPTRAC_INTERNAL\\Symfony\\Component\\DependencyInjection\\ContainerInterface; use DEPTRAC_INTERNAL\\Symfony\\Component\\DependencyInjection\\Exception\\RuntimeException; /*{$this->docStar} * @internal This class has been auto-generated by the Symfony Dependency Injection Component. */ class %s extends {$options['class']} {%s} EOF; $files = []; $preloadedFiles = []; $ids = $this->container->getRemovedIds(); foreach ($this->container->getDefinitions() as $id => $definition) { if (!$definition->isPublic()) { $ids[$id] = \true; } } if ($ids = \array_keys($ids)) { \sort($ids); $c = "<?php\n\nreturn [\n"; foreach ($ids as $id) { $c .= ' ' . $this->doExport($id) . " => true,\n"; } $files['removed-ids.php'] = $c . "];\n"; } if (!$this->inlineFactories) { foreach ($this->generateServiceFiles($services) as $file => [$c, $preload]) { $files[$file] = \sprintf($fileTemplate, \substr($file, 0, -4), $c); if ($preload) { $preloadedFiles[$file] = $file; } } foreach ($proxyClasses as $file => $c) { $files[$file] = "<?php\n" . $c; $preloadedFiles[$file] = $file; } } $code .= $this->endClass(); if ($this->inlineFactories && $proxyClasses) { $files['proxy-classes.php'] = "<?php\n\n"; foreach ($proxyClasses as $c) { $files['proxy-classes.php'] .= $c; } } $files[$options['class'] . '.php'] = $code; $hash = \ucfirst(\strtr(ContainerBuilder::hash($files), '._', 'xx')); $code = []; foreach ($files as $file => $c) { $code["Container{$hash}/{$file}"] = \substr_replace($c, "<?php\n\nnamespace Container{$hash};\n", 0, 6); if (isset($preloadedFiles[$file])) { $preloadedFiles[$file] = "Container{$hash}/{$file}"; } } $namespaceLine = $this->namespace ? "\nnamespace {$this->namespace};\n" : ''; $time = $options['build_time']; $id = \hash('crc32', $hash . $time); $this->asFiles = \false; if ($this->preload && null !== ($autoloadFile = $this->getAutoloadFile())) { $autoloadFile = \trim($this->export($autoloadFile), '()\\'); $preloadedFiles = \array_reverse($preloadedFiles); if ('' !== ($preloadedFiles = \implode("';\nrequire __DIR__.'/", $preloadedFiles))) { $preloadedFiles = "require __DIR__.'/{$preloadedFiles}';\n"; } $code[$options['class'] . '.preload.php'] = <<<EOF <?php // This file has been auto-generated by the Symfony Dependency Injection Component // You can reference it in the "opcache.preload" php.ini setting on PHP >= 7.4 when preloading is desired use DEPTRAC_INTERNAL\\Symfony\\Component\\DependencyInjection\\Dumper\\Preloader; if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { return; } require {$autoloadFile}; (require __DIR__.'/{$options['class']}.php')->set(\\Container{$hash}\\{$options['class']}::class, null); {$preloadedFiles} \$classes = []; EOF; foreach ($this->preload as $class) { if (!$class || \str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], \true)) { continue; } if (!(\class_exists($class, \false) || \interface_exists($class, \false) || \trait_exists($class, \false)) || (new \ReflectionClass($class))->isUserDefined()) { $code[$options['class'] . '.preload.php'] .= \sprintf("\$classes[] = '%s';\n", $class); } } $code[$options['class'] . '.preload.php'] .= <<<'EOF' $preloaded = Preloader::preload($classes); EOF; } $code[$options['class'] . '.php'] = <<<EOF <?php {$namespaceLine} // This file has been auto-generated by the Symfony Dependency Injection Component for internal use. if (\\class_exists(\\Container{$hash}\\{$options['class']}::class, false)) { // no-op } elseif (!include __DIR__.'/Container{$hash}/{$options['class']}.php') { touch(__DIR__.'/Container{$hash}.legacy'); return; } if (!\\class_exists({$options['class']}::class, false)) { \\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false); } return new \\Container{$hash}\\{$options['class']}([ 'container.build_hash' => '{$hash}', 'container.build_id' => '{$id}', 'container.build_time' => {$time}, 'container.runtime_mode' => \\in_array(\\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1', ], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}'); EOF; } else { $code .= $this->endClass(); foreach ($proxyClasses as $c) { $code .= $c; } } $this->targetDirRegex = null; $this->inlinedRequires = []; $this->circularReferences = []; $this->locatedIds = []; $this->exportedVariables = []; $this->dynamicParameters = []; $this->preload = []; $unusedEnvs = []; foreach ($this->container->getEnvCounters() as $env => $use) { if (!$use) { $unusedEnvs[] = $env; } } if ($unusedEnvs) { throw new EnvParameterException($unusedEnvs, null, 'Environment variables "%s" are never used. Please, check your container\'s configuration.'); } return $code; }
Dumps the service container as a PHP class. Available options: * class: The class name * base_class: The base class name * namespace: The class namespace * as_files: To split the container in several files @return string|array A PHP class representing the service container or an array of PHP files if the "as_files" option is set @throws EnvParameterException When an env var exists but has not been dumped
dump
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
private function getProxyDumper() : DumperInterface { return $this->proxyDumper ??= new LazyServiceDumper($this->class); }
Retrieves the currently set proxy dumper or instantiates one.
getProxyDumper
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
private function dumpLiteralClass(string $class) : string { if (\str_contains($class, '$')) { return \sprintf('${($_ = %s) && false ?: "_"}', $class); } if (!\str_starts_with($class, "'") || !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) { throw new RuntimeException(\sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a')); } $class = \substr(\str_replace('\\\\', '\\', $class), 1, -1); return \str_starts_with($class, '\\') ? $class : '\\' . $class; }
Dumps a string to a literal (aka PHP Code) class value. @throws RuntimeException
dumpLiteralClass
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
private function initializeMethodNamesMap(string $class) : void { $this->serviceIdToMethodNameMap = []; $this->usedMethodNames = []; if ($reflectionClass = $this->container->getReflectionClass($class)) { foreach ($reflectionClass->getMethods() as $method) { $this->usedMethodNames[\strtolower($method->getName())] = \true; } } }
Initializes the method names map to avoid conflicts with the Container methods.
initializeMethodNamesMap
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
private static function stripComments(string $source) : string { if (!\function_exists('token_get_all')) { return $source; } $rawChunk = ''; $output = ''; $tokens = \token_get_all($source); $ignoreSpace = \false; for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; } elseif (\T_START_HEREDOC === $token[0]) { $output .= $rawChunk . $token[1]; do { $token = $tokens[++$i]; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; } while (\T_END_HEREDOC !== $token[0]); $rawChunk = ''; } elseif (\T_WHITESPACE === $token[0]) { if ($ignoreSpace) { $ignoreSpace = \false; continue; } // replace multiple new lines with a single newline $rawChunk .= \preg_replace(['/\\n{2,}/S'], "\n", $token[1]); } elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) { if (!\in_array($rawChunk[\strlen($rawChunk) - 1], [' ', "\n", "\r", "\t"], \true)) { $rawChunk .= ' '; } $ignoreSpace = \true; } else { $rawChunk .= $token[1]; // The PHP-open tag already has a new-line if (\T_OPEN_TAG === $token[0]) { $ignoreSpace = \true; } else { $ignoreSpace = \false; } } } $output .= $rawChunk; unset($tokens, $rawChunk); \gc_mem_caches(); return $output; }
Removes comments from a PHP source string. We don't use the PHP php_strip_whitespace() function as we want the content to be readable and well-formatted.
stripComments
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/PhpDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/PhpDumper.php
MIT
public function dump(array $options = []) : string { $this->document = new \DOMDocument('1.0', 'utf-8'); $this->document->formatOutput = \true; $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container'); $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd'); $this->addParameters($container); $this->addServices($container); $this->document->appendChild($container); $xml = $this->document->saveXML(); unset($this->document); return $this->container->resolveEnvPlaceholders($xml); }
Dumps the service container as an XML string.
dump
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/XmlDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/XmlDumper.php
MIT
public static function phpToXml(mixed $value) : string { switch (\true) { case null === $value: return 'null'; case \true === $value: return 'true'; case \false === $value: return 'false'; case $value instanceof Parameter: return '%' . $value . '%'; case $value instanceof \UnitEnum: return \sprintf('%s::%s', $value::class, $value->name); case \is_object($value) || \is_resource($value): throw new RuntimeException(\sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', \get_debug_type($value))); default: return (string) $value; } }
Converts php types to xml types. @throws RuntimeException When trying to dump object or resource
phpToXml
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/XmlDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/XmlDumper.php
MIT
public function dump(array $options = []) : string { if (!\class_exists(YmlDumper::class)) { throw new LogicException('Unable to dump the container as the Symfony Yaml Component is not installed. Try running "composer require symfony/yaml".'); } $this->dumper ??= new YmlDumper(); return $this->container->resolveEnvPlaceholders($this->addParameters() . "\n" . $this->addServices()); }
Dumps the service container as an YAML string.
dump
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/YamlDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/YamlDumper.php
MIT
private function dumpValue(mixed $value) : mixed { if ($value instanceof ServiceClosureArgument) { $value = $value->getValues()[0]; return new TaggedValue('service_closure', $this->dumpValue($value)); } if ($value instanceof ArgumentInterface) { $tag = $value; if ($value instanceof TaggedIteratorArgument || $value instanceof ServiceLocatorArgument && ($tag = $value->getTaggedIteratorArgument())) { if (null === $tag->getIndexAttribute()) { $content = $tag->getTag(); } else { $content = ['tag' => $tag->getTag(), 'index_by' => $tag->getIndexAttribute()]; if (null !== $tag->getDefaultIndexMethod()) { $content['default_index_method'] = $tag->getDefaultIndexMethod(); } if (null !== $tag->getDefaultPriorityMethod()) { $content['default_priority_method'] = $tag->getDefaultPriorityMethod(); } } if ($excludes = $tag->getExclude()) { if (!\is_array($content)) { $content = ['tag' => $content]; } $content['exclude'] = 1 === \count($excludes) ? $excludes[0] : $excludes; } if (!$tag->excludeSelf()) { $content['exclude_self'] = \false; } return new TaggedValue($value instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator', $content); } if ($value instanceof IteratorArgument) { $tag = 'iterator'; } elseif ($value instanceof ServiceLocatorArgument) { $tag = 'service_locator'; } else { throw new RuntimeException(\sprintf('Unspecified Yaml tag for type "%s".', \get_debug_type($value))); } return new TaggedValue($tag, $this->dumpValue($value->getValues())); } if (\is_array($value)) { $code = []; foreach ($value as $k => $v) { $code[$k] = $this->dumpValue($v); } return $code; } elseif ($value instanceof Reference) { return $this->getServiceCall((string) $value, $value); } elseif ($value instanceof Parameter) { return $this->getParameterCall((string) $value); } elseif ($value instanceof Expression) { return $this->getExpressionCall((string) $value); } elseif ($value instanceof Definition) { return new TaggedValue('service', (new Parser())->parse("_:\n" . $this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']); } elseif ($value instanceof \UnitEnum) { return new TaggedValue('php/const', \sprintf('%s::%s', $value::class, $value->name)); } elseif ($value instanceof AbstractArgument) { return new TaggedValue('abstract', $value->getText()); } elseif (\is_object($value) || \is_resource($value)) { throw new RuntimeException(\sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', \get_debug_type($value))); } return $value; }
Dumps the value to YAML format. @throws RuntimeException When trying to dump object or resource
dumpValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/Dumper/YamlDumper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Dumper/YamlDumper.php
MIT
public function __construct(string $key, ?string $sourceId = null, ?string $sourceKey = null, ?\Throwable $previous = null, array $alternatives = [], ?string $nonNestedAlternative = null) { $this->key = $key; $this->sourceId = $sourceId; $this->sourceKey = $sourceKey; $this->alternatives = $alternatives; $this->nonNestedAlternative = $nonNestedAlternative; parent::__construct('', 0, $previous); $this->updateRepr(); }
@param string $key The requested parameter key @param string|null $sourceId The service id that references the non-existent parameter @param string|null $sourceKey The parameter key that references the non-existent parameter @param \Throwable|null $previous The previous exception @param string[] $alternatives Some parameter name alternatives @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
__construct
php
deptrac/deptrac
vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php
MIT
public function getAlias() : string { $className = static::class; if (!\str_ends_with($className, 'Extension')) { throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); } $classBaseName = \substr(\strrchr($className, '\\'), 1, -9); return Container::underscore($classBaseName); }
Returns the recommended alias to use in XML. This alias is also the mandatory prefix to use when using YAML. This convention is to remove the "Extension" postfix from the class name and then lowercase and underscore the result. So: AcmeHelloExtension becomes acme_hello This can be overridden in a sub-class to specify the alias manually. @throws BadMethodCallException When the extension name does not follow conventions
getAlias
php
deptrac/deptrac
vendor/symfony/dependency-injection/Extension/Extension.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Extension/Extension.php
MIT
protected function isConfigEnabled(ContainerBuilder $container, array $config) : bool { if (!\array_key_exists('enabled', $config)) { throw new InvalidArgumentException("The config array has no 'enabled' key."); } return (bool) $container->getParameterBag()->resolveValue($config['enabled']); }
@throws InvalidArgumentException When the config is not enableable
isConfigEnabled
php
deptrac/deptrac
vendor/symfony/dependency-injection/Extension/Extension.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Extension/Extension.php
MIT
public static function getTypeHint(\ReflectionFunctionAbstract $r, ?\ReflectionParameter $p = null, bool $noBuiltin = \false) : ?string { if ($p instanceof \ReflectionParameter) { $type = $p->getType(); } else { $type = $r->getReturnType(); } if (!$type) { return null; } return self::getTypeHintForType($type, $r, $noBuiltin); }
@return string|null The FQCN or builtin name of the type hint, or null when the type hint references an invalid self|parent context
getTypeHint
php
deptrac/deptrac
vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php
MIT
public function import(mixed $resource, ?string $type = null, bool|string $ignoreErrors = \false, ?string $sourceResource = null, $exclude = null) : mixed { $args = \func_get_args(); if ($ignoreNotFound = 'not_found' === $ignoreErrors) { $args[2] = \false; } elseif (!\is_bool($ignoreErrors)) { throw new \TypeError(\sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, \get_debug_type($ignoreErrors))); } try { return parent::import(...$args); } catch (LoaderLoadException $e) { if (!$ignoreNotFound || !($prev = $e->getPrevious()) instanceof FileLocatorFileNotFoundException) { throw $e; } foreach ($prev->getTrace() as $frame) { if ('import' === ($frame['function'] ?? null) && \is_a($frame['class'] ?? '', Loader::class, \true)) { break; } } if (__FILE__ !== $frame['file']) { throw $e; } } return null; }
@param bool|string $ignoreErrors Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found
import
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/FileLoader.php
MIT
public function registerClasses(Definition $prototype, string $namespace, string $resource, string|array|null $exclude = null) { if (!\str_ends_with($namespace, '\\')) { throw new InvalidArgumentException(\sprintf('Namespace prefix must end with a "\\": "%s".', $namespace)); } if (!\preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+\\\\)++$/', $namespace)) { throw new InvalidArgumentException(\sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace)); } // This can happen with YAML files if (\is_array($exclude) && \in_array(null, $exclude, \true)) { throw new InvalidArgumentException('The exclude list must not contain a "null" value.'); } // This can happen with XML files if (\is_array($exclude) && \in_array('', $exclude, \true)) { throw new InvalidArgumentException('The exclude list must not contain an empty value.'); } $source = \func_num_args() > 4 ? \func_get_arg(4) : null; $autoconfigureAttributes = new RegisterAutoconfigureAttributesPass(); $autoconfigureAttributes = $autoconfigureAttributes->accept($prototype) ? $autoconfigureAttributes : null; $classes = $this->findClasses($namespace, $resource, (array) $exclude, $autoconfigureAttributes, $source); $getPrototype = static fn() => clone $prototype; $serialized = \serialize($prototype); // avoid deep cloning if no definitions are nested if (\strpos($serialized, 'O:48:"Symfony\\Component\\DependencyInjection\\Definition"', 55) || \strpos($serialized, 'O:53:"Symfony\\Component\\DependencyInjection\\ChildDefinition"', 55)) { // prepare for deep cloning foreach (['Arguments', 'Properties', 'MethodCalls', 'Configurator', 'Factory', 'Bindings'] as $key) { $serialized = \serialize($prototype->{'get' . $key}()); if (\strpos($serialized, 'O:48:"Symfony\\Component\\DependencyInjection\\Definition"') || \strpos($serialized, 'O:53:"Symfony\\Component\\DependencyInjection\\ChildDefinition"')) { $getPrototype = static fn() => $getPrototype()->{'set' . $key}(\unserialize($serialized)); } } } unset($serialized); foreach ($classes as $class => $errorMessage) { if (null === $errorMessage && $autoconfigureAttributes) { $r = $this->container->getReflectionClass($class); if ($r->getAttributes(Exclude::class)[0] ?? null) { $this->addContainerExcludedTag($class, $source); continue; } if ($this->env) { $attribute = null; foreach ($r->getAttributes(When::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { if ($this->env === $attribute->newInstance()->env) { $attribute = null; break; } } if (null !== $attribute) { $this->addContainerExcludedTag($class, $source); continue; } } } if (\interface_exists($class, \false)) { $this->interfaces[] = $class; } else { $this->setDefinition($class, $definition = $getPrototype()); if (null !== $errorMessage) { $definition->addError($errorMessage); continue; } $definition->setClass($class); $interfaces = []; foreach (\class_implements($class, \false) as $interface) { $this->singlyImplemented[$interface] = ($this->singlyImplemented[$interface] ?? $class) !== $class ? \false : $class; $interfaces[] = $interface; } if (!$autoconfigureAttributes) { continue; } $r = $this->container->getReflectionClass($class); $defaultAlias = 1 === \count($interfaces) ? $interfaces[0] : null; foreach ($r->getAttributes(AsAlias::class) as $attr) { /** @var AsAlias $attribute */ $attribute = $attr->newInstance(); $alias = $attribute->id ?? $defaultAlias; $public = $attribute->public; if (null === $alias) { throw new LogicException(\sprintf('Alias cannot be automatically determined for class "%s". If you have used the #[AsAlias] attribute with a class implementing multiple interfaces, add the interface you want to alias to the first parameter of #[AsAlias].', $class)); } if (isset($this->aliases[$alias])) { throw new LogicException(\sprintf('The "%s" alias has already been defined with the #[AsAlias] attribute in "%s".', $alias, $this->aliases[$alias])); } $this->aliases[$alias] = new Alias($class, $public); } } } foreach ($this->aliases as $alias => $aliasDefinition) { $this->container->setAlias($alias, $aliasDefinition); } if ($this->autoRegisterAliasesForSinglyImplementedInterfaces) { $this->registerAliasesForSinglyImplementedInterfaces(); } }
Registers a set of classes as services using PSR-4 for discovery. @param Definition $prototype A definition to use as template @param string $namespace The namespace prefix of classes in the scanned directory @param string $resource The directory to look for classes, glob-patterns allowed @param string|string[]|null $exclude A globbed path of files to exclude or an array of globbed paths of files to exclude @param string|null $source The path to the file that defines the auto-discovery rule @return void
registerClasses
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/FileLoader.php
MIT
protected function setDefinition(string $id, Definition $definition) { $this->container->removeBindings($id); foreach ($definition->getTag('container.error') as $error) { if (isset($error['message'])) { $definition->addError($error['message']); } } if ($this->isLoadingInstanceof) { if (!$definition instanceof ChildDefinition) { throw new InvalidArgumentException(\sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_debug_type($definition))); } $this->instanceof[$id] = $definition; } else { $this->container->setDefinition($id, $definition->setInstanceofConditionals($this->instanceof)); } }
Registers a definition in the container with its instanceof-conditionals. @return void
setDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/FileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/FileLoader.php
MIT
private function phpize(string $value) : mixed { // trim on the right as comments removal keep whitespaces if ($value !== ($v = \rtrim($value))) { $value = '""' === \substr_replace($v, '', 1, -1) ? \substr($v, 1, -1) : $v; } $lowercaseValue = \strtolower($value); return match (\true) { \defined($value) => \constant($value), 'yes' === $lowercaseValue, 'on' === $lowercaseValue => \true, 'no' === $lowercaseValue, 'off' === $lowercaseValue, 'none' === $lowercaseValue => \false, isset($value[1]) && ("'" === $value[0] && "'" === $value[\strlen($value) - 1] || '"' === $value[0] && '"' === $value[\strlen($value) - 1]) => \substr($value, 1, -1), // quoted string default => XmlUtils::phpize($value), }; }
Note that the following features are not supported: * strings with escaped quotes are not supported "foo\"bar"; * string concatenation ("foo" "bar").
phpize
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/IniFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/IniFileLoader.php
MIT
private function executeCallback(callable $callback, ContainerConfigurator $containerConfigurator, string $path) : void { $callback = $callback(...); $arguments = []; $configBuilders = []; $r = new \ReflectionFunction($callback); $attribute = null; foreach ($r->getAttributes(When::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { if ($this->env === $attribute->newInstance()->env) { $attribute = null; break; } } if (null !== $attribute) { return; } foreach ($r->getParameters() as $parameter) { $reflectionType = $parameter->getType(); if (!$reflectionType instanceof \ReflectionNamedType) { throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, ContainerConfigurator::class, ContainerBuilder::class)); } $type = $reflectionType->getName(); switch ($type) { case ContainerConfigurator::class: $arguments[] = $containerConfigurator; break; case ContainerBuilder::class: $arguments[] = $this->container; break; case FileLoader::class: case self::class: $arguments[] = $this; break; case 'string': if (null !== $this->env && 'env' === $parameter->getName()) { $arguments[] = $this->env; break; } // no break default: try { $configBuilder = $this->configBuilder($type); } catch (InvalidArgumentException|\LogicException $e) { throw new \InvalidArgumentException(\sprintf('Could not resolve argument "%s" for "%s".', $type . ' $' . $parameter->getName(), $path), 0, $e); } $configBuilders[] = $configBuilder; $arguments[] = $configBuilder; } } // Force load ContainerConfigurator to make env(), param() etc available. \class_exists(ContainerConfigurator::class); $callback(...$arguments); /** @var ConfigBuilderInterface $configBuilder */ foreach ($configBuilders as $configBuilder) { $containerConfigurator->extension($configBuilder->getExtensionAlias(), $configBuilder->toArray()); } }
Resolve the parameters to the $callback and execute it.
executeCallback
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/PhpFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php
MIT
private function configBuilder(string $namespace) : ConfigBuilderInterface { if (!\class_exists(ConfigBuilderGenerator::class)) { throw new \LogicException('You cannot use the config builder as the Config component is not installed. Try running "composer require symfony/config".'); } if (null === $this->generator) { throw new \LogicException('You cannot use the ConfigBuilders without providing a class implementing ConfigBuilderGeneratorInterface.'); } // If class exists and implements ConfigBuilderInterface if (\class_exists($namespace) && \is_subclass_of($namespace, ConfigBuilderInterface::class)) { return new $namespace(); } // If it does not start with Symfony\Config\ we don't know how to handle this if (!\str_starts_with($namespace, 'Symfony\\Config\\')) { throw new InvalidArgumentException(\sprintf('Could not find or generate class "%s".', $namespace)); } // Try to get the extension alias $alias = Container::underscore(\substr($namespace, 15, -6)); if (\str_contains($alias, '\\')) { throw new InvalidArgumentException('You can only use "root" ConfigBuilders from "Symfony\\Config\\" namespace. Nested classes like "Symfony\\Config\\Framework\\CacheConfig" cannot be used.'); } if (!$this->container->hasExtension($alias)) { $extensions = \array_filter(\array_map(fn(ExtensionInterface $ext) => $ext->getAlias(), $this->container->getExtensions())); throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? \implode('", "', $extensions) : 'none')); } $extension = $this->container->getExtension($alias); if (!$extension instanceof ConfigurationExtensionInterface) { throw new \LogicException(\sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".', $namespace, ConfigurationExtensionInterface::class)); } $configuration = $extension->getConfiguration([], $this->container); $loader = $this->generator->build($configuration); return $loader(); }
@param string $namespace FQCN string for a class implementing ConfigBuilderInterface
configBuilder
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/PhpFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php
MIT
private function parseFileToDOM(string $file) : \DOMDocument { try { $dom = XmlUtils::loadFile($file, $this->validateSchema(...)); } catch (\InvalidArgumentException $e) { $invalidSecurityElements = []; $errors = \explode("\n", $e->getMessage()); foreach ($errors as $i => $error) { if (\preg_match("#^\\[ERROR 1871] Element '\\{http://symfony\\.com/schema/dic/security}([^']+)'#", $error, $matches)) { $invalidSecurityElements[$i] = $matches[1]; } } if ($invalidSecurityElements) { $dom = XmlUtils::loadFile($file); foreach ($invalidSecurityElements as $errorIndex => $tagName) { foreach ($dom->getElementsByTagNameNS('http://symfony.com/schema/dic/security', $tagName) as $element) { if (!($parent = $element->parentNode)) { continue; } if ('http://symfony.com/schema/dic/security' !== $parent->namespaceURI) { continue; } if ('provider' === $parent->localName || 'firewall' === $parent->localName) { unset($errors[$errorIndex]); } } } } if ($errors) { throw new InvalidArgumentException(\sprintf('Unable to parse file "%s": ', $file) . \implode("\n", $errors), $e->getCode(), $e); } } $this->validateExtensions($dom, $file); return $dom; }
Parses an XML file to a \DOMDocument. @throws InvalidArgumentException When loading of XML file returns error
parseFileToDOM
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
MIT
private function getChildren(\DOMNode $node, string $name) : array { $children = []; foreach ($node->childNodes as $child) { if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) { $children[] = $child; } } return $children; }
Get child elements by name. @return \DOMElement[]
getChildren
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
MIT
public function validateSchema(\DOMDocument $dom) : bool { $schemaLocations = ['http://symfony.com/schema/dic/services' => \str_replace('\\', '/', __DIR__ . '/schema/dic/services/services-1.0.xsd')]; if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) { $items = \preg_split('/\\s+/', $element); for ($i = 0, $nb = \count($items); $i < $nb; $i += 2) { if (!$this->container->hasExtension($items[$i])) { continue; } if (($extension = $this->container->getExtension($items[$i])) && \false !== $extension->getXsdValidationBasePath()) { $ns = $extension->getNamespace(); $path = \str_replace([$ns, \str_replace('http://', 'https://', $ns)], \str_replace('\\', '/', $extension->getXsdValidationBasePath()) . '/', $items[$i + 1]); if (!\is_file($path)) { throw new RuntimeException(\sprintf('Extension "%s" references a non-existent XSD file "%s".', \get_debug_type($extension), $path)); } $schemaLocations[$items[$i]] = $path; } } } $tmpfiles = []; $imports = ''; foreach ($schemaLocations as $namespace => $location) { $parts = \explode('/', $location); $locationstart = 'file:///'; if (0 === \stripos($location, 'phar://')) { $tmpfile = \tempnam(\sys_get_temp_dir(), 'symfony'); if ($tmpfile) { \copy($location, $tmpfile); $tmpfiles[] = $tmpfile; $parts = \explode('/', \str_replace('\\', '/', $tmpfile)); } else { \array_shift($parts); $locationstart = 'phar:///'; } } elseif ('\\' === \DIRECTORY_SEPARATOR && \str_starts_with($location, '\\\\')) { $locationstart = ''; } $drive = '\\' === \DIRECTORY_SEPARATOR ? \array_shift($parts) . '/' : ''; $location = $locationstart . $drive . \implode('/', \array_map('rawurlencode', $parts)); $imports .= \sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />' . "\n", $namespace, $location); } $source = <<<EOF <?xml version="1.0" encoding="utf-8" ?> <xsd:schema xmlns="http://symfony.com/schema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://symfony.com/schema" elementFormDefault="qualified"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> {$imports} </xsd:schema> EOF; if ($this->shouldEnableEntityLoader()) { $disableEntities = \libxml_disable_entity_loader(\false); $valid = @$dom->schemaValidateSource($source); \libxml_disable_entity_loader($disableEntities); } else { $valid = @$dom->schemaValidateSource($source); } foreach ($tmpfiles as $tmpfile) { @\unlink($tmpfile); } return $valid; }
Validates a documents XML schema. @throws RuntimeException When extension references a non-existent XSD file
validateSchema
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
MIT
private function validateExtensions(\DOMDocument $dom, string $file) : void { foreach ($dom->documentElement->childNodes as $node) { if (!$node instanceof \DOMElement || 'http://symfony.com/schema/dic/services' === $node->namespaceURI) { continue; } // can it be handled by an extension? if (!$this->container->hasExtension($node->namespaceURI)) { $extensionNamespaces = \array_filter(\array_map(fn(ExtensionInterface $ext) => $ext->getNamespace(), $this->container->getExtensions())); throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? \implode('", "', $extensionNamespaces) : 'none')); } } }
Validates an extension. @throws InvalidArgumentException When no extension is found corresponding to a tag
validateExtensions
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
MIT
public static function convertDomElementToArray(\DOMElement $element) : mixed { return XmlUtils::convertDomElementToArray($element, \false); }
Converts a \DOMElement object to a PHP array. The following rules applies during the conversion: * Each tag is converted to a key value or an array if there is more than one "value" * The content of a tag is set under a "value" key (<foo>bar</foo>) if the tag also has some nested tags * The attributes are converted to keys (<foo foo="bar"/>) * The nested-tags are converted to keys (<foo><foo>bar</foo></foo>) @param \DOMElement $element A \DOMElement instance
convertDomElementToArray
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
MIT
private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = \false, bool $trackBindings = \true) : Definition|Alias|null { if (\preg_match('/^_[a-zA-Z0-9_]*$/', $id)) { throw new InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id)); } if (\is_string($service) && \str_starts_with($service, '@')) { $alias = new Alias(\substr($service, 1)); if (isset($defaults['public'])) { $alias->setPublic($defaults['public']); } return $return ? $alias : $this->container->setAlias($id, $alias); } if (\is_array($service) && $this->isUsingShortSyntax($service)) { $service = ['arguments' => $service]; } if (!\is_array($service ??= [])) { throw new InvalidArgumentException(\sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); } if (isset($service['stack'])) { if (!\is_array($service['stack'])) { throw new InvalidArgumentException(\sprintf('A stack must be an array of definitions, "%s" given for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); } $stack = []; foreach ($service['stack'] as $k => $frame) { if (\is_array($frame) && 1 === \count($frame) && !isset(self::SERVICE_KEYWORDS[\key($frame)])) { $frame = ['class' => \key($frame), 'arguments' => \current($frame)]; } if (\is_array($frame) && isset($frame['stack'])) { throw new InvalidArgumentException(\sprintf('Service stack "%s" cannot contain another stack in "%s".', $id, $file)); } $definition = $this->parseDefinition($id . '" at index "' . $k, $frame, $file, $defaults, \true); if ($definition instanceof Definition) { $definition->setInstanceofConditionals($this->instanceof); } $stack[$k] = $definition; } if ($diff = \array_diff(\array_keys($service), ['stack', 'public', 'deprecated'])) { throw new InvalidArgumentException(\sprintf('Invalid attribute "%s"; supported ones are "public" and "deprecated" for service "%s" in "%s". Check your YAML syntax.', \implode('", "', $diff), $id, $file)); } $service = ['parent' => '', 'arguments' => $stack, 'tags' => ['container.stack'], 'public' => $service['public'] ?? null, 'deprecated' => $service['deprecated'] ?? null]; } $definition = isset($service[0]) && $service[0] instanceof Definition ? \array_shift($service) : null; $return = null === $definition ? $return : \true; if (isset($service['from_callable'])) { foreach (['alias', 'parent', 'synthetic', 'factory', 'file', 'arguments', 'properties', 'configurator', 'calls'] as $key) { if (isset($service['factory'])) { throw new InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for the service "%s" when using "from_callable" in "%s".', $key, $id, $file)); } } if ('Closure' !== ($service['class'] ??= 'Closure')) { $service['lazy'] = \true; } $service['factory'] = ['Closure', 'fromCallable']; $service['arguments'] = [$service['from_callable']]; unset($service['from_callable']); } $this->checkDefinition($id, $service, $file); if (isset($service['alias'])) { $alias = new Alias($service['alias']); if (isset($service['public'])) { $alias->setPublic($service['public']); } elseif (isset($defaults['public'])) { $alias->setPublic($defaults['public']); } foreach ($service as $key => $value) { if (!\in_array($key, ['alias', 'public', 'deprecated'])) { throw new InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for the service "%s" which is defined as an alias in "%s". Allowed configuration keys for service aliases are "alias", "public" and "deprecated".', $key, $id, $file)); } if ('deprecated' === $key) { $deprecation = \is_array($value) ? $value : ['message' => $value]; if (!isset($deprecation['package'])) { throw new InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); } if (!isset($deprecation['version'])) { throw new InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); } $alias->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message'] ?? ''); } } return $return ? $alias : $this->container->setAlias($id, $alias); } $changes = []; if (null !== $definition) { $changes = $definition->getChanges(); } elseif ($this->isLoadingInstanceof) { $definition = new ChildDefinition(''); } elseif (isset($service['parent'])) { if ('' !== $service['parent'] && '@' === $service['parent'][0]) { throw new InvalidArgumentException(\sprintf('The value of the "parent" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['parent'], \substr($service['parent'], 1))); } $definition = new ChildDefinition($service['parent']); } else { $definition = new Definition(); } if (isset($defaults['public'])) { $definition->setPublic($defaults['public']); } if (isset($defaults['autowire'])) { $definition->setAutowired($defaults['autowire']); } if (isset($defaults['autoconfigure'])) { $definition->setAutoconfigured($defaults['autoconfigure']); } $definition->setChanges($changes); if (isset($service['class'])) { $definition->setClass($service['class']); } if (isset($service['shared'])) { $definition->setShared($service['shared']); } if (isset($service['synthetic'])) { $definition->setSynthetic($service['synthetic']); } if (isset($service['lazy'])) { $definition->setLazy((bool) $service['lazy']); if (\is_string($service['lazy'])) { $definition->addTag('proxy', ['interface' => $service['lazy']]); } } if (isset($service['public'])) { $definition->setPublic($service['public']); } if (isset($service['abstract'])) { $definition->setAbstract($service['abstract']); } if (isset($service['deprecated'])) { $deprecation = \is_array($service['deprecated']) ? $service['deprecated'] : ['message' => $service['deprecated']]; if (!isset($deprecation['package'])) { throw new InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); } if (!isset($deprecation['version'])) { throw new InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); } $definition->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message'] ?? ''); } if (isset($service['factory'])) { $definition->setFactory($this->parseCallable($service['factory'], 'factory', $id, $file)); } if (isset($service['constructor'])) { if (null !== $definition->getFactory()) { throw new LogicException(\sprintf('The "%s" service cannot declare a factory as well as a constructor.', $id)); } $definition->setFactory([null, $service['constructor']]); } if (isset($service['file'])) { $definition->setFile($service['file']); } if (isset($service['arguments'])) { $definition->setArguments($this->resolveServices($service['arguments'], $file)); } if (isset($service['properties'])) { $definition->setProperties($this->resolveServices($service['properties'], $file)); } if (isset($service['configurator'])) { $definition->setConfigurator($this->parseCallable($service['configurator'], 'configurator', $id, $file)); } if (isset($service['calls'])) { if (!\is_array($service['calls'])) { throw new InvalidArgumentException(\sprintf('Parameter "calls" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } foreach ($service['calls'] as $k => $call) { if (!\is_array($call) && (!\is_string($k) || !$call instanceof TaggedValue)) { throw new InvalidArgumentException(\sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof TaggedValue ? '!' . $call->getTag() : \get_debug_type($call), $file)); } if (\is_string($k)) { throw new InvalidArgumentException(\sprintf('Invalid method call for service "%s", did you forget a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); } if (isset($call['method']) && \is_string($call['method'])) { $method = $call['method']; $args = $call['arguments'] ?? []; $returnsClone = $call['returns_clone'] ?? \false; } else { if (1 === \count($call) && \is_string(\key($call))) { $method = \key($call); $args = $call[$method]; if ($args instanceof TaggedValue) { if ('returns_clone' !== $args->getTag()) { throw new InvalidArgumentException(\sprintf('Unsupported tag "!%s", did you mean "!returns_clone" for service "%s" in "%s"?', $args->getTag(), $id, $file)); } $returnsClone = \true; $args = $args->getValue(); } else { $returnsClone = \false; } } elseif (empty($call[0])) { throw new InvalidArgumentException(\sprintf('Invalid call for service "%s": the method must be defined as the first index of an array or as the only key of a map in "%s".', $id, $file)); } else { $method = $call[0]; $args = $call[1] ?? []; $returnsClone = $call[2] ?? \false; } } if (!\is_array($args)) { throw new InvalidArgumentException(\sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in "%s". Check your YAML syntax.', $method, $id, $file)); } $args = $this->resolveServices($args, $file); $definition->addMethodCall($method, $args, $returnsClone); } } $tags = $service['tags'] ?? []; if (!\is_array($tags)) { throw new InvalidArgumentException(\sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if (isset($defaults['tags'])) { $tags = \array_merge($tags, $defaults['tags']); } foreach ($tags as $tag) { if (!\is_array($tag)) { $tag = ['name' => $tag]; } if (1 === \count($tag) && \is_array(\current($tag))) { $name = \key($tag); $tag = \current($tag); } else { if (!isset($tag['name'])) { throw new InvalidArgumentException(\sprintf('A "tags" entry is missing a "name" key for service "%s" in "%s".', $id, $file)); } $name = $tag['name']; unset($tag['name']); } if (!\is_string($name) || '' === $name) { throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $id, $file)); } $this->validateAttributes(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, '%s', $file), $tag); $definition->addTag($name, $tag); } if (null !== ($decorates = $service['decorates'] ?? null)) { if ('' !== $decorates && '@' === $decorates[0]) { throw new InvalidArgumentException(\sprintf('The value of the "decorates" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['decorates'], \substr($decorates, 1))); } $decorationOnInvalid = \array_key_exists('decoration_on_invalid', $service) ? $service['decoration_on_invalid'] : 'exception'; if ('exception' === $decorationOnInvalid) { $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; } elseif ('ignore' === $decorationOnInvalid) { $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } elseif (null === $decorationOnInvalid) { $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } elseif ('null' === $decorationOnInvalid) { throw new InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean null (without quotes) in "%s"?', $decorationOnInvalid, $id, $file)); } else { throw new InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean "exception", "ignore" or null in "%s"?', $decorationOnInvalid, $id, $file)); } $renameId = $service['decoration_inner_name'] ?? null; $priority = $service['decoration_priority'] ?? 0; $definition->setDecoratedService($decorates, $renameId, $priority, $invalidBehavior); } if (isset($service['autowire'])) { $definition->setAutowired($service['autowire']); } if (isset($defaults['bind']) || isset($service['bind'])) { // deep clone, to avoid multiple process of the same instance in the passes $bindings = $definition->getBindings(); $bindings += isset($defaults['bind']) ? \unserialize(\serialize($defaults['bind'])) : []; if (isset($service['bind'])) { if (!\is_array($service['bind'])) { throw new InvalidArgumentException(\sprintf('Parameter "bind" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $bindings = \array_merge($bindings, $this->resolveServices($service['bind'], $file)); $bindingType = $this->isLoadingInstanceof ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING; foreach ($bindings as $argument => $value) { if (!$value instanceof BoundArgument) { $bindings[$argument] = new BoundArgument($value, $trackBindings, $bindingType, $file); } } } $definition->setBindings($bindings); } if (isset($service['autoconfigure'])) { $definition->setAutoconfigured($service['autoconfigure']); } if (\array_key_exists('namespace', $service) && !\array_key_exists('resource', $service)) { throw new InvalidArgumentException(\sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if ($return) { if (\array_key_exists('resource', $service)) { throw new InvalidArgumentException(\sprintf('Invalid "resource" attribute found for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } return $definition; } if (\array_key_exists('resource', $service)) { if (!\is_string($service['resource'])) { throw new InvalidArgumentException(\sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $exclude = $service['exclude'] ?? null; $namespace = $service['namespace'] ?? $id; $this->registerClasses($definition, $namespace, $service['resource'], $exclude, $file); } else { $this->setDefinition($id, $definition); } return null; }
@throws InvalidArgumentException When tags are invalid
parseDefinition
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
MIT
protected function loadFile(string $file) : ?array { if (!\class_exists(\DEPTRAC_INTERNAL\Symfony\Component\Yaml\Parser::class)) { throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed. Try running "composer require symfony/yaml".'); } if (!\stream_is_local($file)) { throw new InvalidArgumentException(\sprintf('This is not a local file "%s".', $file)); } if (!\is_file($file)) { throw new InvalidArgumentException(\sprintf('The file "%s" does not exist.', $file)); } $this->yamlParser ??= new YamlParser(); try { $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); } catch (ParseException $e) { throw new InvalidArgumentException(\sprintf('The file "%s" does not contain valid YAML: ', $file) . $e->getMessage(), 0, $e); } return $this->validate($configuration, $file); }
Loads a YAML file. @throws InvalidArgumentException when the given file is not a local file or when it does not exist
loadFile
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
MIT
private function validate(mixed $content, string $file) : ?array { if (null === $content) { return $content; } if (!\is_array($content)) { throw new InvalidArgumentException(\sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } foreach ($content as $namespace => $data) { if (\in_array($namespace, ['imports', 'parameters', 'services']) || \str_starts_with($namespace, 'when@')) { continue; } if (!$this->container->hasExtension($namespace)) { $extensionNamespaces = \array_filter(\array_map(fn(ExtensionInterface $ext) => $ext->getAlias(), $this->container->getExtensions())); throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $file, $namespace, $extensionNamespaces ? \sprintf('"%s"', \implode('", "', $extensionNamespaces)) : 'none')); } } return $content; }
Validates a YAML file. @throws InvalidArgumentException When service file is not valid
validate
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php
MIT
public static function processValue(mixed $value, bool $allowServices = \false) : mixed { if (\is_array($value)) { foreach ($value as $k => $v) { $value[$k] = static::processValue($v, $allowServices); } return self::$valuePreProcessor ? (self::$valuePreProcessor)($value, $allowServices) : $value; } if (self::$valuePreProcessor) { $value = (self::$valuePreProcessor)($value, $allowServices); } if ($value instanceof ReferenceConfigurator) { $reference = new Reference($value->id, $value->invalidBehavior); return $value instanceof ClosureReferenceConfigurator ? new ServiceClosureArgument($reference) : $reference; } if ($value instanceof InlineServiceConfigurator) { $def = $value->definition; $value->definition = null; return $def; } if ($value instanceof ParamConfigurator) { return (string) $value; } if ($value instanceof self) { throw new InvalidArgumentException(\sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY)); } switch (\true) { case null === $value: case \is_scalar($value): case $value instanceof \UnitEnum: return $value; case $value instanceof ArgumentInterface: case $value instanceof Definition: case $value instanceof Expression: case $value instanceof Parameter: case $value instanceof AbstractArgument: case $value instanceof Reference: if ($allowServices) { return $value; } } throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', \get_debug_type($value))); }
Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value. @param bool $allowServices whether Definition and Reference are allowed; by default, only scalars, arrays and enum are @return mixed the value, optionally cast to a Definition/Reference
processValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php
MIT
public final function load(string $namespace, string $resource) : PrototypeConfigurator { $this->__destruct(); return $this->parent->load($namespace, $resource); }
Registers a PSR-4 namespace using a glob pattern.
load
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
MIT
public final function get(string $id) : ServiceConfigurator { $this->__destruct(); return $this->parent->get($id); }
Gets an already defined service definition. @throws ServiceNotFoundException if the service definition does not exist
get
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
MIT
public final function remove(string $id) : ServicesConfigurator { $this->__destruct(); return $this->parent->remove($id); }
Removes an already defined service definition or alias.
remove
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
MIT
public final function stack(string $id, array $services) : AliasConfigurator { $this->__destruct(); return $this->parent->stack($id, $services); }
Registers a stack of decorator services. @param InlineServiceConfigurator[]|ReferenceConfigurator[] $services
stack
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php
MIT
public final function env() : ?string { return $this->env; }
Get the current environment to be able to write conditional configuration.
env
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
MIT
function service_locator(array $values) : ServiceLocatorArgument { $values = AbstractConfigurator::processValue($values, \true); if (isset($values[0])) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/dependency-injection', '6.3', 'Using integers as keys in a "service_locator()" argument is deprecated. The keys will default to the IDs of the original services in 7.0.'); } return new ServiceLocatorArgument($values); }
Creates a service locator. @param array<ReferenceConfigurator|InlineServiceConfigurator> $values
service_locator
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
MIT
function iterator(array $values) : IteratorArgument { return new IteratorArgument(AbstractConfigurator::processValue($values, \true)); }
Creates a lazy iterator. @param ReferenceConfigurator[] $values
iterator
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
MIT
function tagged_iterator(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = \true) : TaggedIteratorArgument { return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \false, $defaultPriorityMethod, (array) $exclude, $excludeSelf); }
Creates a lazy iterator by tag name.
tagged_iterator
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
MIT
function tagged_locator(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = \true) : ServiceLocatorArgument { return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \true, $defaultPriorityMethod, (array) $exclude, $excludeSelf)); }
Creates a service locator by tag name.
tagged_locator
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
MIT
public final function tag(string $name, array $attributes = []) : static { if ('' === $name) { throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); } $this->validateAttributes($name, $attributes); $this->definition->addTag($name, $attributes); return $this; }
Adds a tag for this definition. @return $this @throws InvalidArgumentException when an invalid tag name or attribute is provided
tag
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php
MIT
public final function instanceof(string $fqcn) : InstanceofConfigurator { return $this->parent->instanceof($fqcn); }
Defines an instanceof-conditional to be applied to following service definitions.
instanceof
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php
MIT
public function enum(string $backedEnumClassName) : static { \array_unshift($this->stack, 'enum', $backedEnumClassName); return $this; }
@param class-string<\BackedEnum> $backedEnumClassName @return $this
enum
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php
MIT
public final function instanceof(string $fqcn) : self { return $this->parent->instanceof($fqcn); }
Defines an instanceof-conditional to be applied to following service definitions.
instanceof
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php
MIT
public final function exclude(array|string $excludes) : static { $this->excludes = (array) $excludes; return $this; }
Excludes files from registration using glob patterns. @param string[]|string $excludes @return $this
exclude
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php
MIT
public final function defaults() : DefaultsConfigurator { return new DefaultsConfigurator($this, $this->defaults = new Definition(), $this->path); }
Defines a set of defaults for following service definitions.
defaults
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function instanceof(string $fqcn) : InstanceofConfigurator { $this->instanceof[$fqcn] = $definition = new ChildDefinition(''); return new InstanceofConfigurator($this, $definition, $fqcn, $this->path); }
Defines an instanceof-conditional to be applied to following service definitions.
instanceof
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function set(?string $id, ?string $class = null) : ServiceConfigurator { $defaults = $this->defaults; $definition = new Definition(); if (null === $id) { if (!$class) { throw new \LogicException('Anonymous services must have a class name.'); } $id = \sprintf('.%d_%s', ++$this->anonymousCount, \preg_replace('/^.*\\\\/', '', $class) . '~' . $this->anonymousHash); } elseif (!$defaults->isPublic() || !$defaults->isPrivate()) { $definition->setPublic($defaults->isPublic() && !$defaults->isPrivate()); } $definition->setAutowired($defaults->isAutowired()); $definition->setAutoconfigured($defaults->isAutoconfigured()); // deep clone, to avoid multiple process of the same instance in the passes $definition->setBindings(\unserialize(\serialize($defaults->getBindings()))); $definition->setChanges([]); $configurator = new ServiceConfigurator($this->container, $this->instanceof, \true, $this, $definition, $id, $defaults->getTags(), $this->path); return null !== $class ? $configurator->class($class) : $configurator; }
Registers a service. @param string|null $id The service id, or null to create an anonymous service @param string|null $class The class of the service, or null when $id is also the class name
set
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function remove(string $id) : static { $this->container->removeDefinition($id); $this->container->removeAlias($id); return $this; }
Removes an already defined service definition or alias. @return $this
remove
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function load(string $namespace, string $resource) : PrototypeConfigurator { return new PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, \true, $this->path); }
Registers a PSR-4 namespace using a glob pattern.
load
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function get(string $id) : ServiceConfigurator { $definition = $this->container->getDefinition($id); return new ServiceConfigurator($this->container, $definition->getInstanceofConditionals(), \true, $this, $definition, $id, []); }
Gets an already defined service definition. @throws ServiceNotFoundException if the service definition does not exist
get
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function stack(string $id, array $services) : AliasConfigurator { foreach ($services as $i => $service) { if ($service instanceof InlineServiceConfigurator) { $definition = $service->definition->setInstanceofConditionals($this->instanceof); $changes = $definition->getChanges(); $definition->setAutowired((isset($changes['autowired']) ? $definition : $this->defaults)->isAutowired()); $definition->setAutoconfigured((isset($changes['autoconfigured']) ? $definition : $this->defaults)->isAutoconfigured()); $definition->setBindings(\array_merge($this->defaults->getBindings(), $definition->getBindings())); $definition->setChanges($changes); $services[$i] = $definition; } elseif (!$service instanceof ReferenceConfigurator) { throw new InvalidArgumentException(\sprintf('"%s()" expects a list of definitions as returned by "%s()" or "%s()", "%s" given at index "%s" for service "%s".', __METHOD__, InlineServiceConfigurator::FACTORY, ReferenceConfigurator::FACTORY, $service instanceof AbstractConfigurator ? $service::FACTORY . '()' : \get_debug_type($service), $i, $id)); } } $alias = $this->alias($id, ''); $alias->definition = $this->set($id)->parent('')->args($services)->tag('container.stack')->definition; return $alias; }
Registers a stack of decorator services. @param InlineServiceConfigurator[]|ReferenceConfigurator[] $services
stack
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php
MIT
public final function abstract(bool $abstract = \true) : static { $this->definition->setAbstract($abstract); return $this; }
Whether this definition is abstract, that means it merely serves as a template for other definitions. @return $this
abstract
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/AbstractTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/AbstractTrait.php
MIT
public final function args(array $arguments) : static { $this->definition->setArguments(static::processValue($arguments, \true)); return $this; }
Sets the arguments to pass to the service constructor/factory method. @return $this
args
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ArgumentTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ArgumentTrait.php
MIT
public final function arg(string|int $key, mixed $value) : static { $this->definition->setArgument($key, static::processValue($value, \true)); return $this; }
Sets one argument to pass to the service constructor/factory method. @return $this
arg
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ArgumentTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ArgumentTrait.php
MIT
public final function autoconfigure(bool $autoconfigured = \true) : static { $this->definition->setAutoconfigured($autoconfigured); return $this; }
Sets whether or not instanceof conditionals should be prepended with a global set. @return $this @throws InvalidArgumentException when a parent is already set
autoconfigure
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/AutoconfigureTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/AutoconfigureTrait.php
MIT
public final function bind(string $nameOrFqcn, mixed $valueOrRef) : static { $valueOrRef = static::processValue($valueOrRef, \true); $bindings = $this->definition->getBindings(); $type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING); $bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, \true, $type, $this->path ?? null); $this->definition->setBindings($bindings); return $this; }
Sets bindings. Bindings map $named or FQCN arguments to values that should be injected in the matching parameters (of the constructor, of methods called and of controller actions). @param string $nameOrFqcn A parameter name with its "$" prefix, or an FQCN @param mixed $valueOrRef The value or reference to bind @return $this
bind
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php
MIT
public final function call(string $method, array $arguments = [], bool $returnsClone = \false) : static { $this->definition->addMethodCall($method, static::processValue($arguments, \true), $returnsClone); return $this; }
Adds a method to call after service initialization. @param string $method The method name to call @param array $arguments An array of arguments to pass to the method call @param bool $returnsClone Whether the call returns the service instance or not @return $this @throws InvalidArgumentException on empty $method param
call
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/CallTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/CallTrait.php
MIT
public final function class(?string $class) : static { $this->definition->setClass($class); return $this; }
Sets the service class. @return $this
class
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ClassTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ClassTrait.php
MIT
public final function configurator(string|array|ReferenceConfigurator $configurator) : static { $this->definition->setConfigurator(static::processValue($configurator, \true)); return $this; }
Sets a configurator to call after the service is fully initialized. @return $this
configurator
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ConfiguratorTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ConfiguratorTrait.php
MIT
public final function decorate(?string $id, ?string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : static { $this->definition->setDecoratedService($id, $renamedId, $priority, $invalidBehavior); return $this; }
Sets the service that this service is decorating. @param string|null $id The decorated service id, use null to remove decoration @return $this @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
decorate
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php
MIT
public final function deprecate(string $package, string $version, string $message) : static { $this->definition->setDeprecated($package, $version, $message); return $this; }
Whether this definition is deprecated, that means it should not be called anymore. @param string $package The name of the composer package that is triggering the deprecation @param string $version The version of the package that introduced the deprecation @param string $message The deprecation message to use @return $this @throws InvalidArgumentException when the message template is invalid
deprecate
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/DeprecateTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DeprecateTrait.php
MIT
public final function file(string $file) : static { $this->definition->setFile($file); return $this; }
Sets a file to require before creating the service. @return $this
file
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/FileTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/FileTrait.php
MIT
public final function lazy(bool|string $lazy = \true) : static { $this->definition->setLazy((bool) $lazy); if (\is_string($lazy)) { $this->definition->addTag('proxy', ['interface' => $lazy]); } return $this; }
Sets the lazy flag of this service. @param bool|string $lazy A FQCN to derivate the lazy proxy from or `true` to make it extend from the definition's class @return $this
lazy
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/LazyTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/LazyTrait.php
MIT
public final function parent(string $parent) : static { if (!$this->allowParent) { throw new InvalidArgumentException(\sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id)); } if ($this->definition instanceof ChildDefinition) { $this->definition->setParent($parent); } else { // cast Definition to ChildDefinition $definition = \serialize($this->definition); $definition = \substr_replace($definition, '70', 2, 2); $definition = \substr_replace($definition, 'Child', 61, 0); $definition = \unserialize($definition); $this->definition = $definition->setParent($parent); } return $this; }
Sets the Definition to inherit from. @return $this @throws InvalidArgumentException when parent cannot be set
parent
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php
MIT
public final function share(bool $shared = \true) : static { $this->definition->setShared($shared); return $this; }
Sets if the service must be shared or not. @return $this
share
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/ShareTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ShareTrait.php
MIT
public final function synthetic(bool $synthetic = \true) : static { $this->definition->setSynthetic($synthetic); return $this; }
Sets whether this definition is synthetic, that is not constructed by the container, but dynamically injected. @return $this
synthetic
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/SyntheticTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/SyntheticTrait.php
MIT
public final function tag(string $name, array $attributes = []) : static { if ('' === $name) { throw new InvalidArgumentException(\sprintf('The tag name for service "%s" must be a non-empty string.', $this->id)); } $this->validateAttributes($name, $attributes); $this->definition->addTag($name, $attributes); return $this; }
Adds a tag for this definition. @return $this
tag
php
deptrac/deptrac
vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php
MIT
public function getEnvPlaceholderUniquePrefix() : string { if (!isset($this->envPlaceholderUniquePrefix)) { $reproducibleEntropy = \unserialize(\serialize($this->parameters)); \array_walk_recursive($reproducibleEntropy, function (&$v) { $v = null; }); $this->envPlaceholderUniquePrefix = 'env_' . \substr(\hash('xxh128', \serialize($reproducibleEntropy)), -16); } return $this->envPlaceholderUniquePrefix; }
Gets the common env placeholder prefix for env vars created by this bag.
getEnvPlaceholderUniquePrefix
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
MIT
public function getEnvPlaceholders() : array { return $this->envPlaceholders; }
Returns the map of env vars used in the resolved parameter values to their placeholders. @return string[][] A map of env var names to their placeholders
getEnvPlaceholders
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
MIT
public function mergeEnvPlaceholders(self $bag) { if ($newPlaceholders = $bag->getEnvPlaceholders()) { $this->envPlaceholders += $newPlaceholders; foreach ($newPlaceholders as $env => $placeholders) { $this->envPlaceholders[$env] += $placeholders; } } if ($newUnusedPlaceholders = $bag->getUnusedEnvPlaceholders()) { $this->unusedEnvPlaceholders += $newUnusedPlaceholders; foreach ($newUnusedPlaceholders as $env => $placeholders) { $this->unusedEnvPlaceholders[$env] += $placeholders; } } }
Merges the env placeholders of another EnvPlaceholderParameterBag. @return void
mergeEnvPlaceholders
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
MIT
public function setProvidedTypes(array $providedTypes) { $this->providedTypes = $providedTypes; }
Maps env prefixes to their corresponding PHP types. @return void
setProvidedTypes
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
MIT
public function getProvidedTypes() : array { return $this->providedTypes; }
Gets the PHP types corresponding to env() parameter prefixes. @return string[][]
getProvidedTypes
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
MIT
public function __construct(array $parameters = [], protected array $deprecatedParameters = []) { $this->parameters = $parameters; $this->resolved = \true; }
For performance reasons, the constructor assumes that all keys are already lowercased. This is always the case when used internally.
__construct
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php
MIT
public function deprecate(string $name, string $package, string $version, string $message = 'The parameter "%s" is deprecated.') { if (!\array_key_exists($name, $this->parameters)) { throw new ParameterNotFoundException($name); } $this->deprecatedParameters[$name] = [$package, $version, $message, $name]; }
Deprecates a service container parameter. @return void @throws ParameterNotFoundException if the parameter is not defined
deprecate
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
MIT
public function resolveValue(mixed $value, array $resolving = []) : mixed { if (\is_array($value)) { $args = []; foreach ($value as $key => $v) { $resolvedKey = \is_string($key) ? $this->resolveValue($key, $resolving) : $key; if (!\is_scalar($resolvedKey) && !$resolvedKey instanceof \Stringable) { throw new RuntimeException(\sprintf('Array keys must be a scalar-value, but found key "%s" to resolve to type "%s".', $key, \get_debug_type($resolvedKey))); } $args[$resolvedKey] = $this->resolveValue($v, $resolving); } return $args; } if (!\is_string($value) || '' === $value || !\str_contains($value, '%')) { return $value; } return $this->resolveString($value, $resolving); }
Replaces parameter placeholders (%name%) by their values. @template TValue of array<array|scalar>|scalar @param TValue $value @param array $resolving An array of keys that are being resolved (used internally to detect circular references) @psalm-return (TValue is scalar ? array|scalar : array<array|scalar>) @throws ParameterNotFoundException if a placeholder references a parameter that does not exist @throws ParameterCircularReferenceException if a circular reference if detected @throws RuntimeException when a given parameter has a type problem
resolveValue
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
MIT
public function resolveString(string $value, array $resolving = []) : mixed { // we do this to deal with non string values (Boolean, integer, ...) // as the preg_replace_callback throw an exception when trying // a non-string in a parameter value if (\preg_match('/^%([^%\\s]+)%$/', $value, $match)) { $key = $match[1]; if (isset($resolving[$key])) { throw new ParameterCircularReferenceException(\array_keys($resolving)); } $resolving[$key] = \true; return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving); } return \preg_replace_callback('/%%|%([^%\\s]+)%/', function ($match) use($resolving, $value) { // skip %% if (!isset($match[1])) { return '%%'; } $key = $match[1]; if (isset($resolving[$key])) { throw new ParameterCircularReferenceException(\array_keys($resolving)); } $resolved = $this->get($key); if (!\is_string($resolved) && !\is_numeric($resolved)) { throw new RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \get_debug_type($resolved), $value)); } $resolved = (string) $resolved; $resolving[$key] = \true; return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving); }, $value); }
Resolves parameters inside a string. @param array $resolving An array of keys that are being resolved (used internally to detect circular references) @throws ParameterNotFoundException if a placeholder references a parameter that does not exist @throws ParameterCircularReferenceException if a circular reference if detected @throws RuntimeException when a given parameter has a type problem
resolveString
php
deptrac/deptrac
vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
MIT
function trigger_deprecation(string $package, string $version, string $message, mixed ...$args) : void { @\trigger_error(($package || $version ? "Since {$package} {$version}: " : '') . ($args ? \vsprintf($message, $args) : $message), \E_USER_DEPRECATED); }
Triggers a silenced deprecation notice. @param string $package The name of the Composer package that is triggering the deprecation @param string $version The version of the package that introduced the deprecation @param string $message The message of the deprecation @param mixed ...$args Values to insert in the message using printf() formatting @author Nicolas Grekas <[email protected]>
trigger_deprecation
php
deptrac/deptrac
vendor/symfony/deprecation-contracts/function.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/deprecation-contracts/function.php
MIT
protected function callListeners(iterable $listeners, string $eventName, object $event) { $stoppable = $event instanceof StoppableEventInterface; foreach ($listeners as $listener) { if ($stoppable && $event->isPropagationStopped()) { break; } $listener($event, $eventName, $this); } }
Triggers the listeners of an event. This method can be overridden to add functionality that is executed for each listener. @param callable[] $listeners The event listeners @param string $eventName The name of the event to dispatch @param object $event The event object to pass to the event handlers/listeners @return void
callListeners
php
deptrac/deptrac
vendor/symfony/event-dispatcher/EventDispatcher.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/EventDispatcher.php
MIT
private function sortListeners(string $eventName) : void { \krsort($this->listeners[$eventName]); $this->sorted[$eventName] = []; foreach ($this->listeners[$eventName] as &$listeners) { foreach ($listeners as &$listener) { if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure && 2 >= \count($listener)) { $listener[0] = $listener[0](); $listener[1] ??= '__invoke'; } $this->sorted[$eventName][] = $listener; } } }
Sorts the internal list of listeners for the given event by priority.
sortListeners
php
deptrac/deptrac
vendor/symfony/event-dispatcher/EventDispatcher.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/EventDispatcher.php
MIT
private function optimizeListeners(string $eventName) : array { \krsort($this->listeners[$eventName]); $this->optimized[$eventName] = []; foreach ($this->listeners[$eventName] as &$listeners) { foreach ($listeners as &$listener) { $closure =& $this->optimized[$eventName][]; if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure && 2 >= \count($listener)) { $closure = static function (...$args) use(&$listener, &$closure) { if ($listener[0] instanceof \Closure) { $listener[0] = $listener[0](); $listener[1] ??= '__invoke'; } ($closure = $listener(...))(...$args); }; } else { $closure = $listener instanceof WrappedListener ? $listener : $listener(...); } } } return $this->optimized[$eventName]; }
Optimizes the internal list of listeners for the given event by priority.
optimizeListeners
php
deptrac/deptrac
vendor/symfony/event-dispatcher/EventDispatcher.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/EventDispatcher.php
MIT
public function __construct(mixed $subject = null, array $arguments = []) { $this->subject = $subject; $this->arguments = $arguments; }
Encapsulate an event with $subject and $arguments. @param mixed $subject The subject of the event, usually an object or a callable @param array $arguments Arguments to store in the event
__construct
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT
public function getArgument(string $key) : mixed { if ($this->hasArgument($key)) { return $this->arguments[$key]; } throw new \InvalidArgumentException(\sprintf('Argument "%s" not found.', $key)); }
Get argument by key. @throws \InvalidArgumentException if key is not found
getArgument
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT
public function setArgument(string $key, mixed $value) : static { $this->arguments[$key] = $value; return $this; }
Add argument to event. @return $this
setArgument
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT
public function offsetGet(mixed $key) : mixed { return $this->getArgument($key); }
ArrayAccess for argument getter. @param string $key Array key @throws \InvalidArgumentException if key does not exist in $this->args
offsetGet
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT
public function offsetSet(mixed $key, mixed $value) : void { $this->setArgument($key, $value); }
ArrayAccess for argument setter. @param string $key Array key to set
offsetSet
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT
public function offsetUnset(mixed $key) : void { if ($this->hasArgument($key)) { unset($this->arguments[$key]); } }
ArrayAccess for unset argument. @param string $key Array key
offsetUnset
php
deptrac/deptrac
vendor/symfony/event-dispatcher/GenericEvent.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/event-dispatcher/GenericEvent.php
MIT