class PointcutFilterComposite implements PointcutFilterInterface (View source)

This composite allows to check for match against a row pointcut filters by only one method call. All registered filters will be invoked and if one filter doesn't match, the overall result is "no".

Properties

protected array $filters
protected bool $earlyReturn
protected array $runtimeEvaluationsDefinition
protected array $globalRuntimeEvaluationsDefinition

Methods

bool
matches(string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier)

Checks if the specified class and method match the registered class- and method filter patterns.

void
addFilter(string $operator, PointcutFilterInterface $filter)

Adds a class filter to the composite

bool
hasRuntimeEvaluationsDefinition()

Returns true if this filter holds runtime evaluations for a previously matched pointcut

array
getRuntimeEvaluationsDefinition()

Returns runtime evaluations for the pointcut.

void
setGlobalRuntimeEvaluationsDefinition(array $runtimeEvaluations)

Sets static runtime evaluations for to pointcut, that will be used for every method this composite matches

string
getRuntimeEvaluationsClosureCode()

Returns the PHP code (closure) that can evaluate the runtime evaluations

reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

string
buildRuntimeEvaluationsConditionCode(string $operator, array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used for runtime evaluations

string
buildMethodArgumentsEvaluationConditionCode(array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used argument runtime evaluations

string
buildGlobalRuntimeEvaluationsConditionCode(array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used for global runtime evaluations

string
buildArgumentEvaluationAccessCode(mixed $argumentAccess, bool $useGlobalObjects = false)

Returns the PHP code used to access one argument of a runtime evaluation

Details

bool matches(string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier)

Checks if the specified class and method match the registered class- and method filter patterns.

Parameters

string $className

Name of the class to check against

string $methodName

Name of the method to check against

string $methodDeclaringClassName

Name of the class the method was originally declared in

mixed $pointcutQueryIdentifier

Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.

Return Value

bool

true if the class / method match, otherwise false

void addFilter(string $operator, PointcutFilterInterface $filter)

Adds a class filter to the composite

Parameters

string $operator

The operator for this filter

PointcutFilterInterface $filter

A configured class filter

Return Value

void

bool hasRuntimeEvaluationsDefinition()

Returns true if this filter holds runtime evaluations for a previously matched pointcut

Return Value

bool

true if this filter has runtime evaluations

array getRuntimeEvaluationsDefinition()

Returns runtime evaluations for the pointcut.

Return Value

array

Runtime evaluations

void setGlobalRuntimeEvaluationsDefinition(array $runtimeEvaluations)

Sets static runtime evaluations for to pointcut, that will be used for every method this composite matches

Parameters

array $runtimeEvaluations

Runtime evaluations to be added

Return Value

void

string getRuntimeEvaluationsClosureCode()

Returns the PHP code (closure) that can evaluate the runtime evaluations

Return Value

string

The closure code

ClassNameIndex reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

Parameters

ClassNameIndex $classNameIndex

An index of class names

Return Value

ClassNameIndex

The filtered result, with pointcuts possibly covered by this filter

protected string buildRuntimeEvaluationsConditionCode(string $operator, array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used for runtime evaluations

Parameters

string $operator

The operator for the given condition

array $conditions

Condition array

bool $useGlobalObjects

Set to true if global objects are used by the condition

Return Value

string

The condition code

protected string buildMethodArgumentsEvaluationConditionCode(array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used argument runtime evaluations

Parameters

array $conditions

Condition array

bool $useGlobalObjects

Set to true if global objects are used by the condition

Return Value

string

The arguments condition code

protected string buildGlobalRuntimeEvaluationsConditionCode(array $conditions, bool $useGlobalObjects = false)

Returns the PHP code of the conditions used for global runtime evaluations

Parameters

array $conditions

Condition array

bool $useGlobalObjects

Set to true if global objects are used by the condition

Return Value

string

The condition code

protected string buildArgumentEvaluationAccessCode(mixed $argumentAccess, bool $useGlobalObjects = false)

Returns the PHP code used to access one argument of a runtime evaluation

Parameters

mixed $argumentAccess

The unparsed argument access, might be string or array

bool $useGlobalObjects

Set to true if global objects are used by the condition

Return Value

string

The condition code