class Pointcut implements PointcutFilterInterface (View source)

The pointcut defines the set of join points (ie. "situations") in which certain code associated with the pointcut (ie. advices) should be executed. This set of join points is defined by a pointcut expression which is matched against class and method signatures.

Constants

MAXIMUM_RECURSIONS

Properties

protected string $pointcutExpression

A pointcut expression which configures the pointcut

protected PointcutFilterComposite $pointcutFilterComposite

The filter composite object, created from the pointcut expression

protected string $aspectClassName

If this pointcut is based on a pointcut declaration, contains the name of the aspect class where the pointcut was declared

protected string $pointcutMethodName

If this pointcut is based on a pointcut declaration, contains the name of the method acting as the pointcut identifier

protected mixed $pointcutQueryIdentifier

An identifier which is used to detect circular references between pointcuts

protected int $recursionLevel

Counts how often this pointcut's matches() method has been called during one query

Methods

__construct(string $pointcutExpression, PointcutFilterComposite $pointcutFilterComposite, string $aspectClassName, string $pointcutMethodName = null)

The constructor

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

Checks if the given class and method match this pointcut.

string
getPointcutExpression()

Returns the pointcut expression which has been passed to the constructor.

string
getAspectClassName()

Returns the aspect class name where the pointcut was declared.

string
getPointcutMethodName()

Returns the pointcut method name (if any was defined)

bool
hasRuntimeEvaluationsDefinition()

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

array
getRuntimeEvaluationsDefinition()

Returns runtime evaluations for the pointcut.

string
getRuntimeEvaluationsClosureCode()

Returns the PHP code (closure) that evaluates the runtime evaluations

reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

Details

__construct(string $pointcutExpression, PointcutFilterComposite $pointcutFilterComposite, string $aspectClassName, string $pointcutMethodName = null)

The constructor

Parameters

string $pointcutExpression

A pointcut expression which configures the pointcut

PointcutFilterComposite $pointcutFilterComposite
string $aspectClassName

The name of the aspect class where the pointcut was declared (either explicitly or from an advice's pointcut expression)

string $pointcutMethodName

(optional) If the pointcut is created from a pointcut declaration, the name of the method declaring the pointcut must be passed

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

Checks if the given class and method match this pointcut.

Before each match run, reset() must be called to reset the circular references guard.

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

CircularPointcutReferenceException

string getPointcutExpression()

Returns the pointcut expression which has been passed to the constructor.

This can be used for debugging pointcuts.

Return Value

string

The pointcut expression

string getAspectClassName()

Returns the aspect class name where the pointcut was declared.

Return Value

string

The aspect class name where the pointcut was declared

string getPointcutMethodName()

Returns the pointcut method name (if any was defined)

Return Value

string

The pointcut method name

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

string getRuntimeEvaluationsClosureCode()

Returns the PHP code (closure) that evaluates 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