class PointcutMethodNameFilter implements PointcutFilterInterface (View source)

A little filter which filters for method names

Constants

PATTERN_MATCHVISIBILITYMODIFIER

Properties

protected ReflectionService $reflectionService
protected string $methodNameFilterExpression
protected string|null $methodVisibility
protected LoggerInterface $logger
protected array $methodArgumentConstraints

Methods

__construct(string $methodNameFilterExpression, string $methodVisibility = null, array $methodArgumentConstraints = [])

Constructor - initializes the filter with the name filter pattern

void
injectReflectionService(ReflectionService $reflectionService)

Injects the reflection service

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

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

Checks if the specified method matches against the method name expression.

bool
hasRuntimeEvaluationsDefinition()

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

array
getRuntimeEvaluationsDefinition()

Returns runtime evaluations for a previously matched pointcut

string
getMethodNameFilterExpression()

Returns the method name filter expression

string|null
getMethodVisibility()

Returns the method visibility

array
getMethodArgumentConstraints()

Returns the method argument constraints

reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

Details

__construct(string $methodNameFilterExpression, string $methodVisibility = null, array $methodArgumentConstraints = [])

Constructor - initializes the filter with the name filter pattern

Parameters

string $methodNameFilterExpression

A regular expression which filters method names

string $methodVisibility

The method visibility modifier (public, protected or private). Specify NULL if you don't care.

array $methodArgumentConstraints

array of method constraints

Exceptions

InvalidPointcutExpressionException

void injectReflectionService(ReflectionService $reflectionService)

Injects the reflection service

Parameters

ReflectionService $reflectionService

The reflection service

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

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

Checks if the specified method matches against the method name expression.

Returns true if method name, visibility and arguments constraints match.

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

Exceptions

Exception

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 a previously matched pointcut

Return Value

array

Runtime evaluations

string getMethodNameFilterExpression()

Returns the method name filter expression

Return Value

string

string|null getMethodVisibility()

Returns the method visibility

Return Value

string|null

array getMethodArgumentConstraints()

Returns the method argument constraints

Return Value

array

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