Documentation

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
author

Nicolas Grekas p@tchwork.com

author

Julien Maulny jmaulny@darkmira.fr

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

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

enableExpressionProcessing()

protected enableExpressionProcessing() : mixed
Return values
mixed

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
throws
InvalidParameterTypeException

When a parameter is not compatible with the declared type

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
throws
InvalidArgumentException

When not enough parameters are defined for the method

Return values
void

Search results