class AdvicedMethodInterceptorBuilder extends AbstractMethodInterceptorBuilder (View source)

An AOP interceptor code builder for methods enriched by advices.

Properties

protected ReflectionService $reflectionService from  AbstractMethodInterceptorBuilder
protected Compiler $compiler from  AbstractMethodInterceptorBuilder

Methods

void
injectReflectionService(ReflectionService $reflectionService)

Injects the reflection service

void
injectCompiler(Compiler $compiler)

No description

void
build(string $methodName, array $interceptedMethods, string $targetClassName)

Builds interception PHP code for an adviced method

string
buildArraySetupCode(array $array)

Builds a string containing PHP code to build the array given as input.

string
buildMethodArgumentsArrayCode(string $className = null, string $methodName = null, bool $useArgumentsArray = false)

Builds the PHP code for the method arguments array which is passed to the constructor of a new join point. Used in the method interceptor functions.

string
buildSavedConstructorParametersCode(string $className = null)

Generates the parameters code needed to call the constructor with the saved parameters.

string
buildAdvicesCode(array $groupedAdvices, string $methodName = null, string $targetClassName = null, string $declaringClassName = null)

Builds the advice interception code, to be used in a method interceptor.

Details

void injectReflectionService(ReflectionService $reflectionService)

Injects the reflection service

Parameters

ReflectionService $reflectionService

The reflection service

Return Value

void

void injectCompiler(Compiler $compiler)

No description

Parameters

Compiler $compiler

Return Value

void

void build(string $methodName, array $interceptedMethods, string $targetClassName)

Builds interception PHP code for an adviced method

Parameters

string $methodName

Name of the method to build an interceptor for

array $interceptedMethods

An array of method names and their meta information, including advices for the method (if any)

string $targetClassName

Name of the target class to build the interceptor for

Return Value

void

Exceptions

Exception

protected string buildArraySetupCode(array $array)

Builds a string containing PHP code to build the array given as input.

Parameters

array $array

Return Value

string

e.g. 'array()' or 'array(1 => 'bar')

protected string buildMethodArgumentsArrayCode(string $className = null, string $methodName = null, bool $useArgumentsArray = false)

Builds the PHP code for the method arguments array which is passed to the constructor of a new join point. Used in the method interceptor functions.

Parameters

string $className

Name of the declaring class of the method

string $methodName

Name of the method to create arguments array code for

bool $useArgumentsArray

If set, the $methodArguments array will be built from $arguments instead of using the actual parameter variables.

Return Value

string

The generated code to be used in an "array()" definition

protected string buildSavedConstructorParametersCode(string $className = null)

Generates the parameters code needed to call the constructor with the saved parameters.

Parameters

string $className

Name of the class the method is declared in

Return Value

string

The generated parameters code

protected string buildAdvicesCode(array $groupedAdvices, string $methodName = null, string $targetClassName = null, string $declaringClassName = null)

Builds the advice interception code, to be used in a method interceptor.

Parameters

array $groupedAdvices

The advices grouped by advice type

string $methodName

Name of the method the advice applies to

string $targetClassName

Name of the target class

string $declaringClassName

Name of the declaring class. This is usually the same as the $targetClassName. However, it is the introduction interface for introduced methods.

Return Value

string

PHP code to be used in the method interceptor