CheckTypeDeclarationsPass
extends AbstractRecursivePass
in package
FinalYes
Checks whether injected parameters are compatible with type declarations.
This pass should be run after all optimization passes.
It can be added either:
- before removing passes to check all services even if they are not currently used,
- after removing passes to check only services are used in the app.
Tags
Table of Contents
Constants
- BUILTIN_TYPES = ['array' => true, 'bool' => true, 'callable' => true, 'float' => true, 'int' => true, 'iterable' => true, 'object' => true, 'string' => true]
- SCALAR_TYPES = ['int' => true, 'float' => true, 'bool' => true, 'string' => true]
Properties
- $container : ContainerBuilder
- $currentId : mixed
- $skipScalars : bool
- $autoload : bool
- $expressionLanguage : ExpressionLanguage
- $skippedIds : array<string|int, mixed>
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.
- checkType() : void
- checkTypeDeclarations() : void
- getExpressionLanguage() : ExpressionLanguage
Constants
BUILTIN_TYPES
private
mixed
BUILTIN_TYPES
= ['array' => true, 'bool' => true, 'callable' => true, 'float' => true, 'int' => true, 'iterable' => true, 'object' => true, 'string' => true]
SCALAR_TYPES
private
mixed
SCALAR_TYPES
= ['int' => true, 'float' => true, 'bool' => true, 'string' => true]
Properties
$container
protected
ContainerBuilder
$container
$currentId
protected
mixed
$currentId
$skipScalars
protected
bool
$skipScalars
= true
$autoload
private
bool
$autoload
$expressionLanguage
private
ExpressionLanguage
$expressionLanguage
$skippedIds
private
array<string|int, mixed>
$skippedIds
Methods
__construct()
public
__construct([bool $autoload = false ][, array<string|int, mixed> $skippedIds = [] ]) : mixed
Parameters
- $autoload : bool = false
-
Whether services who's class in not loaded should be checked or not. Defaults to false to save loading code during compilation.
- $skippedIds : array<string|int, mixed> = []
-
An array indexed by the service ids to skip
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
checkType()
private
checkType(Definition $checkedDefinition, mixed $value, ReflectionParameter $parameter, string|null $envPlaceholderUniquePrefix[, ReflectionType|null $reflectionType = null ]) : void
Parameters
- $checkedDefinition : Definition
- $value : mixed
- $parameter : ReflectionParameter
- $envPlaceholderUniquePrefix : string|null
- $reflectionType : ReflectionType|null = null
Tags
checkTypeDeclarations()
private
checkTypeDeclarations(Definition $checkedDefinition, ReflectionFunctionAbstract $reflectionFunction, array<string|int, mixed> $values) : void
Parameters
- $checkedDefinition : Definition
- $reflectionFunction : ReflectionFunctionAbstract
- $values : array<string|int, mixed>
Tags
getExpressionLanguage()
private
getExpressionLanguage() : ExpressionLanguage