CheckTypeDeclarationsPass
extends AbstractRecursivePass
in package
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
- 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]
- $container : ContainerBuilder
- $currentId : mixed
- $autoload : mixed
- $expressionLanguage : mixed
- $inExpression : mixed
- $processExpressions : mixed
- $skippedIds : mixed
- __construct() : mixed
- process() : mixed
- You can modify the container here before it is dumped to PHP code.
- enableExpressionProcessing() : mixed
- 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
$autoload
private
mixed
$autoload
$expressionLanguage
private
mixed
$expressionLanguage
$inExpression
private
mixed
$inExpression
= false
$processExpressions
private
mixed
$processExpressions
= false
$skippedIds
private
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
Return values
mixed —process()
You can modify the container here before it is dumped to PHP code.
public
process(ContainerBuilder $container) : mixed
Parameters
- $container : ContainerBuilder
Return values
mixed —enableExpressionProcessing()
protected
enableExpressionProcessing() : mixed
Return values
mixed —getConstructor()
protected
getConstructor(Definition $definition, bool $required) : ReflectionFunctionAbstract|null
Parameters
- $definition : Definition
- $required : bool
Tags
Return values
ReflectionFunctionAbstract|null —getReflectionMethod()
protected
getReflectionMethod(Definition $definition, string $method) : ReflectionFunctionAbstract
Parameters
- $definition : Definition
- $method : string
Tags
Return values
ReflectionFunctionAbstract —inExpression()
protected
inExpression([bool $reset = true ]) : bool
Parameters
- $reset : bool = true
Return values
bool —processValue()
Processes a value found in a definition tree.
protected
processValue(mixed $value[, bool $isRoot = false ]) : mixed
Parameters
- $value : mixed
- $isRoot : bool = false
Return values
mixed —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
Return values
void —checkTypeDeclarations()
private
checkTypeDeclarations(Definition $checkedDefinition, ReflectionFunctionAbstract $reflectionFunction, array<string|int, mixed> $values) : void
Parameters
- $checkedDefinition : Definition
- $reflectionFunction : ReflectionFunctionAbstract
- $values : array<string|int, mixed>
Tags
Return values
void —getExpressionLanguage()
private
getExpressionLanguage() : ExpressionLanguage