class ProxyClass (View source)

Representation of a Proxy Class during rendering time

Properties

protected string $namespace

Namespace, extracted from the fully qualified original class name

protected string $originalClassName

The original class name

protected class-string $fullOriginalClassName

Fully qualified class name of the original class

protected ProxyConstructorGenerator $constructor
protected array $methods
protected array $constants
protected array $interfaces

Note: Not using ProxyInterface::class here, since the interface names must have a leading backslash.

protected array $traits
protected array $properties
protected ReflectionService $reflectionService

Methods

__construct(string $fullOriginalClassName)

Creates a new ProxyClass instance.

void
injectReflectionService(ReflectionService $reflectionService)

Injects the Reflection Service

getConstructor()

Returns the ProxyConstructorGenerator for this ProxyClass. Creates it if needed.

ProxyConstructorGenerator
getMethod(string $methodName)

Returns the named ProxyMethod for this ProxyClass. Creates it if needed.

void
addConstant(string $name, string $valueCode)

Adds a constant to this proxy class

void
addProperty(string $name, string $initialValueCode, string $visibility = 'private', string $docComment = '')

Adds a class property to this proxy class

void
addInterfaces(array $interfaceNames)

Adds one or more interfaces to the "implements" section of the class definition.

void
addTraits(array $traitNames)

Adds one or more traits to the class definition.

string
render()

Renders and returns the PHP code for this ProxyClass.

string
buildClassDocumentation()

Builds the class documentation block for the specified class keeping doc comments and vital annotations

string
renderConstantsCode()

Renders code for the added class constants

string
renderPropertiesCode()

Renders code for the added class properties

string
renderTraitsCode()

Renders code for added traits

Details

__construct(string $fullOriginalClassName)

Creates a new ProxyClass instance.

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

ProxyConstructorGenerator getConstructor()

Returns the ProxyConstructorGenerator for this ProxyClass. Creates it if needed.

ProxyConstructorGenerator getMethod(string $methodName)

Returns the named ProxyMethod for this ProxyClass. Creates it if needed.

Parameters

string $methodName

Return Value

ProxyConstructorGenerator

Exceptions

ReflectionException

void addConstant(string $name, string $valueCode)

Adds a constant to this proxy class

Parameters

string $name

Name of the constant. Should be ALL_UPPERCASE_WITH_UNDERSCORES

string $valueCode

PHP code which assigns the value. Example: 'foo' (including quotes!)

Return Value

void

void addProperty(string $name, string $initialValueCode, string $visibility = 'private', string $docComment = '')

Adds a class property to this proxy class

Parameters

string $name

Name of the property

string $initialValueCode

PHP code of the initial value assignment

string $visibility
string $docComment

Return Value

void

void addInterfaces(array $interfaceNames)

Adds one or more interfaces to the "implements" section of the class definition.

Note that the passed interface names must already have a leading backslash, for example "\Neos\Flow\Foo\BarInterface".

Parameters

array $interfaceNames

Fully qualified names of the interfaces to introduce

Return Value

void

void addTraits(array $traitNames)

Adds one or more traits to the class definition.

Note that the passed trait names must have a leading backslash, for example "\Neos\Flow\ObjectManagement\Proxy\PropertyInjectionTrait".

Parameters

array $traitNames

Return Value

void

string render()

Renders and returns the PHP code for this ProxyClass.

Return Value

string

Exceptions

CannotBuildObjectException

protected string buildClassDocumentation()

Builds the class documentation block for the specified class keeping doc comments and vital annotations

Return Value

string

$methodDocumentation DocComment for the given method

protected string renderConstantsCode()

Renders code for the added class constants

Return Value

string

protected string renderPropertiesCode()

Renders code for the added class properties

Return Value

string

protected string renderTraitsCode()

Renders code for added traits

Return Value

string