class ProxyConstructor extends ProxyMethod (View source)

Representation of a constructor method within a proxy class

Constants

BEFORE_PARENT_CALL

AFTER_PARENT_CALL

Properties

protected string $fullOriginalClassName

Fully qualified class name of the original class

from  ProxyMethod
protected string $methodName

Name of the original method

protected string $visibility

Visibility of the method

from  ProxyMethod
protected string $addedPreParentCallCode from  ProxyMethod
protected string $addedPostParentCallCode from  ProxyMethod
protected string $methodParametersCode from  ProxyMethod
string $methodBody from  ProxyMethod
protected ReflectionService $reflectionService from  ProxyMethod

Methods

__construct(string $fullOriginalClassName)

No description

void
injectReflectionService(ReflectionService $reflectionService)

Injects the Reflection Service

void
overrideMethodVisibility(string $visibility)

Overrides the method's visibility

bool
isPrivate()

Returns TRUE if this proxy belongs to a private method, otherwise FALSE

void
addPreParentCallCode(string $code)

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

void
addPostParentCallCode(string $code)

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

void
setMethodParametersCode(string $code)

Sets the (exact) code which use used in as the parameters signature for this method.

string
render()

Renders the code for a proxy constructor

bool
willBeRendered()

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

string
buildMethodDocumentation(string $className, string $methodName)

Builds the method documentation block for the specified method keeping the vital annotations

string
buildMethodParametersCode(string $fullClassName, string $methodName, bool $addTypeAndDefaultValue = true)

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 (ie. parent) method after the added code has been executed.

string
buildArraySetupCode(array $array)

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

string
getMethodVisibilityString()

Returns the method's visibility string found by the reflection service Note: If the reflection service has no information about this method, 'public' is returned.

void
setMethodBody(string $methodBody)

Override the method body

Details

__construct(string $fullOriginalClassName)

No description

Parameters

string $fullOriginalClassName

The fully qualified class name of the original class

void injectReflectionService(ReflectionService $reflectionService)

Injects the Reflection Service

Parameters

ReflectionService $reflectionService

Return Value

void

void overrideMethodVisibility(string $visibility)

Overrides the method's visibility

Parameters

string $visibility

One of 'public', 'protected', 'private'

Return Value

void

bool isPrivate()

Returns TRUE if this proxy belongs to a private method, otherwise FALSE

Return Value

bool

void addPreParentCallCode(string $code)

Adds PHP code to the body of this 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 method which will be executed after a possible parent call.

Parameters

string $code

Return Value

void

void setMethodParametersCode(string $code)

Sets the (exact) code which use used in as the parameters signature for this method.

Parameters

string $code

Parameters code, for example: '$foo, array $bar, \Foo\Bar\Baz $baz'

Return Value

void

string render()

Renders the code for a proxy constructor

Return Value

string

PHP code

Exceptions

ClassLoadingForReflectionFailedException

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

protected string buildMethodDocumentation(string $className, string $methodName)

Builds the method documentation block for the specified method keeping the vital annotations

Parameters

string $className

Name of the class the method is declared in

string $methodName

Name of the method to create the parameters code for

Return Value

string

$methodDocumentation DocComment for the given method

string buildMethodParametersCode(string $fullClassName, string $methodName, bool $addTypeAndDefaultValue = true)

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

Parameters

string $fullClassName

Name of the class the method is declared in

string $methodName

Name of the method to create the parameters code for

bool $addTypeAndDefaultValue

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

Return Value

string

A comma speparated list of parameters

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

Builds PHP code which calls the original (ie. 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 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 getMethodVisibilityString()

Returns the method's visibility string found by the reflection service Note: If the reflection service has no information about this method, 'public' is returned.

Return Value

string

One of 'public', 'protected' or 'private'

void setMethodBody(string $methodBody)

Override the method body

Parameters

string $methodBody

Return Value

void