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 |
---|---|---|---|---|---|---|---|
public function registerForAutoconfiguration(string $interface) : ChildDefinition
{
if (!isset($this->autoconfiguredInstanceof[$interface])) {
$this->autoconfiguredInstanceof[$interface] = new ChildDefinition('');
}
return $this->autoconfiguredInstanceof[$interface];
}
|
Returns a ChildDefinition that will be used for autoconfiguring the interface/class.
|
registerForAutoconfiguration
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function registerAttributeForAutoconfiguration(string $attributeClass, callable $configurator) : void
{
$this->autoconfiguredAttributes[$attributeClass] = $configurator;
}
|
Registers an attribute that will be used for autoconfiguring annotated classes.
The third argument passed to the callable is the reflector of the
class/method/property/parameter that the attribute targets. Using one or many of
\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter as a type-hint
for this argument allows filtering which attributes should be passed to the callable.
@template T
@param class-string<T> $attributeClass
@param callable(ChildDefinition, T, \Reflector): void $configurator
|
registerAttributeForAutoconfiguration
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function registerAliasForArgument(string $id, string $type, ?string $name = null) : Alias
{
$parsedName = (new Target($name ??= $id))->getParsedName();
if (!\preg_match('/^[a-zA-Z_\\x7f-\\xff]/', $parsedName)) {
if ($id !== $name) {
$id = \sprintf(' for service "%s"', $id);
}
throw new InvalidArgumentException(\sprintf('Invalid argument name "%s"' . $id . ': the first character must be a letter.', $name));
}
if ($parsedName !== $name) {
$this->setAlias('.' . $type . ' $' . $name, $type . ' $' . $parsedName);
}
return $this->setAlias($type . ' $' . $parsedName, $id);
}
|
Registers an autowiring alias that only binds to a specific argument name.
The argument name is derived from $name if provided (from $id otherwise)
using camel case: "foo.bar" or "foo_bar" creates an alias bound to
"$fooBar"-named arguments with $type as type-hint. Such arguments will
receive the service $id when autowiring is used.
|
registerAliasForArgument
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function getAutoconfiguredInstanceof() : array
{
return $this->autoconfiguredInstanceof;
}
|
Returns an array of ChildDefinition[] keyed by interface.
@return array<string, ChildDefinition>
|
getAutoconfiguredInstanceof
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function resolveEnvPlaceholders(mixed $value, string|bool|null $format = null, ?array &$usedEnvs = null) : mixed
{
$bag = $this->getParameterBag();
if (\true === ($format ??= '%%env(%s)%%')) {
$value = $bag->resolveValue($value);
}
if ($value instanceof Definition) {
$value = (array) $value;
}
if (\is_array($value)) {
$result = [];
foreach ($value as $k => $v) {
$result[\is_string($k) ? $this->resolveEnvPlaceholders($k, $format, $usedEnvs) : $k] = $this->resolveEnvPlaceholders($v, $format, $usedEnvs);
}
return $result;
}
if (!\is_string($value) || 38 > \strlen($value) || \false === \stripos($value, 'env_')) {
return $value;
}
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
$completed = \false;
\preg_match_all('/env_[a-f0-9]{16}_\\w+_[a-f0-9]{32}/Ui', $value, $matches);
$usedPlaceholders = \array_flip($matches[0]);
foreach ($envPlaceholders as $env => $placeholders) {
foreach ($placeholders as $placeholder) {
if (isset($usedPlaceholders[$placeholder])) {
if (\true === $format) {
$resolved = $bag->escapeValue($this->getEnv($env));
} else {
$resolved = \sprintf($format, $env);
}
if ($placeholder === $value) {
$value = $resolved;
$completed = \true;
} else {
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 "env(%s)" of type "%s" inside string value "%s".', $env, \get_debug_type($resolved), $this->resolveEnvPlaceholders($value)));
}
$value = \str_ireplace($placeholder, $resolved, $value);
}
$usedEnvs[$env] = $env;
$this->envCounters[$env] = isset($this->envCounters[$env]) ? 1 + $this->envCounters[$env] : 1;
if ($completed) {
break 2;
}
}
}
}
return $value;
}
|
Resolves env parameter placeholders in a string or an array.
@param string|true|null $format A sprintf() format returning the replacement for each env var name or
null to resolve back to the original "%env(VAR)%" format or
true to resolve to the actual values of the referenced env vars
@param array &$usedEnvs Env vars found while resolving are added to this array
@return mixed The value with env parameters resolved if a string or an array is passed
|
resolveEnvPlaceholders
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function getEnvCounters() : array
{
$bag = $this->getParameterBag();
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
foreach ($envPlaceholders as $env => $placeholders) {
if (!isset($this->envCounters[$env])) {
$this->envCounters[$env] = 0;
}
}
return $this->envCounters;
}
|
Get statistics about env usage.
@return int[] The number of time each env vars has been resolved
|
getEnvCounters
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public static final function willBeAvailable(string $package, string $class, array $parentPackages) : bool
{
if (!\class_exists(InstalledVersions::class)) {
throw new \LogicException(\sprintf('Calling "%s" when dependencies have been installed with Composer 1 is not supported. Consider upgrading to Composer 2.', __METHOD__));
}
if (!\class_exists($class) && !\interface_exists($class, \false) && !\trait_exists($class, \false)) {
return \false;
}
if (!InstalledVersions::isInstalled($package) || InstalledVersions::isInstalled($package, \false)) {
return \true;
}
// the package is installed but in dev-mode only, check if this applies to one of the parent packages too
$rootPackage = InstalledVersions::getRootPackage()['name'] ?? '';
if ('symfony/symfony' === $rootPackage) {
return \true;
}
foreach ($parentPackages as $parentPackage) {
if ($rootPackage === $parentPackage || InstalledVersions::isInstalled($parentPackage) && !InstalledVersions::isInstalled($parentPackage, \false)) {
return \true;
}
}
return \false;
}
|
Checks whether a class is available and will remain available in the "no-dev" mode of Composer.
When parent packages are provided and if any of them is in dev-only mode,
the class will be considered available even if it is also in dev-only mode.
@throws \LogicException If dependencies have been installed with Composer 1
|
willBeAvailable
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function getRemovedBindingIds() : array
{
return $this->removedBindingIds;
}
|
Gets removed binding ids.
@return array<int, bool>
@internal
|
getRemovedBindingIds
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public static function hash(mixed $value) : string
{
$hash = \substr(\base64_encode(\hash('sha256', \serialize($value), \true)), 0, 7);
return \str_replace(['/', '+'], ['.', '_'], $hash);
}
|
Computes a reasonably unique hash of a serializable value.
|
hash
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ContainerBuilder.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ContainerBuilder.php
|
MIT
|
public function getChanges() : array
{
return $this->changes;
}
|
Returns all changes tracked for the Definition object.
|
getChanges
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setChanges(array $changes) : static
{
$this->changes = $changes;
return $this;
}
|
Sets the tracked changes for the Definition object.
@param array $changes An array of changes for this Definition
@return $this
|
setChanges
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setFactory(string|array|Reference|null $factory) : static
{
$this->changes['factory'] = \true;
if (\is_string($factory) && \str_contains($factory, '::')) {
$factory = \explode('::', $factory, 2);
} elseif ($factory instanceof Reference) {
$factory = [$factory, '__invoke'];
}
$this->factory = $factory;
return $this;
}
|
Sets a factory.
@param string|array|Reference|null $factory A PHP function, reference or an array containing a class/Reference and a method to call
@return $this
|
setFactory
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getFactory() : string|array|null
{
return $this->factory;
}
|
Gets the factory.
@return string|array|null The PHP function or an array containing a class/Reference and a method to call
|
getFactory
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setDecoratedService(?string $id, ?string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : static
{
if ($renamedId && $id === $renamedId) {
throw new InvalidArgumentException(\sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
}
$this->changes['decorated_service'] = \true;
if (null === $id) {
$this->decoratedService = null;
} else {
$this->decoratedService = [$id, $renamedId, $priority];
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
$this->decoratedService[] = $invalidBehavior;
}
}
return $this;
}
|
Sets the service that this service is decorating.
@param string|null $id The decorated service id, use null to remove decoration
@param string|null $renamedId The new decorated service id
@return $this
@throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
|
setDecoratedService
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getDecoratedService() : ?array
{
return $this->decoratedService;
}
|
Gets the service that this service is decorating.
@return array|null An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
|
getDecoratedService
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setClass(?string $class) : static
{
$this->changes['class'] = \true;
$this->class = $class;
return $this;
}
|
Sets the service class.
@return $this
|
setClass
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setArguments(array $arguments) : static
{
$this->arguments = $arguments;
return $this;
}
|
Sets the arguments to pass to the service constructor/factory method.
@return $this
|
setArguments
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setProperties(array $properties) : static
{
$this->properties = $properties;
return $this;
}
|
Sets the properties to define when creating the service.
@return $this
|
setProperties
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getProperties() : array
{
return $this->properties;
}
|
Gets the properties to define when creating the service.
|
getProperties
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function addArgument(mixed $argument) : static
{
$this->arguments[] = $argument;
return $this;
}
|
Adds an argument to pass to the service constructor/factory method.
@return $this
|
addArgument
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function replaceArgument(int|string $index, mixed $argument) : static
{
if (0 === \count($this->arguments)) {
throw new OutOfBoundsException(\sprintf('Cannot replace arguments for class "%s" if none have been configured yet.', $this->class));
}
if (\is_int($index) && ($index < 0 || $index > \count($this->arguments) - 1)) {
throw new OutOfBoundsException(\sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".', $index, \count($this->arguments) - 1, $this->class));
}
if (!\array_key_exists($index, $this->arguments)) {
throw new OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class));
}
$this->arguments[$index] = $argument;
return $this;
}
|
Replaces a specific argument.
@return $this
@throws OutOfBoundsException When the replaced argument does not exist
|
replaceArgument
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getArguments() : array
{
return $this->arguments;
}
|
Gets the arguments to pass to the service constructor/factory method.
|
getArguments
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getArgument(int|string $index) : mixed
{
if (!\array_key_exists($index, $this->arguments)) {
throw new OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class));
}
return $this->arguments[$index];
}
|
Gets an argument to pass to the service constructor/factory method.
@throws OutOfBoundsException When the argument does not exist
|
getArgument
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setMethodCalls(array $calls = []) : static
{
$this->calls = [];
foreach ($calls as $call) {
$this->addMethodCall($call[0], $call[1], $call[2] ?? \false);
}
return $this;
}
|
Sets the methods to call after service initialization.
@return $this
|
setMethodCalls
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function addMethodCall(string $method, array $arguments = [], bool $returnsClone = \false) : static
{
if (empty($method)) {
throw new InvalidArgumentException('Method name cannot be empty.');
}
$this->calls[] = $returnsClone ? [$method, $arguments, \true] : [$method, $arguments];
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
|
addMethodCall
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function removeMethodCall(string $method) : static
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
unset($this->calls[$i]);
}
}
return $this;
}
|
Removes a method to call after service initialization.
@return $this
|
removeMethodCall
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function hasMethodCall(string $method) : bool
{
foreach ($this->calls as $call) {
if ($call[0] === $method) {
return \true;
}
}
return \false;
}
|
Check if the current definition has a given method to call after service initialization.
|
hasMethodCall
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getMethodCalls() : array
{
return $this->calls;
}
|
Gets the methods to call after service initialization.
|
getMethodCalls
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setInstanceofConditionals(array $instanceof) : static
{
$this->instanceof = $instanceof;
return $this;
}
|
Sets the definition templates to conditionally apply on the current definition, keyed by parent interface/class.
@param ChildDefinition[] $instanceof
@return $this
|
setInstanceofConditionals
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getInstanceofConditionals() : array
{
return $this->instanceof;
}
|
Gets the definition templates to conditionally apply on the current definition, keyed by parent interface/class.
@return ChildDefinition[]
|
getInstanceofConditionals
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setAutoconfigured(bool $autoconfigured) : static
{
$this->changes['autoconfigured'] = \true;
$this->autoconfigured = $autoconfigured;
return $this;
}
|
Sets whether or not instanceof conditionals should be prepended with a global set.
@return $this
|
setAutoconfigured
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setTags(array $tags) : static
{
$this->tags = $tags;
return $this;
}
|
Sets tags for this definition.
@return $this
|
setTags
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function addTag(string $name, array $attributes = []) : static
{
$this->tags[$name][] = $attributes;
return $this;
}
|
Adds a tag for this definition.
@return $this
|
addTag
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function hasTag(string $name) : bool
{
return isset($this->tags[$name]);
}
|
Whether this definition has a tag with the given name.
|
hasTag
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function clearTag(string $name) : static
{
unset($this->tags[$name]);
return $this;
}
|
Clears all tags for a given name.
@return $this
|
clearTag
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function clearTags() : static
{
$this->tags = [];
return $this;
}
|
Clears the tags for this definition.
@return $this
|
clearTags
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setFile(?string $file) : static
{
$this->changes['file'] = \true;
$this->file = $file;
return $this;
}
|
Sets a file to require before creating the service.
@return $this
|
setFile
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getFile() : ?string
{
return $this->file;
}
|
Gets the file to require before creating the service.
|
getFile
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setShared(bool $shared) : static
{
$this->changes['shared'] = \true;
$this->shared = $shared;
return $this;
}
|
Sets if the service must be shared or not.
@return $this
|
setShared
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setPublic(bool $boolean) : static
{
$this->changes['public'] = \true;
$this->public = $boolean;
return $this;
}
|
Sets the visibility of this service.
@return $this
|
setPublic
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function isPublic() : bool
{
return $this->public;
}
|
Whether this service is public facing.
|
isPublic
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setLazy(bool $lazy) : static
{
$this->changes['lazy'] = \true;
$this->lazy = $lazy;
return $this;
}
|
Sets the lazy flag of this service.
@return $this
|
setLazy
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setSynthetic(bool $boolean) : static
{
$this->synthetic = $boolean;
if (!isset($this->changes['public'])) {
$this->setPublic(\true);
}
return $this;
}
|
Sets whether this definition is synthetic, that is not constructed by the
container, but dynamically injected.
@return $this
|
setSynthetic
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function isSynthetic() : bool
{
return $this->synthetic;
}
|
Whether this definition is synthetic, that is not constructed by the
container, but dynamically injected.
|
isSynthetic
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setAbstract(bool $boolean) : static
{
$this->abstract = $boolean;
return $this;
}
|
Whether this definition is abstract, that means it merely serves as a
template for other definitions.
@return $this
|
setAbstract
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function isAbstract() : bool
{
return $this->abstract;
}
|
Whether this definition is abstract, that means it merely serves as a
template for other definitions.
|
isAbstract
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setDeprecated(string $package, string $version, string $message) : static
{
if ('' !== $message) {
if (\preg_match('#[\\r\\n]|\\*/#', $message)) {
throw new InvalidArgumentException('Invalid characters found in deprecation template.');
}
if (!\str_contains($message, '%service_id%')) {
throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
}
}
$this->changes['deprecated'] = \true;
$this->deprecation = ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE];
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
|
setDeprecated
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function isDeprecated() : bool
{
return (bool) $this->deprecation;
}
|
Whether this definition is deprecated, that means it should not be called
anymore.
|
isDeprecated
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getDeprecation(string $id) : array
{
return ['package' => $this->deprecation['package'], 'version' => $this->deprecation['version'], 'message' => \str_replace('%service_id%', $id, $this->deprecation['message'])];
}
|
@param string $id Service id relying on this definition
|
getDeprecation
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setConfigurator(string|array|Reference|null $configurator) : static
{
$this->changes['configurator'] = \true;
if (\is_string($configurator) && \str_contains($configurator, '::')) {
$configurator = \explode('::', $configurator, 2);
} elseif ($configurator instanceof Reference) {
$configurator = [$configurator, '__invoke'];
}
$this->configurator = $configurator;
return $this;
}
|
Sets a configurator to call after the service is fully initialized.
@param string|array|Reference|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call
@return $this
|
setConfigurator
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getConfigurator() : string|array|null
{
return $this->configurator;
}
|
Gets the configurator to call after the service is fully initialized.
|
getConfigurator
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function setBindings(array $bindings) : static
{
foreach ($bindings as $key => $binding) {
if (0 < \strpos($key, '$') && $key !== ($k = \preg_replace('/[ \\t]*\\$/', ' $', $key))) {
unset($bindings[$key]);
$bindings[$key = $k] = $binding;
}
if (!$binding instanceof BoundArgument) {
$bindings[$key] = new BoundArgument($binding);
}
}
$this->bindings = $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).
@return $this
|
setBindings
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function addError(string|\Closure|self $error) : static
{
if ($error instanceof self) {
$this->errors = \array_merge($this->errors, $error->errors);
} else {
$this->errors[] = $error;
}
return $this;
}
|
Add an error that occurred when building this Definition.
@return $this
|
addError
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getErrors() : array
{
foreach ($this->errors as $i => $error) {
if ($error instanceof \Closure) {
$this->errors[$i] = (string) $error();
} elseif (!\is_string($error)) {
$this->errors[$i] = (string) $error;
}
}
return $this->errors;
}
|
Returns any errors that occurred while building this Definition.
|
getErrors
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Definition.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Definition.php
|
MIT
|
public function getInvalidBehavior() : int
{
return $this->invalidBehavior;
}
|
Returns the behavior to be used when the service does not exist.
|
getInvalidBehavior
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Reference.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Reference.php
|
MIT
|
public function getId(object $service) : ?string
{
if ($this->serviceContainer === $service) {
return 'service_container';
}
if (null === ($id = ($this->getServiceId)($service))) {
return null;
}
if ($this->serviceContainer->has($id) || $this->reversibleLocator->has($id)) {
return $id;
}
return null;
}
|
Returns the id of the passed object when it exists as a service.
To be reversible, services need to be either public or be tagged with "container.reversible".
|
getId
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ReverseContainer.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ReverseContainer.php
|
MIT
|
public function getService(string $id) : object
{
if ($this->reversibleLocator->has($id)) {
return $this->reversibleLocator->get($id);
}
if (isset($this->serviceContainer->getRemovedIds()[$id])) {
throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName));
}
return $this->serviceContainer->get($id);
}
|
@throws ServiceNotFoundException When the service is not reversible
|
getService
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/ReverseContainer.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/ReverseContainer.php
|
MIT
|
public function __construct(string $id, string $type, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, ?string $name = null, array $attributes = [])
{
$this->name = $type === $id ? $name : null;
parent::__construct($id, $invalidBehavior);
$this->type = $type;
$this->attributes = $attributes;
}
|
@param string $id The service identifier
@param string $type The PHP type of the identified service
@param int $invalidBehavior The behavior when the service does not exist
@param string|null $name The name of the argument targeting the service
@param array $attributes The attributes to be used
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/TypedReference.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/TypedReference.php
|
MIT
|
public function setValues(array $values)
{
foreach ($values as $k => $v) {
if (null !== $v && !$v instanceof Reference) {
throw new InvalidArgumentException(\sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \get_debug_type($v)));
}
}
$this->values = $values;
}
|
@param Reference[] $values The service references to put in the set
@return void
|
setValues
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php
|
MIT
|
public function __construct(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, bool $needsIndexes = \false, ?string $defaultPriorityMethod = null, array $exclude = [], bool $excludeSelf = \true)
{
parent::__construct([]);
if (null === $indexAttribute && $needsIndexes) {
$indexAttribute = \preg_match('/[^.]++$/', $tag, $m) ? $m[0] : $tag;
}
$this->tag = $tag;
$this->indexAttribute = $indexAttribute;
$this->defaultIndexMethod = $defaultIndexMethod ?: ($indexAttribute ? 'getDefault' . \str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $indexAttribute))) . 'Name' : null);
$this->needsIndexes = $needsIndexes;
$this->defaultPriorityMethod = $defaultPriorityMethod ?: ($indexAttribute ? 'getDefault' . \str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $indexAttribute))) . 'Priority' : null);
$this->exclude = $exclude;
$this->excludeSelf = $excludeSelf;
}
|
@param string $tag The name of the tag identifying the target services
@param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
@param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
@param bool $needsIndexes Whether indexes are required and should be generated when computing the map
@param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
@param array $exclude Services to exclude from the iterator
@param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php
|
MIT
|
public function __construct(string|array|ArgumentInterface|null $value = null, ?string $service = null, ?string $expression = null, ?string $env = null, ?string $param = null, bool|string|array $lazy = \false)
{
if ($this->lazy = \is_string($lazy) ? [$lazy] : $lazy) {
if (null !== ($expression ?? $env ?? $param)) {
throw new LogicException('#[Autowire] attribute cannot be $lazy and use $expression, $env, or $param.');
}
if (null !== $value && null !== $service) {
throw new LogicException('#[Autowire] attribute cannot declare $value and $service at the same time.');
}
} elseif (!(null !== $value xor null !== $service xor null !== $expression xor null !== $env xor null !== $param)) {
throw new LogicException('#[Autowire] attribute must declare exactly one of $service, $expression, $env, $param or $value.');
}
if (\is_string($value) && \str_starts_with($value, '@')) {
match (\true) {
\str_starts_with($value, '@@') => $value = \substr($value, 1),
\str_starts_with($value, '@=') => $expression = \substr($value, 2),
default => $service = \substr($value, 1),
};
}
$this->value = match (\true) {
null !== $service => new Reference($service),
null !== $expression => \class_exists(Expression::class) ? new Expression($expression) : throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'),
null !== $env => "%env({$env})%",
null !== $param => "%{$param}%",
default => $value,
};
}
|
Use only ONE of the following.
@param string|array|ArgumentInterface|null $value Value to inject (ie "%kernel.project_dir%/some/path")
@param string|null $service Service ID (ie "some.service")
@param string|null $expression Expression (ie 'service("some.service").someMethod()')
@param string|null $env Environment variable name (ie 'SOME_ENV_VARIABLE')
@param string|null $param Parameter name (ie 'some.parameter.name')
@param bool|class-string|class-string[] $lazy Whether to use lazy-loading for this argument
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Attribute/Autowire.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Attribute/Autowire.php
|
MIT
|
public function __construct(string|array|null $callable = null, ?string $service = null, ?string $method = null, bool|string $lazy = \false)
{
if (!(null !== $callable xor null !== $service)) {
throw new LogicException('#[AutowireCallable] attribute must declare exactly one of $callable or $service.');
}
if (null === $service && null !== $method) {
throw new LogicException('#[AutowireCallable] attribute cannot have a $method without a $service.');
}
parent::__construct($callable ?? [new Reference($service), $method ?? '__invoke'], lazy: $lazy);
}
|
@param bool|class-string $lazy Whether to use lazy-loading for this argument
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Attribute/AutowireCallable.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Attribute/AutowireCallable.php
|
MIT
|
public function __construct(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = \true)
{
parent::__construct(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \false, $defaultPriorityMethod, (array) $exclude, $excludeSelf));
}
|
@param string|string[] $exclude A service or a list of services to exclude
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Attribute/AutowireIterator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Attribute/AutowireIterator.php
|
MIT
|
public function __construct(string|array $services, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = \true)
{
if (\is_string($services)) {
parent::__construct(new ServiceLocatorArgument(new TaggedIteratorArgument($services, $indexAttribute, $defaultIndexMethod, \true, $defaultPriorityMethod, (array) $exclude, $excludeSelf)));
return;
}
$references = [];
foreach ($services as $key => $type) {
$attributes = [];
if ($type instanceof Autowire) {
$references[$key] = $type;
continue;
}
if ($type instanceof SubscribedService) {
$key = $type->key ?? $key;
$attributes = $type->attributes;
$type = ($type->nullable ? '?' : '') . ($type->type ?? throw new InvalidArgumentException(\sprintf('When "%s" is used, a type must be set.', SubscribedService::class)));
}
if (!\is_string($type) || !\preg_match('/(?(DEFINE)(?<cn>[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+))(?(DEFINE)(?<fqcn>(?&cn)(?:\\\\(?&cn))*+))^\\??(?&fqcn)(?:(?:\\|(?&fqcn))*+|(?:&(?&fqcn))*+)$/', $type)) {
throw new InvalidArgumentException(\sprintf('"%s" is not a PHP type for key "%s".', \is_string($type) ? $type : \get_debug_type($type), $key));
}
$optionalBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if ('?' === $type[0]) {
$type = \substr($type, 1);
$optionalBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
}
if (\is_int($name = $key)) {
$key = $type;
$name = null;
}
$references[$key] = new TypedReference($type, $type, $optionalBehavior, $name, $attributes);
}
parent::__construct(new ServiceLocatorArgument($references));
}
|
@see ServiceSubscriberInterface::getSubscribedServices()
@param string|array<string|Autowire|SubscribedService> $services An explicit list of services or a tag name
@param string|string[] $exclude A service or a list of services to exclude
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Attribute/AutowireLocator.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Attribute/AutowireLocator.php
|
MIT
|
protected function processValue(mixed $value, bool $isRoot = \false)
{
if (\is_array($value)) {
foreach ($value as $k => $v) {
if ((!$v || \is_scalar($v)) && $this->skipScalars) {
continue;
}
if ($isRoot) {
if ($v instanceof Definition && $v->hasTag('container.excluded')) {
continue;
}
$this->currentId = $k;
}
if ($v !== ($processedValue = $this->processValue($v, $isRoot))) {
$value[$k] = $processedValue;
}
}
} elseif ($value instanceof ArgumentInterface) {
$value->setValues($this->processValue($value->getValues()));
} elseif ($value instanceof Expression && $this->processExpressions) {
$this->getExpressionLanguage()->compile((string) $value, ['this' => 'container', 'args' => 'args']);
} elseif ($value instanceof Definition) {
$value->setArguments($this->processValue($value->getArguments()));
$value->setProperties($this->processValue($value->getProperties()));
$value->setMethodCalls($this->processValue($value->getMethodCalls()));
$changes = $value->getChanges();
if (isset($changes['factory'])) {
if (\is_string($factory = $value->getFactory()) && \str_starts_with($factory, '@=')) {
if (!\class_exists(Expression::class)) {
throw new LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".');
}
$factory = new Expression(\substr($factory, 2));
}
if (($factory = $this->processValue($factory)) instanceof Expression) {
$factory = '@=' . $factory;
}
$value->setFactory($factory);
}
if (isset($changes['configurator'])) {
$value->setConfigurator($this->processValue($value->getConfigurator()));
}
}
return $value;
}
|
Processes a value found in a definition tree.
@return mixed
|
processValue
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php
|
MIT
|
public function __construct(bool $onlyConstructorArguments = \false, bool $hasProxyDumper = \true)
{
$this->onlyConstructorArguments = $onlyConstructorArguments;
$this->hasProxyDumper = $hasProxyDumper;
$this->enableExpressionProcessing();
}
|
@param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
$this->container = $container;
$this->graph = $container->getCompiler()->getServiceReferenceGraph();
$this->graph->clear();
$this->lazy = \false;
$this->byConstructor = \false;
$this->byFactory = \false;
$this->definitions = $container->getDefinitions();
$this->aliases = $container->getAliases();
foreach ($this->aliases as $id => $alias) {
$targetId = $this->getDefinitionId((string) $alias);
$this->graph->connect($id, $alias, $targetId, null !== $targetId ? $this->container->getDefinition($targetId) : null, null);
}
try {
parent::process($container);
} finally {
$this->aliases = $this->definitions = [];
}
}
|
Processes a ContainerBuilder object to populate the service reference graph.
@return void
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php
|
MIT
|
private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, array $arguments, bool $checkAttributes, int $methodIndex) : array
{
$class = $reflectionMethod instanceof \ReflectionMethod ? $reflectionMethod->class : $this->currentId;
$method = $reflectionMethod->name;
$parameters = $reflectionMethod->getParameters();
if ($reflectionMethod->isVariadic()) {
\array_pop($parameters);
}
$this->defaultArgument->names = new \ArrayObject();
foreach ($parameters as $index => $parameter) {
$this->defaultArgument->names[$index] = $parameter->name;
if (\array_key_exists($parameter->name, $arguments)) {
$arguments[$index] = $arguments[$parameter->name];
unset($arguments[$parameter->name]);
}
if (\array_key_exists($index, $arguments) && '' !== $arguments[$index]) {
continue;
}
$type = ProxyHelper::exportType($parameter, \true);
$target = null;
$name = Target::parseName($parameter, $target);
$target = $target ? [$target] : [];
$getValue = function () use($type, $parameter, $class, $method, $name, $target) {
if (!($value = $this->getAutowiredReference($ref = new TypedReference($type, $type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $name, $target), \false))) {
$failureMessage = $this->createTypeNotFoundMessageCallback($ref, \sprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method));
if ($parameter->isDefaultValueAvailable()) {
$value = $this->defaultArgument->withValue($parameter);
} elseif (!$parameter->allowsNull()) {
throw new AutowiringFailedException($this->currentId, $failureMessage);
}
}
return $value;
};
if ($checkAttributes) {
foreach ($parameter->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
$attribute = $attribute->newInstance();
$invalidBehavior = $parameter->allowsNull() ? ContainerInterface::NULL_ON_INVALID_REFERENCE : ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE;
try {
$value = $this->processValue(new TypedReference($type ?: '?', $type ?: 'mixed', $invalidBehavior, $name, [$attribute, ...$target]));
} catch (ParameterNotFoundException $e) {
if (!$parameter->isDefaultValueAvailable()) {
throw new AutowiringFailedException($this->currentId, $e->getMessage(), 0, $e);
}
$arguments[$index] = clone $this->defaultArgument;
$arguments[$index]->value = $parameter->getDefaultValue();
continue 2;
}
if ($attribute instanceof AutowireCallable) {
$value = $attribute->buildDefinition($value, $type, $parameter);
} elseif ($lazy = $attribute->lazy) {
$definition = (new Definition($type))->setFactory('current')->setArguments([[$value ??= $getValue()]])->setLazy(\true);
if (!\is_array($lazy)) {
if (\str_contains($type, '|')) {
throw new AutowiringFailedException($this->currentId, \sprintf('Cannot use #[Autowire] with option "lazy: true" on union types for service "%s"; set the option to the interface(s) that should be proxied instead.', $this->currentId));
}
$lazy = \str_contains($type, '&') ? \explode('&', $type) : [];
}
if ($lazy) {
if (!\class_exists($type) && !\interface_exists($type, \false)) {
$definition->setClass('object');
}
foreach ($lazy as $v) {
$definition->addTag('proxy', ['interface' => $v]);
}
}
if ($definition->getClass() !== (string) $value || $definition->getTag('proxy')) {
$value .= '.' . $this->container->hash([$definition->getClass(), $definition->getTag('proxy')]);
}
$this->container->setDefinition($value = '.lazy.' . $value, $definition);
$value = new Reference($value);
}
$arguments[$index] = $value;
continue 2;
}
foreach ($parameter->getAttributes(AutowireDecorated::class) as $attribute) {
$arguments[$index] = $this->processValue($attribute->newInstance());
continue 2;
}
foreach ($parameter->getAttributes(MapDecorated::class) as $attribute) {
$arguments[$index] = $this->processValue($attribute->newInstance());
continue 2;
}
}
if (!$type) {
if (isset($arguments[$index])) {
continue;
}
// no default value? Then fail
if (!$parameter->isDefaultValueAvailable()) {
// For core classes, isDefaultValueAvailable() can
// be false when isOptional() returns true. If the
// argument *is* optional, allow it to be missing
if ($parameter->isOptional()) {
--$index;
break;
}
$type = ProxyHelper::exportType($parameter);
$type = $type ? \sprintf('is type-hinted "%s"', \preg_replace('/(^|[(|&])\\\\|^\\?\\\\?/', '\\1', $type)) : 'has no type-hint';
throw new AutowiringFailedException($this->currentId, \sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" %s, you should configure its value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method, $type));
}
// specifically pass the default value
$arguments[$index] = $this->defaultArgument->withValue($parameter);
continue;
}
if ($this->decoratedClass && \is_a($this->decoratedClass, $type, \true)) {
if ($this->getPreviousValue) {
// The inner service is injected only if there is only 1 argument matching the type of the decorated class
// across all arguments of all autowired methods.
// If a second matching argument is found, the default behavior is restored.
$getPreviousValue = $this->getPreviousValue;
$this->methodCalls[$this->decoratedMethodIndex][1][$this->decoratedMethodArgumentIndex] = $getPreviousValue();
$this->decoratedClass = null;
// Prevent further checks
} else {
$arguments[$index] = new TypedReference($this->decoratedId, $this->decoratedClass);
$this->getPreviousValue = $getValue;
$this->decoratedMethodIndex = $methodIndex;
$this->decoratedMethodArgumentIndex = $index;
continue;
}
}
$arguments[$index] = $getValue();
}
if ($parameters && !isset($arguments[++$index])) {
while (0 <= --$index) {
if (!$arguments[$index] instanceof $this->defaultArgument) {
break;
}
unset($arguments[$index]);
}
}
// it's possible index 1 was set, then index 0, then 2, etc
// make sure that we re-order so they're injected as expected
\ksort($arguments, \SORT_NATURAL);
return $arguments;
}
|
Autowires the constructor or a method.
@throws AutowiringFailedException
|
autowireMethod
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
MIT
|
private function getAutowiredReference(TypedReference $reference, bool $filterType) : ?TypedReference
{
$this->lastFailure = null;
$type = $reference->getType();
if ($type !== (string) $reference) {
return $reference;
}
if ($filterType && \false !== ($m = \strpbrk($type, '&|'))) {
$types = \array_diff(\explode($m[0], $type), ['int', 'string', 'array', 'bool', 'float', 'iterable', 'object', 'callable', 'null']);
\sort($types);
$type = \implode($m[0], $types);
}
$name = $target = (\array_filter($reference->getAttributes(), static fn($a) => $a instanceof Target)[0] ?? null)?->name;
if (null !== ($name ??= $reference->getName())) {
if ($this->container->has($alias = $type . ' $' . $name) && !$this->container->findDefinition($alias)->isAbstract()) {
return new TypedReference($alias, $type, $reference->getInvalidBehavior());
}
if (null !== ($alias = $this->getCombinedAlias($type, $name)) && !$this->container->findDefinition($alias)->isAbstract()) {
return new TypedReference($alias, $type, $reference->getInvalidBehavior());
}
$parsedName = (new Target($name))->getParsedName();
if ($this->container->has($alias = $type . ' $' . $parsedName) && !$this->container->findDefinition($alias)->isAbstract()) {
return new TypedReference($alias, $type, $reference->getInvalidBehavior());
}
if (null !== ($alias = $this->getCombinedAlias($type, $parsedName)) && !$this->container->findDefinition($alias)->isAbstract()) {
return new TypedReference($alias, $type, $reference->getInvalidBehavior());
}
if ($this->container->has($n = $name) && !$this->container->findDefinition($n)->isAbstract() || $this->container->has($n = $parsedName) && !$this->container->findDefinition($n)->isAbstract()) {
foreach ($this->container->getAliases() as $id => $alias) {
if ($n === (string) $alias && \str_starts_with($id, $type . ' $')) {
return new TypedReference($n, $type, $reference->getInvalidBehavior());
}
}
}
if (null !== $target) {
return null;
}
}
if ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract()) {
return new TypedReference($type, $type, $reference->getInvalidBehavior());
}
if (null !== ($alias = $this->getCombinedAlias($type)) && !$this->container->findDefinition($alias)->isAbstract()) {
return new TypedReference($alias, $type, $reference->getInvalidBehavior());
}
return null;
}
|
Returns a reference to the service matching the given type, if any.
|
getAutowiredReference
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
MIT
|
private function populateAvailableTypes(ContainerBuilder $container) : void
{
$this->types = [];
$this->ambiguousServiceTypes = [];
$this->autowiringAliases = [];
foreach ($container->getDefinitions() as $id => $definition) {
$this->populateAvailableType($container, $id, $definition);
}
$prev = null;
foreach ($container->getAliases() as $id => $alias) {
$this->populateAutowiringAlias($id, $prev);
$prev = $id;
}
}
|
Populates the list of available types.
|
populateAvailableTypes
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
MIT
|
private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition) : void
{
// Never use abstract services
if ($definition->isAbstract()) {
return;
}
if ('' === $id || '.' === $id[0] || $definition->isDeprecated() || !($reflectionClass = $container->getReflectionClass($definition->getClass(), \false))) {
return;
}
foreach ($reflectionClass->getInterfaces() as $reflectionInterface) {
$this->set($reflectionInterface->name, $id);
}
do {
$this->set($reflectionClass->name, $id);
} while ($reflectionClass = $reflectionClass->getParentClass());
$this->populateAutowiringAlias($id);
}
|
Populates the list of available types for a given definition.
|
populateAvailableType
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
MIT
|
private function set(string $type, string $id) : void
{
// is this already a type/class that is known to match multiple services?
if (isset($this->ambiguousServiceTypes[$type])) {
$this->ambiguousServiceTypes[$type][] = $id;
return;
}
// check to make sure the type doesn't match multiple services
if (!isset($this->types[$type]) || $this->types[$type] === $id) {
$this->types[$type] = $id;
return;
}
// keep an array of all services matching this type
if (!isset($this->ambiguousServiceTypes[$type])) {
$this->ambiguousServiceTypes[$type] = [$this->types[$type]];
unset($this->types[$type]);
}
$this->ambiguousServiceTypes[$type][] = $id;
}
|
Associates a type and a service id if applicable.
|
set
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
$graph = $container->getCompiler()->getServiceReferenceGraph();
$this->checkedNodes = [];
foreach ($graph->getNodes() as $id => $node) {
$this->currentPath = [$id];
$this->checkOutEdges($node->getOutEdges());
}
}
|
Checks the ContainerBuilder object for circular references.
@return void
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php
|
MIT
|
private function checkOutEdges(array $edges) : void
{
foreach ($edges as $edge) {
$node = $edge->getDestNode();
$id = $node->getId();
if (empty($this->checkedNodes[$id])) {
// Don't check circular references for lazy edges
if (!$node->getValue() || !$edge->isLazy() && !$edge->isWeak()) {
$searchKey = \array_search($id, $this->currentPath);
$this->currentPath[] = $id;
if (\false !== $searchKey) {
throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey));
}
$this->checkOutEdges($node->getOutEdges());
}
$this->checkedNodes[$id] = \true;
\array_pop($this->currentPath);
}
}
}
|
Checks for circular references.
@param ServiceReferenceGraphEdge[] $edges An array of Edges
@throws ServiceCircularReferenceException when a circular reference is found
|
checkOutEdges
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {
// synthetic service is public
if ($definition->isSynthetic() && !$definition->isPublic()) {
throw new RuntimeException(\sprintf('A synthetic service ("%s") must be public.', $id));
}
// non-synthetic, non-abstract service has class
if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass() && !$definition->hasTag('container.service_locator') && (!$definition->getFactory() || !\preg_match(FileLoader::ANONYMOUS_ID_REGEXP, $id))) {
if ($definition->getFactory()) {
throw new RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id));
}
if (\class_exists($id) || \interface_exists($id, \false)) {
if (\str_starts_with($id, '\\') && 1 < \substr_count($id, '\\')) {
throw new RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, \substr($id, 1)));
}
throw new RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id));
}
throw new RuntimeException(\sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id));
}
// tag attribute values must be scalars
foreach ($definition->getTags() as $name => $tags) {
foreach ($tags as $attributes) {
$this->validateAttributes($id, $name, $attributes);
}
}
if ($definition->isPublic() && !$definition->isPrivate()) {
$resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs);
if (null !== $usedEnvs) {
throw new EnvParameterException([$resolvedId], null, 'A service name ("%s") cannot contain dynamic values.');
}
}
}
foreach ($container->getAliases() as $id => $alias) {
if ($alias->isPublic() && !$alias->isPrivate()) {
$resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs);
if (null !== $usedEnvs) {
throw new EnvParameterException([$resolvedId], null, 'An alias name ("%s") cannot contain dynamic values.');
}
}
}
}
|
Processes the ContainerBuilder to validate the Definition.
@return void
@throws RuntimeException When the Definition is invalid
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php
|
MIT
|
public function __construct(bool $autoload = \false, array $skippedIds = [])
{
$this->autoload = $autoload;
$this->skippedIds = $skippedIds;
}
|
@param bool $autoload Whether services who's class in not loaded should be checked or not.
Defaults to false to save loading code during compilation.
@param array $skippedIds An array indexed by the service ids to skip
|
__construct
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
MIT
|
private function checkTypeDeclarations(Definition $checkedDefinition, \ReflectionFunctionAbstract $reflectionFunction, array $values) : void
{
$numberOfRequiredParameters = $reflectionFunction->getNumberOfRequiredParameters();
if (\count($values) < $numberOfRequiredParameters) {
throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": "%s::%s()" requires %d arguments, %d passed.', $this->currentId, $reflectionFunction->class, $reflectionFunction->name, $numberOfRequiredParameters, \count($values)));
}
$reflectionParameters = $reflectionFunction->getParameters();
$checksCount = \min($reflectionFunction->getNumberOfParameters(), \count($values));
$envPlaceholderUniquePrefix = $this->container->getParameterBag() instanceof EnvPlaceholderParameterBag ? $this->container->getParameterBag()->getEnvPlaceholderUniquePrefix() : null;
for ($i = 0; $i < $checksCount; ++$i) {
$p = $reflectionParameters[$i];
if (!$p->hasType() || $p->isVariadic()) {
continue;
}
if (\array_key_exists($p->name, $values)) {
$i = $p->name;
} elseif (!\array_key_exists($i, $values)) {
continue;
}
$this->checkType($checkedDefinition, $values[$i], $p, $envPlaceholderUniquePrefix);
}
if ($reflectionFunction->isVariadic() && ($lastParameter = \end($reflectionParameters))->hasType()) {
$variadicParameters = \array_slice($values, $lastParameter->getPosition());
foreach ($variadicParameters as $variadicParameter) {
$this->checkType($checkedDefinition, $variadicParameter, $lastParameter, $envPlaceholderUniquePrefix);
}
}
}
|
@throws InvalidArgumentException When not enough parameters are defined for the method
|
checkTypeDeclarations
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
MIT
|
private function checkType(Definition $checkedDefinition, mixed $value, \ReflectionParameter $parameter, ?string $envPlaceholderUniquePrefix, ?\ReflectionType $reflectionType = null) : void
{
$reflectionType ??= $parameter->getType();
if ($reflectionType instanceof \ReflectionUnionType) {
foreach ($reflectionType->getTypes() as $t) {
try {
$this->checkType($checkedDefinition, $value, $parameter, $envPlaceholderUniquePrefix, $t);
return;
} catch (InvalidParameterTypeException $e) {
}
}
throw new InvalidParameterTypeException($this->currentId, $e->getCode(), $parameter);
}
if ($reflectionType instanceof \ReflectionIntersectionType) {
foreach ($reflectionType->getTypes() as $t) {
$this->checkType($checkedDefinition, $value, $parameter, $envPlaceholderUniquePrefix, $t);
}
return;
}
if (!$reflectionType instanceof \ReflectionNamedType) {
return;
}
$type = $reflectionType->getName();
if ($value instanceof Reference) {
if (!$this->container->has($value = (string) $value)) {
return;
}
if ('service_container' === $value && \is_a($type, Container::class, \true)) {
return;
}
$value = $this->container->findDefinition($value);
}
if ('self' === $type) {
$type = $parameter->getDeclaringClass()->getName();
}
if ('static' === $type) {
$type = $checkedDefinition->getClass();
}
$class = null;
if ($value instanceof Definition) {
if ($value->hasErrors() || $value->getFactory()) {
return;
}
$class = $value->getClass();
if ($class && isset(self::BUILTIN_TYPES[\strtolower($class)])) {
$class = \strtolower($class);
} elseif (!$class || !$this->autoload && !\class_exists($class, \false) && !\interface_exists($class, \false)) {
return;
}
} elseif ($value instanceof Parameter) {
$value = $this->container->getParameter($value);
} elseif ($value instanceof Expression) {
try {
$value = $this->getExpressionLanguage()->evaluate($value, ['container' => $this->container]);
} catch (\Exception) {
// If a service from the expression cannot be fetched from the container, we skip the validation.
return;
}
} elseif (\is_string($value)) {
if ('%' === ($value[0] ?? '') && \preg_match('/^%([^%]+)%$/', $value, $match)) {
$value = $this->container->getParameter(\substr($value, 1, -1));
}
if ($envPlaceholderUniquePrefix && \is_string($value) && \str_contains($value, 'env_')) {
// If the value is an env placeholder that is either mixed with a string or with another env placeholder, then its resolved value will always be a string, so we don't need to resolve it.
// We don't need to change the value because it is already a string.
if ('' === \preg_replace('/' . $envPlaceholderUniquePrefix . '_\\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) {
try {
$value = $this->container->resolveEnvPlaceholders($value, \true);
} catch (\Exception) {
// If an env placeholder cannot be resolved, we skip the validation.
return;
}
}
}
}
if (null === $value && $parameter->allowsNull()) {
return;
}
if (null === $class) {
if ($value instanceof IteratorArgument) {
$class = RewindableGenerator::class;
} elseif ($value instanceof ServiceClosureArgument) {
$class = \Closure::class;
} elseif ($value instanceof ServiceLocatorArgument) {
$class = ServiceLocator::class;
} elseif (\is_object($value)) {
$class = $value::class;
} else {
$class = \gettype($value);
$class = ['integer' => 'int', 'double' => 'float', 'boolean' => 'bool'][$class] ?? $class;
}
}
if (isset(self::SCALAR_TYPES[$type]) && isset(self::SCALAR_TYPES[$class])) {
return;
}
if ('string' === $type && \method_exists($class, '__toString')) {
return;
}
if ('callable' === $type && (\Closure::class === $class || \method_exists($class, '__invoke'))) {
return;
}
if ('callable' === $type && \is_array($value) && isset($value[0]) && ($value[0] instanceof Reference || $value[0] instanceof Definition || \is_string($value[0]))) {
return;
}
if ('iterable' === $type && (\is_array($value) || 'array' === $class || \is_subclass_of($class, \Traversable::class))) {
return;
}
if ($type === $class) {
return;
}
if ('object' === $type && !isset(self::BUILTIN_TYPES[$class])) {
return;
}
if ('mixed' === $type) {
return;
}
if (\is_a($class, $type, \true)) {
return;
}
if ('false' === $type) {
if (\false === $value) {
return;
}
} elseif ('true' === $type) {
if (\true === $value) {
return;
}
} elseif ($reflectionType->isBuiltin()) {
$checkFunction = \sprintf('is_%s', $type);
if ($checkFunction($value)) {
return;
}
}
throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : \get_debug_type($value), $parameter);
}
|
@throws InvalidParameterTypeException When a parameter is not compatible with the declared type
|
checkType
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php
|
MIT
|
public function compile(ContainerBuilder $container)
{
try {
foreach ($this->passConfig->getPasses() as $pass) {
$pass->process($container);
}
} catch (\Exception $e) {
$usedEnvs = [];
$prev = $e;
do {
$msg = $prev->getMessage();
if ($msg !== ($resolvedMsg = $container->resolveEnvPlaceholders($msg, null, $usedEnvs))) {
$r = new \ReflectionProperty($prev, 'message');
$r->setValue($prev, $resolvedMsg);
}
} while ($prev = $prev->getPrevious());
if ($usedEnvs) {
$e = new EnvParameterException($usedEnvs, $e);
}
throw $e;
} finally {
$this->getServiceReferenceGraph()->clear();
}
}
|
Run the Compiler and process all Passes.
@return void
|
compile
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/Compiler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/Compiler.php
|
MIT
|
private function isInlineableDefinition(string $id, Definition $definition) : bool
{
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic() || $definition->hasTag('container.do_not_inline')) {
return \false;
}
if (!$definition->isShared()) {
if (!$this->graph->hasNode($id)) {
return \true;
}
foreach ($this->graph->getNode($id)->getInEdges() as $edge) {
$srcId = $edge->getSourceNode()->getId();
$this->connectedIds[$srcId] = \true;
if ($edge->isWeak() || $edge->isLazy()) {
return !($this->connectedIds[$id] = \true);
}
}
return \true;
}
if ($definition->isPublic()) {
return \false;
}
if (!$this->graph->hasNode($id)) {
return \true;
}
if ($this->currentId === $id) {
return \false;
}
$this->connectedIds[$id] = \true;
$srcIds = [];
$srcCount = 0;
foreach ($this->graph->getNode($id)->getInEdges() as $edge) {
$srcId = $edge->getSourceNode()->getId();
$this->connectedIds[$srcId] = \true;
if ($edge->isWeak() || $edge->isLazy()) {
return \false;
}
$srcIds[$srcId] = \true;
++$srcCount;
}
if (1 !== \count($srcIds)) {
$this->notInlinedIds[$id] = \true;
return \false;
}
if ($srcCount > 1 && \is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) {
return \false;
}
return $this->container->getDefinition($srcId)->isShared();
}
|
Checks if the definition is inlineable.
|
isInlineableDefinition
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php
|
MIT
|
public function getPasses() : array
{
return \array_merge([$this->mergePass], $this->getBeforeOptimizationPasses(), $this->getOptimizationPasses(), $this->getBeforeRemovingPasses(), $this->getRemovingPasses(), $this->getAfterRemovingPasses());
}
|
Returns all passes in order to be processed.
@return CompilerPassInterface[]
|
getPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function addPass(CompilerPassInterface $pass, string $type = self::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
{
$property = $type . 'Passes';
if (!isset($this->{$property})) {
throw new InvalidArgumentException(\sprintf('Invalid type "%s".', $type));
}
$passes =& $this->{$property};
if (!isset($passes[$priority])) {
$passes[$priority] = [];
}
$passes[$priority][] = $pass;
}
|
Adds a pass.
@return void
@throws InvalidArgumentException when a pass type doesn't exist
|
addPass
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function getAfterRemovingPasses() : array
{
return $this->sortPasses($this->afterRemovingPasses);
}
|
Gets all passes for the AfterRemoving pass.
@return CompilerPassInterface[]
|
getAfterRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function getBeforeOptimizationPasses() : array
{
return $this->sortPasses($this->beforeOptimizationPasses);
}
|
Gets all passes for the BeforeOptimization pass.
@return CompilerPassInterface[]
|
getBeforeOptimizationPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function getBeforeRemovingPasses() : array
{
return $this->sortPasses($this->beforeRemovingPasses);
}
|
Gets all passes for the BeforeRemoving pass.
@return CompilerPassInterface[]
|
getBeforeRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function getOptimizationPasses() : array
{
return $this->sortPasses($this->optimizationPasses);
}
|
Gets all passes for the Optimization pass.
@return CompilerPassInterface[]
|
getOptimizationPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function getRemovingPasses() : array
{
return $this->sortPasses($this->removingPasses);
}
|
Gets all passes for the Removing pass.
@return CompilerPassInterface[]
|
getRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function setAfterRemovingPasses(array $passes)
{
$this->afterRemovingPasses = [$passes];
}
|
Sets the AfterRemoving passes.
@param CompilerPassInterface[] $passes
@return void
|
setAfterRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function setBeforeOptimizationPasses(array $passes)
{
$this->beforeOptimizationPasses = [$passes];
}
|
Sets the BeforeOptimization passes.
@param CompilerPassInterface[] $passes
@return void
|
setBeforeOptimizationPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function setBeforeRemovingPasses(array $passes)
{
$this->beforeRemovingPasses = [$passes];
}
|
Sets the BeforeRemoving passes.
@param CompilerPassInterface[] $passes
@return void
|
setBeforeRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function setOptimizationPasses(array $passes)
{
$this->optimizationPasses = [$passes];
}
|
Sets the Optimization passes.
@param CompilerPassInterface[] $passes
@return void
|
setOptimizationPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
public function setRemovingPasses(array $passes)
{
$this->removingPasses = [$passes];
}
|
Sets the Removing passes.
@param CompilerPassInterface[] $passes
@return void
|
setRemovingPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
private function sortPasses(array $passes) : array
{
if (0 === \count($passes)) {
return [];
}
\krsort($passes);
// Flatten the array
return \array_merge(...$passes);
}
|
Sort passes by priority.
@param array $passes CompilerPassInterface instances with their priority as key
@return CompilerPassInterface[]
|
sortPasses
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PassConfig.php
|
MIT
|
private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagName, ContainerBuilder $container, array $exclude = []) : array
{
$indexAttribute = $defaultIndexMethod = $needsIndexes = $defaultPriorityMethod = null;
if ($tagName instanceof TaggedIteratorArgument) {
$indexAttribute = $tagName->getIndexAttribute();
$defaultIndexMethod = $tagName->getDefaultIndexMethod();
$needsIndexes = $tagName->needsIndexes();
$defaultPriorityMethod = $tagName->getDefaultPriorityMethod() ?? 'getDefaultPriority';
$exclude = \array_merge($exclude, $tagName->getExclude());
$tagName = $tagName->getTag();
}
$i = 0;
$services = [];
foreach ($container->findTaggedServiceIds($tagName, \true) as $serviceId => $attributes) {
if (\in_array($serviceId, $exclude, \true)) {
continue;
}
$defaultPriority = null;
$defaultIndex = null;
$definition = $container->getDefinition($serviceId);
$class = $definition->getClass();
$class = $container->getParameterBag()->resolveValue($class) ?: null;
$checkTaggedItem = !$definition->hasTag($definition->isAutoconfigured() ? 'container.ignore_attributes' : $tagName);
foreach ($attributes as $attribute) {
$index = $priority = null;
if (isset($attribute['priority'])) {
$priority = $attribute['priority'];
} elseif (null === $defaultPriority && $defaultPriorityMethod && $class) {
$defaultPriority = PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultPriorityMethod, $tagName, 'priority', $checkTaggedItem);
}
$priority ??= $defaultPriority ??= 0;
if (null === $indexAttribute && !$defaultIndexMethod && !$needsIndexes) {
$services[] = [$priority, ++$i, null, $serviceId, null];
continue 2;
}
if (null !== $indexAttribute && isset($attribute[$indexAttribute])) {
$index = $attribute[$indexAttribute];
} elseif (null === $defaultIndex && $defaultPriorityMethod && $class) {
$defaultIndex = PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultIndexMethod ?? 'getDefaultName', $tagName, $indexAttribute, $checkTaggedItem);
}
$decorated = $definition->getTag('container.decorator')[0]['id'] ?? null;
$index = $index ?? $defaultIndex ?? ($defaultIndex = $decorated ?? $serviceId);
$services[] = [$priority, ++$i, $index, $serviceId, $class];
}
}
\uasort($services, static fn($a, $b) => $b[0] <=> $a[0] ?: $a[1] <=> $b[1]);
$refs = [];
foreach ($services as [, , $index, $serviceId, $class]) {
if (!$class) {
$reference = new Reference($serviceId);
} elseif ($index === $serviceId) {
$reference = new TypedReference($serviceId, $class);
} else {
$reference = new TypedReference($serviceId, $class, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $index);
}
if (null === $index) {
$refs[] = $reference;
} else {
$refs[$index] = $reference;
}
}
return $refs;
}
|
Finds all services with the given tag name and order them by their priority.
The order of additions must be respected for services having the same priority,
and knowing that the \SplPriorityQueue class does not respect the FIFO method,
we should not use that class.
@see https://bugs.php.net/53710
@see https://bugs.php.net/60926
@return Reference[]
|
findAndSortTaggedServices
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php
|
MIT
|
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isAbstract()) {
$container->removeDefinition($id);
$container->log($this, \sprintf('Removed service "%s"; reason: abstract.', $id));
}
}
}
|
Removes abstract definitions from the ContainerBuilder.
@return void
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
foreach ($container->getAliases() as $id => $alias) {
if ($alias->isPublic()) {
continue;
}
$container->removeAlias($id);
$container->log($this, \sprintf('Removed service "%s"; reason: private alias.', $id));
}
}
|
Removes private aliases from the ContainerBuilder.
@return void
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
try {
$this->enableExpressionProcessing();
$this->container = $container;
$connectedIds = [];
$aliases = $container->getAliases();
foreach ($aliases as $id => $alias) {
if ($alias->isPublic()) {
$this->connectedIds[] = (string) $aliases[$id];
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isPublic()) {
$connectedIds[$id] = \true;
$this->processValue($definition);
}
}
while ($this->connectedIds) {
$ids = $this->connectedIds;
$this->connectedIds = [];
foreach ($ids as $id) {
if (!isset($connectedIds[$id]) && $container->hasDefinition($id)) {
$connectedIds[$id] = \true;
$this->processValue($container->getDefinition($id));
}
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if (!isset($connectedIds[$id])) {
$container->removeDefinition($id);
$container->resolveEnvPlaceholders(!$definition->hasErrors() ? \serialize($definition) : $definition);
$container->log($this, \sprintf('Removed service "%s"; reason: unused.', $id));
}
}
} finally {
$this->container = null;
$this->connectedIds = [];
}
}
|
Processes the ContainerBuilder to remove unused definitions.
@return void
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
// First collect all alias targets that need to be replaced
$seenAliasTargets = [];
$replacements = [];
foreach ($container->getAliases() as $definitionId => $target) {
$targetId = (string) $target;
// Special case: leave this target alone
if ('service_container' === $targetId) {
continue;
}
// Check if target needs to be replaced
if (isset($replacements[$targetId])) {
$container->setAlias($definitionId, $replacements[$targetId])->setPublic($target->isPublic());
if ($target->isDeprecated()) {
$container->getAlias($definitionId)->setDeprecated(...\array_values($target->getDeprecation('%alias_id%')));
}
}
// No need to process the same target twice
if (isset($seenAliasTargets[$targetId])) {
continue;
}
// Process new target
$seenAliasTargets[$targetId] = \true;
try {
$definition = $container->getDefinition($targetId);
} catch (ServiceNotFoundException $e) {
if ('' !== $e->getId() && '@' === $e->getId()[0]) {
throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [\substr($e->getId(), 1)]);
}
throw $e;
}
if ($definition->isPublic()) {
continue;
}
// Remove private definition and schedule for replacement
$definition->setPublic($target->isPublic());
$container->setDefinition($definitionId, $definition);
$container->removeDefinition($targetId);
$replacements[$targetId] = $definitionId;
if ($target->isPublic() && $target->isDeprecated()) {
$definition->addTag('container.private', $target->getDeprecation('%service_id%'));
}
}
$this->replacements = $replacements;
parent::process($container);
$this->replacements = [];
}
|
Process the Container to replace aliases with service definitions.
@return void
@throws InvalidArgumentException if the service definition does not exist
|
process
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php
|
MIT
|
private function resolveDefinition(ChildDefinition $definition) : Definition
{
try {
return $this->doResolveDefinition($definition);
} catch (ServiceCircularReferenceException $e) {
throw $e;
} catch (ExceptionInterface $e) {
$r = new \ReflectionProperty($e, 'message');
$r->setValue($e, \sprintf('Service "%s": %s', $this->currentId, $e->getMessage()));
throw $e;
}
}
|
Resolves the definition.
@throws RuntimeException When the definition is invalid
|
resolveDefinition
|
php
|
deptrac/deptrac
|
vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php
|
MIT
|
public function process(ContainerBuilder $container)
{
$this->container = $container;
$this->signalingException = new RuntimeException('Invalid reference.');
try {
foreach ($container->getDefinitions() as $this->currentId => $definition) {
$this->processValue($definition);
}
} finally {
unset($this->container, $this->signalingException);
}
}
|
Process the ContainerBuilder to resolve invalid references.
@return void
|
process
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.