class ProxyMethodGenerator extends MethodGenerator (View source)

Class ProxyMethodGenerator

This class is responsible for generating proxy methods that can be used as method interceptors. It extends the MethodGenerator class.

Properties

protected $addedPreParentCallCode
protected $addedPostParentCallCode
protected $attributesCode
protected class-string|null $fullOriginalClassName

Methods

fromReflection(MethodReflection $reflectionMethod)

No description

copyMethodSignatureAndDocblock(MethodReflection $reflectionMethod)

No description

string|null
getFullOriginalClassName()

No description

void
setFullOriginalClassName(string $fullOriginalClassName)

No description

void
addPreParentCallCode(string $code)

Adds PHP code to the body of this proxy method which will be executed before a possible parent call.

void
addPostParentCallCode(string $code)

Adds PHP code to the body of this proxy method which will be executed after a possible parent call.

string
generate()

Generates the code for the method.

string
renderBodyCode()

No description

bool
willBeRendered()

Tells if enough code was provided (yet) so that this method would actually be rendered if render() is called.

string
buildMethodParametersCode(string|null $fullClassName, string|null $methodName, bool $addTypeAndDefaultValue)

Builds the PHP code for the parameters of the specified method to be used in a method interceptor in the proxy class

string
buildCallParentMethodCode(string $fullClassName, string $methodName)

Builds PHP code which calls the original (i.e. parent) method after the added code has been executed.

string
buildAttributesCode(ReflectionMethod $reflectionMethod)

Build the code for the attributes of a given \ReflectionMethod object.

Details

static ProxyMethodGenerator fromReflection(MethodReflection $reflectionMethod)

No description

Parameters

MethodReflection $reflectionMethod

Return Value

ProxyMethodGenerator

static ProxyMethodGenerator copyMethodSignatureAndDocblock(MethodReflection $reflectionMethod)

No description

Parameters

MethodReflection $reflectionMethod

Return Value

ProxyMethodGenerator

string|null getFullOriginalClassName()

No description

Return Value

string|null

void setFullOriginalClassName(string $fullOriginalClassName)

No description

Parameters

string $fullOriginalClassName

Return Value

void

void addPreParentCallCode(string $code)

Adds PHP code to the body of this proxy method which will be executed before a possible parent call.

Parameters

string $code

Return Value

void

void addPostParentCallCode(string $code)

Adds PHP code to the body of this proxy method which will be executed after a possible parent call.

Parameters

string $code

Return Value

void

string generate()

Generates the code for the method.

This method overrides the parent generate() method in order to insert attributes code. As soon as https://github.com/laminas/laminas-code/pull/145 is merged and released, this can be implemented properly.

Return Value

string

The generated method code.

string renderBodyCode()

No description

Return Value

string

bool willBeRendered()

Tells if enough code was provided (yet) so that this method would actually be rendered if render() is called.

Return Value

bool

true if there is any code to render, otherwise false

string buildMethodParametersCode(string|null $fullClassName, string|null $methodName, bool $addTypeAndDefaultValue)

Builds the PHP code for the parameters of the specified method to be used in a method interceptor in the proxy class

Parameters

string|null $fullClassName

Name of the class the method is declared in

string|null $methodName

Name of the method to create the parameters code for

bool $addTypeAndDefaultValue

If the type and default value for each parameter should be rendered

Return Value

string

A comma separated list of parameters

protected string buildCallParentMethodCode(string $fullClassName, string $methodName)

Builds PHP code which calls the original (i.e. parent) method after the added code has been executed.

Parameters

string $fullClassName

Fully qualified name of the original class

string $methodName

Name of the original method

Return Value

string

PHP code

protected string buildAttributesCode(ReflectionMethod $reflectionMethod)

Build the code for the attributes of a given \ReflectionMethod object.

Note: This is just a preliminary solution until https://github.com/laminas/laminas-code/pull/145 is implemented and released.

Parameters

ReflectionMethod $reflectionMethod

The \ReflectionMethod object to retrieve attributes from.

Return Value

string

The code for the attributes of the given \ReflectionMethod object.

Exceptions

UnsupportedAttributeException