AutowirePass
extends AbstractRecursivePass
in package
Inspects existing service definitions and wires the autowired ones using the type hints of their classes.
Tags
Table of Contents
Properties
- $container : ContainerBuilder
- $currentId : mixed
- $skipScalars : bool
- $ambiguousServiceTypes : array<string|int, mixed>
- $autowiringAliases : array<string|int, mixed>
- $decoratedClass : string|null
- $decoratedId : string|null
- $decoratedMethodArgumentIndex : int|null
- $decoratedMethodIndex : int|null
- $defaultArgument : object
- $getPreviousValue : Closure|null
- $lastFailure : string|null
- $methodCalls : array<string|int, mixed>|null
- $throwOnAutowiringException : bool
- $types : array<string|int, mixed>
- $typesClone : self|null
Methods
- __construct() : mixed
- process() : void
- You can modify the container here before it is dumped to PHP code.
- enableExpressionProcessing() : void
- getConstructor() : ReflectionFunctionAbstract|null
- getReflectionMethod() : ReflectionFunctionAbstract
- inExpression() : bool
- processValue() : mixed
- Processes a value found in a definition tree.
- autowireCalls() : array<string|int, mixed>
- autowireMethod() : array<string|int, mixed>
- Autowires the constructor or a method.
- createTypeAlternatives() : string
- createTypeNotFoundMessage() : string
- createTypeNotFoundMessageCallback() : Closure
- doProcessValue() : mixed
- getAliasesSuggestionForType() : string|null
- getAutowiredReference() : TypedReference|null
- Returns a reference to the service matching the given type, if any.
- getCombinedAlias() : string|null
- populateAutowiringAlias() : void
- populateAvailableType() : void
- Populates the list of available types for a given definition.
- populateAvailableTypes() : void
- Populates the list of available types.
- set() : void
- Associates a type and a service id if applicable.
Properties
$container
protected
ContainerBuilder
$container
$currentId
protected
mixed
$currentId
$skipScalars
protected
bool
$skipScalars
= true
$ambiguousServiceTypes
private
array<string|int, mixed>
$ambiguousServiceTypes
$autowiringAliases
private
array<string|int, mixed>
$autowiringAliases
$decoratedClass
private
string|null
$decoratedClass
= null
$decoratedId
private
string|null
$decoratedId
= null
$decoratedMethodArgumentIndex
private
int|null
$decoratedMethodArgumentIndex
= null
$decoratedMethodIndex
private
int|null
$decoratedMethodIndex
= null
$defaultArgument
private
object
$defaultArgument
$getPreviousValue
private
Closure|null
$getPreviousValue
= null
$lastFailure
private
string|null
$lastFailure
= null
$methodCalls
private
array<string|int, mixed>|null
$methodCalls
= null
$throwOnAutowiringException
private
bool
$throwOnAutowiringException
$types
private
array<string|int, mixed>
$types
$typesClone
private
self|null
$typesClone
= null
Methods
__construct()
public
__construct([bool $throwOnAutowireException = true ]) : mixed
Parameters
- $throwOnAutowireException : bool = true
process()
You can modify the container here before it is dumped to PHP code.
public
process(ContainerBuilder $container) : void
Parameters
- $container : ContainerBuilder
enableExpressionProcessing()
protected
enableExpressionProcessing() : void
getConstructor()
protected
getConstructor(Definition $definition, bool $required) : ReflectionFunctionAbstract|null
Parameters
- $definition : Definition
- $required : bool
Tags
Return values
ReflectionFunctionAbstract|nullgetReflectionMethod()
protected
getReflectionMethod(Definition $definition, string $method) : ReflectionFunctionAbstract
Parameters
- $definition : Definition
- $method : string
Tags
Return values
ReflectionFunctionAbstractinExpression()
protected
inExpression([bool $reset = true ]) : bool
Parameters
- $reset : bool = true
Return values
boolprocessValue()
Processes a value found in a definition tree.
protected
processValue(mixed $value[, bool $isRoot = false ]) : mixed
Parameters
- $value : mixed
- $isRoot : bool = false
autowireCalls()
private
autowireCalls(ReflectionClass $reflectionClass, bool $isRoot, bool $checkAttributes) : array<string|int, mixed>
Parameters
- $reflectionClass : ReflectionClass
- $isRoot : bool
- $checkAttributes : bool
Return values
array<string|int, mixed>autowireMethod()
Autowires the constructor or a method.
private
autowireMethod(ReflectionFunctionAbstract $reflectionMethod, array<string|int, mixed> $arguments, bool $checkAttributes, int $methodIndex) : array<string|int, mixed>
Parameters
- $reflectionMethod : ReflectionFunctionAbstract
- $arguments : array<string|int, mixed>
- $checkAttributes : bool
- $methodIndex : int
Tags
Return values
array<string|int, mixed>createTypeAlternatives()
private
createTypeAlternatives(ContainerBuilder $container, TypedReference $reference) : string
Parameters
- $container : ContainerBuilder
- $reference : TypedReference
Return values
stringcreateTypeNotFoundMessage()
private
createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId) : string
Parameters
- $reference : TypedReference
- $label : string
- $currentId : string
Return values
stringcreateTypeNotFoundMessageCallback()
private
createTypeNotFoundMessageCallback(TypedReference $reference, string $label) : Closure
Parameters
- $reference : TypedReference
- $label : string
Return values
ClosuredoProcessValue()
private
doProcessValue(mixed $value[, bool $isRoot = false ]) : mixed
Parameters
- $value : mixed
- $isRoot : bool = false
getAliasesSuggestionForType()
private
getAliasesSuggestionForType(ContainerBuilder $container, string $type) : string|null
Parameters
- $container : ContainerBuilder
- $type : string
Return values
string|nullgetAutowiredReference()
Returns a reference to the service matching the given type, if any.
private
getAutowiredReference(TypedReference $reference, bool $filterType) : TypedReference|null
Parameters
- $reference : TypedReference
- $filterType : bool
Return values
TypedReference|nullgetCombinedAlias()
private
getCombinedAlias(string $type[, string|null $name = null ]) : string|null
Parameters
- $type : string
- $name : string|null = null
Return values
string|nullpopulateAutowiringAlias()
private
populateAutowiringAlias(string $id[, string|null $target = null ]) : void
Parameters
- $id : string
- $target : string|null = null
populateAvailableType()
Populates the list of available types for a given definition.
private
populateAvailableType(ContainerBuilder $container, string $id, Definition $definition) : void
Parameters
- $container : ContainerBuilder
- $id : string
- $definition : Definition
populateAvailableTypes()
Populates the list of available types.
private
populateAvailableTypes(ContainerBuilder $container) : void
Parameters
- $container : ContainerBuilder
set()
Associates a type and a service id if applicable.
private
set(string $type, string $id) : void
Parameters
- $type : string
- $id : string