class ReflectionService (View source)

A service for acquiring reflection based information in a performant way. This service also builds up class schema information which is used by the Flow's persistence layer.

Reflection of classes of all active packages is triggered through the bootstrap's initializeReflectionService() method. In a development context, single classes may be re-reflected once files are modified whereas in a production context reflection is done once and successive requests read from the frozen caches for performance reasons.

The list of available classes is determined by the CompiletimeObjectManager which also triggers the initial build of reflection data in this service.

The invalidation of reflection cache entries is done by the CacheManager which in turn is triggered by signals sent by the file monitor.

The internal representation of cache data is optimized for memory consumption and speed by using constants which have an integer value.

Constants

VISIBILITY_PRIVATE

VISIBILITY_PROTECTED

VISIBILITY_PUBLIC

DATA_INTERFACE_IMPLEMENTATIONS

DATA_CLASS_INTERFACES

DATA_CLASS_SUBCLASSES

DATA_CLASS_TAGS_VALUES

DATA_CLASS_ANNOTATIONS

DATA_CLASS_ABSTRACT

DATA_CLASS_FINAL

DATA_CLASS_METHODS

DATA_CLASS_PROPERTIES

DATA_METHOD_FINAL

DATA_METHOD_STATIC

DATA_METHOD_VISIBILITY

DATA_METHOD_PARAMETERS

DATA_METHOD_DECLARED_RETURN_TYPE

DATA_PROPERTY_TAGS_VALUES

DATA_PROPERTY_ANNOTATIONS

DATA_PROPERTY_VISIBILITY

DATA_PROPERTY_TYPE

DATA_PARAMETER_POSITION

DATA_PARAMETER_OPTIONAL

DATA_PARAMETER_TYPE

DATA_PARAMETER_ARRAY

DATA_PARAMETER_CLASS

DATA_PARAMETER_ALLOWS_NULL

DATA_PARAMETER_DEFAULT_VALUE

DATA_PARAMETER_BY_REFERENCE

DATA_PARAMETER_SCALAR_DECLARATION

Properties

protected Reader $annotationReader
protected array $availableClassNames
protected StringFrontend $statusCache
protected VariableFrontend $reflectionDataCompiletimeCache
protected VariableFrontend $reflectionDataRuntimeCache
protected VariableFrontend $classSchemataRuntimeCache
protected LoggerInterface $logger
protected PackageManager $packageManager
protected Environment $environment
protected ApplicationContext $context
protected PhpParser $doctrinePhpParser

The doctrine PHP parser which can parse "use" statements. Is initialized lazily when it is first needed.

protected array $useStatementsForClassCache

a cache which stores the use statements reflected for a particular class (only relevant for un-expanded "var" and "param" annotations)

protected bool $loadFromClassSchemaRuntimeCache

In Production context, with frozen caches, this flag will be true

protected array $settings
protected array $annotatedClasses

Array of annotation classnames and the names of classes which are annotated with them

protected array $classesByMethodAnnotations

Array of method annotations and the classes and methods which are annotated with them

protected ClassSchema[] $classSchemata

Schemata of all classes which can be persisted

protected array $classesCurrentlyBeingForgotten

An array of class names which are currently being forgotten by forgetClass(). Acts as a safeguard against infinite loops.

protected array $classReflectionData

Array with reflection information indexed by class name

protected array $updatedReflectionData

Array with updated reflection information (e.g. in Development context after classes have changed)

protected bool $initialized
protected array $methodAnnotationsRuntimeCache

A runtime cache for reflected method annotations to speed up repeating checks.

Methods

void
setStatusCache(StringFrontend $cache)

Sets the status cache

void
setReflectionDataCompiletimeCache(VariableFrontend $cache)

Sets the compile-time data cache

void
setReflectionDataRuntimeCache(VariableFrontend $cache)

Sets the runtime data cache

void
setClassSchemataRuntimeCache(VariableFrontend $cache)

Sets the dedicated class schema cache for runtime purposes

void
injectSettings(array $settings)

No description

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

void
injectPackageManager(PackageManager $packageManager)

No description

void
injectEnvironment(Environment $environment)

No description

PhpParser
getDoctrinePhpParser()

Retrieves a singleton instance of the Doctrine PhpParser

void
initialize()

Initialize the reflection service lazily

void
buildReflectionData(array $availableClassNames)

Builds the reflection data cache during compile time.

bool
isClassReflected(string $className)

Tells if the specified class is known to this reflection service and reflection information is available.

array
getAllClassNames()

Returns the names of all classes known to this reflection service.

mixed
getDefaultImplementationClassNameForInterface(string $interfaceName)

Searches for and returns the class name of the default implementation of the given interface name. If no class implementing the interface was found or more than one implementation was found in the package defining the interface, false is returned.

array
getAllImplementationClassNamesForInterface(string $interfaceName)

Searches for and returns all class names of implementations of the given object type (interface name). If no class implementing the interface was found, an empty array is returned.

array
getAllSubClassNamesForClass(string $className)

Searches for and returns all names of classes inheriting the specified class.

array
getClassNamesByAnnotation(string $annotationClassName)

Searches for and returns all names of classes which are tagged by the specified annotation. If no classes were found, an empty array is returned.

bool
isClassAnnotatedWith(string $className, string $annotationClassName)

Tells if the specified class has the given annotation

object[]
getClassAnnotations(string $className, string $annotationClassName = null)

Returns the specified class annotations or an empty array

object|null
getClassAnnotation(string $className, string $annotationClassName)

Returns the specified class annotation or NULL.

bool
isClassImplementationOf(string $className, string $interfaceName)

Tells if the specified class implements the given interface

bool
isClassAbstract(string $className)

Tells if the specified class is abstract or not

bool
isClassFinal(string $className)

Tells if the specified class is final or not

bool
isClassUnconfigurable(string $className)

Tells if the class is unconfigurable or not

array
getClassesContainingMethodsAnnotatedWith(string $annotationClassName)

Returns all class names of classes containing at least one method annotated with the given annotation class

array
getMethodsAnnotatedWith(string $className, string $annotationClassName)

Returns all names of methods of the given class that are annotated with the given annotation class

bool
isMethodFinal(string $className, string $methodName)

Tells if the specified method is final or not

bool
isMethodStatic(string $className, string $methodName)

Tells if the specified method is declared as static or not

bool
isMethodPublic(string $className, string $methodName)

Tells if the specified method is public

bool
isMethodProtected(string $className, string $methodName)

Tells if the specified method is protected

bool
isMethodPrivate(string $className, string $methodName)

Tells if the specified method is private

bool
isMethodTaggedWith(string $className, string $methodName, string $tag)

Tells if the specified method is tagged with the given tag

bool
isAttributeIgnored(string $attributeName)

Tells if a specific PHP attribute is to be ignored for reflection

bool
isMethodAnnotatedWith(string $className, string $methodName, string $annotationClassName)

Tells if the specified method has the given annotation

object[]
getMethodAnnotations(string $className, string $methodName, string $annotationClassName = null)

Returns the specified method annotations or an empty array

object|null
getMethodAnnotation(string $className, string $methodName, string $annotationClassName)

Returns the specified method annotation or NULL.

array
getClassPropertyNames(string $className)

Returns the names of all properties of the specified class

bool
hasMethod(string $className, string $methodName)

Wrapper for method_exists() which tells if the given method exists.

array
getMethodTagsValues(string $className, string $methodName)

Returns all tags and their values the specified method is tagged with

array
getMethodParameters(string $className, string $methodName)

Returns an array of parameters of the given method. Each entry contains additional information about the parameter position, type hint etc.

string
getMethodDeclaredReturnType(string $className, string $methodName)

Returns the declared return type of a method (for PHP < 7.0 this will always return null)

array
getPropertyNamesByTag(string $className, string $tag)

Searches for and returns all names of class properties which are tagged by the specified tag.

array
getPropertyTagsValues(string $className, string $propertyName)

Returns all tags and their values the specified class property is tagged with

array
getPropertyTagValues(string $className, string $propertyName, string $tag)

Returns the values of the specified class property tag

string|null
getPropertyType($className, $propertyName)

Returns the property type

bool
isPropertyPrivate(string $className, string $propertyName)

Tells if the specified property is private

bool
isPropertyTaggedWith(string $className, string $propertyName, string $tag)

Tells if the specified class property is tagged with the given tag

bool
isPropertyAnnotatedWith(string $className, string $propertyName, string $annotationClassName)

Tells if the specified property has the given annotation

array
getPropertyNamesByAnnotation(string $className, string $annotationClassName)

Searches for and returns all names of class properties which are marked by the specified annotation. If no properties were found, an empty array is returned.

object[]
getPropertyAnnotations(string $className, string $propertyName, string $annotationClassName = null)

Returns the specified property annotations or an empty array

object|null
getPropertyAnnotation(string $className, string $propertyName, string $annotationClassName)

Returns the specified property annotation or NULL.

getClassSchema(mixed $classNameOrObject)

Returns the class schema for the given class

string
prepareClassReflectionForUsage(string $className)

Initializes the ReflectionService, cleans the given class name and finally reflects the class if necessary.

void
reflectEmergedClasses()

Checks if the given class names match those which already have been reflected. If the given array contains class names not yet known to this service, these classes will be reflected.

bool
isTagIgnored(string $tagName)

Check if a specific annotation tag is configured to be ignored.

void
reflectClass(string $className)

Reflects the given class and stores the results in this service's properties.

int
reflectClassProperty(string $className, PropertyReflection $property)

No description

array
reflectPropertyTag(string $className, PropertyReflection $property, string $tagName, array $tagValues)

No description

void
addParentClass(string $className, ClassReflection $parentClass)

No description

addImplementedInterface(string $className, ClassReflection $interface)

No description

void
reflectClassMethod(string $className, MethodReflection $method)

No description

void
reflectClassMethodParameter(string $className, MethodReflection $method, ParameterReflection $parameter)

No description

string
expandType(ClassReflection $class, string $type)

Expand shortened class names in "var" and "param" annotations, taking use statements into account.

getParentClasses(ClassReflection $class, array $parentClasses = [])

Finds all parent classes of the given class

void
buildClassSchemata(array $classNames)

Builds class schemata from classes annotated as entities or value objects

buildClassSchema(string $className)

Builds a class schema for the given class name.

void
addPropertiesToClassSchema(ClassSchema $classSchema)

Adds properties of the class at hand to the class schema.

bool
evaluateClassPropertyAnnotationsForSchema(ClassSchema $classSchema, string $propertyName)

No description

void
completeRepositoryAssignments()

Complete repository-to-entity assignments.

void
makeChildClassesAggregateRoot(ClassSchema $classSchema)

Assigns the repository of any aggregate root to all it's subclasses, unless they are aggregate root already.

void
ensureAggregateRootInheritanceChainConsistency()

Checks whether all aggregate roots having superclasses have a repository assigned up to the tip of their hierarchy.

void
checkValueObjectRequirements(string $className)

Checks if the given class meets the requirements for a value object, i.e.

array
convertParameterDataToArray(array $parametersInformation)

Converts the internal, optimized data structure of parameter information into a human-friendly array with speaking indexes.

array
convertParameterReflectionToArray(ParameterReflection $parameter, MethodReflection $method)

Converts the given parameter reflection into an information array

void
forgetChangedClasses()

Checks which classes lack a cache entry and removes their reflection data accordingly.

void
forgetClass(string $className)

Forgets all reflection data related to the specified class

bool
loadClassReflectionCompiletimeCache()

Tries to load the reflection data from the compile time cache.

void
loadOrReflectClassIfNecessary(string $className)

Loads reflection data from the cache or reflects the class if needed.

void
freezePackageReflection(string $packageKey)

Stores the current reflection data related to classes of the specified package in the PrecompiledReflectionData directory for the current context.

array
filterArrayByClassesInPackageNamespace(array $array, string $packageKey)

Filter an array of entries were keys are class names by being in the given package namespace.

void
unfreezePackageReflection(string $packageKey)

Removes the precompiled reflection data of a frozen package

void
saveToCache()

Exports the internal reflection data into the ReflectionData cache

saveDevelopmentData()

Save reflection data to cache in Development context.

saveProductionData()

Save reflection data to cache in Production context.

updateReflectionData()

Set updated reflection data to caches.

string
cleanClassName(string $className)

Clean a given class name from possibly prefixed backslash

string
produceCacheIdentifierFromClassName(string $className)

Transform backslashes to underscores to provide an valid cache identifier.

void
log(string $message, string $severity = LogLevel::INFO, array $additionalData = [])

Writes the given message along with the additional information into the log.

string
getPrecompiledReflectionStoragePath()

Determines the path to the precompiled reflection data.

bool
hasFrozenCacheInProduction()

No description

Details

void setStatusCache(StringFrontend $cache)

Sets the status cache

The cache must be set before initializing the Reflection Service

Parameters

StringFrontend $cache

Cache for the reflection service

Return Value

void

void setReflectionDataCompiletimeCache(VariableFrontend $cache)

Sets the compile-time data cache

Parameters

VariableFrontend $cache

Cache for the reflection service

Return Value

void

void setReflectionDataRuntimeCache(VariableFrontend $cache)

Sets the runtime data cache

Parameters

VariableFrontend $cache

Cache for the reflection service

Return Value

void

void setClassSchemataRuntimeCache(VariableFrontend $cache)

Sets the dedicated class schema cache for runtime purposes

Parameters

VariableFrontend $cache

Return Value

void

void injectSettings(array $settings)

No description

Parameters

array $settings

Settings of the Flow package

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

void injectPackageManager(PackageManager $packageManager)

No description

Parameters

PackageManager $packageManager

Return Value

void

void injectEnvironment(Environment $environment)

No description

Parameters

Environment $environment

Return Value

void

protected PhpParser getDoctrinePhpParser()

Retrieves a singleton instance of the Doctrine PhpParser

Return Value

PhpParser

protected void initialize()

Initialize the reflection service lazily

This method must be run only after all dependencies have been injected.

Return Value

void

void buildReflectionData(array $availableClassNames)

Builds the reflection data cache during compile time.

This method is called by the CompiletimeObjectManager which also determines the list of classes to consider for reflection.

Parameters

array $availableClassNames

List of all class names to consider for reflection

Return Value

void

bool isClassReflected(string $className)

Tells if the specified class is known to this reflection service and reflection information is available.

Parameters

string $className

Name of the class

Return Value

bool

If the class is reflected by this service

array getAllClassNames()

Returns the names of all classes known to this reflection service.

Return Value

array

Class names

mixed getDefaultImplementationClassNameForInterface(string $interfaceName)

Searches for and returns the class name of the default implementation of the given interface name. If no class implementing the interface was found or more than one implementation was found in the package defining the interface, false is returned.

Parameters

string $interfaceName

Name of the interface

Return Value

mixed

Either the class name of the default implementation for the object type or false

Exceptions

InvalidArgumentException

array getAllImplementationClassNamesForInterface(string $interfaceName)

Searches for and returns all class names of implementations of the given object type (interface name). If no class implementing the interface was found, an empty array is returned.

Parameters

string $interfaceName

Name of the interface

Return Value

array

An array of class names of the default implementation for the object type

Exceptions

InvalidArgumentException

array getAllSubClassNamesForClass(string $className)

Searches for and returns all names of classes inheriting the specified class.

If no class inheriting the given class was found, an empty array is returned.

Parameters

string $className

Name of the parent class

Return Value

array

An array of names of those classes being a direct or indirect subclass of the specified class

Exceptions

InvalidArgumentException

array getClassNamesByAnnotation(string $annotationClassName)

Searches for and returns all names of classes which are tagged by the specified annotation. If no classes were found, an empty array is returned.

Parameters

string $annotationClassName

Name of the annotation class, for example "Neos\Flow\Annotations\Aspect"

Return Value

array

bool isClassAnnotatedWith(string $className, string $annotationClassName)

Tells if the specified class has the given annotation

Parameters

string $className

Name of the class

string $annotationClassName

Annotation to check for

Return Value

bool

object[] getClassAnnotations(string $className, string $annotationClassName = null)

Returns the specified class annotations or an empty array

Parameters

string $className

Name of the class

string $annotationClassName

Annotation to filter for

Return Value

object[]

object|null getClassAnnotation(string $className, string $annotationClassName)

Returns the specified class annotation or NULL.

If multiple annotations are set on the target you will get the first instance of them.

Parameters

string $className

Name of the class

string $annotationClassName

Annotation to filter for

Return Value

object|null

bool isClassImplementationOf(string $className, string $interfaceName)

Tells if the specified class implements the given interface

Parameters

string $className

Name of the class

string $interfaceName

interface to check for

Return Value

bool

true if the class implements $interfaceName, otherwise false

bool isClassAbstract(string $className)

Tells if the specified class is abstract or not

Parameters

string $className

Name of the class to analyze

Return Value

bool

true if the class is abstract, otherwise false

bool isClassFinal(string $className)

Tells if the specified class is final or not

Parameters

string $className

Name of the class to analyze

Return Value

bool

true if the class is final, otherwise false

bool isClassUnconfigurable(string $className)

Tells if the class is unconfigurable or not

Parameters

string $className

Name of the class to analyze

Return Value

bool

return true if class not could not be automatically configured, otherwise false

array getClassesContainingMethodsAnnotatedWith(string $annotationClassName)

Returns all class names of classes containing at least one method annotated with the given annotation class

Parameters

string $annotationClassName

The annotation class name for a method annotation

Return Value

array

An array of class names

array getMethodsAnnotatedWith(string $className, string $annotationClassName)

Returns all names of methods of the given class that are annotated with the given annotation class

Parameters

string $className

Name of the class containing the method(s)

string $annotationClassName

The annotation class name for a method annotation

Return Value

array

An array of method names

bool isMethodFinal(string $className, string $methodName)

Tells if the specified method is final or not

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

Return Value

bool

true if the method is final, otherwise false

bool isMethodStatic(string $className, string $methodName)

Tells if the specified method is declared as static or not

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

Return Value

bool

true if the method is static, otherwise false

bool isMethodPublic(string $className, string $methodName)

Tells if the specified method is public

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

Return Value

bool

true if the method is public, otherwise false

bool isMethodProtected(string $className, string $methodName)

Tells if the specified method is protected

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

Return Value

bool

true if the method is protected, otherwise false

bool isMethodPrivate(string $className, string $methodName)

Tells if the specified method is private

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

Return Value

bool

true if the method is private, otherwise false

bool isMethodTaggedWith(string $className, string $methodName, string $tag)

Tells if the specified method is tagged with the given tag

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to analyze

string $tag

Tag to check for

Return Value

bool

true if the method is tagged with $tag, otherwise false

bool isAttributeIgnored(string $attributeName)

Tells if a specific PHP attribute is to be ignored for reflection

Parameters

string $attributeName

Return Value

bool

bool isMethodAnnotatedWith(string $className, string $methodName, string $annotationClassName)

Tells if the specified method has the given annotation

Parameters

string $className

Name of the class

string $methodName

Name of the method

string $annotationClassName

Annotation to check for

Return Value

bool

object[] getMethodAnnotations(string $className, string $methodName, string $annotationClassName = null)

Returns the specified method annotations or an empty array

Parameters

string $className

Name of the class

string $methodName

Name of the method

string $annotationClassName

Annotation to filter for

Return Value

object[]

object|null getMethodAnnotation(string $className, string $methodName, string $annotationClassName)

Returns the specified method annotation or NULL.

If multiple annotations are set on the target you will get the first instance of them.

Parameters

string $className

Name of the class

string $methodName

Name of the method

string $annotationClassName

Annotation to filter for

Return Value

object|null

array getClassPropertyNames(string $className)

Returns the names of all properties of the specified class

Parameters

string $className

Name of the class to return the property names of

Return Value

array

An array of property names or an empty array if none exist

bool hasMethod(string $className, string $methodName)

Wrapper for method_exists() which tells if the given method exists.

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method

Return Value

bool

array getMethodTagsValues(string $className, string $methodName)

Returns all tags and their values the specified method is tagged with

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to return the tags and values of

Return Value

array

An array of tags and their values or an empty array of no tags were found

array getMethodParameters(string $className, string $methodName)

Returns an array of parameters of the given method. Each entry contains additional information about the parameter position, type hint etc.

Parameters

string $className

Name of the class containing the method

string $methodName

Name of the method to return parameter information of

Return Value

array

An array of parameter names and additional information or an empty array of no parameters were found

string getMethodDeclaredReturnType(string $className, string $methodName)

Returns the declared return type of a method (for PHP < 7.0 this will always return null)

Parameters

string $className
string $methodName

Return Value

string

The declared return type of the method or null if none was declared

array getPropertyNamesByTag(string $className, string $tag)

Searches for and returns all names of class properties which are tagged by the specified tag.

If no properties were found, an empty array is returned.

Parameters

string $className

Name of the class containing the properties

string $tag

Tag to search for

Return Value

array

An array of property names tagged by the tag

array getPropertyTagsValues(string $className, string $propertyName)

Returns all tags and their values the specified class property is tagged with

Parameters

string $className

Name of the class containing the property

string $propertyName

Name of the property to return the tags and values of

Return Value

array

An array of tags and their values or an empty array of no tags were found

array getPropertyTagValues(string $className, string $propertyName, string $tag)

Returns the values of the specified class property tag

Parameters

string $className

Name of the class containing the property

string $propertyName

Name of the tagged property

string $tag

Tag to return the values of

Return Value

array

An array of values or an empty array if the tag was not found

string|null getPropertyType($className, $propertyName)

Returns the property type

Parameters

$className
$propertyName

Return Value

string|null

bool isPropertyPrivate(string $className, string $propertyName)

Tells if the specified property is private

Parameters

string $className

Name of the class containing the method

string $propertyName

Name of the property to analyze

Return Value

bool

true if the property is private, otherwise false

bool isPropertyTaggedWith(string $className, string $propertyName, string $tag)

Tells if the specified class property is tagged with the given tag

Parameters

string $className

Name of the class

string $propertyName

Name of the property

string $tag

Tag to check for

Return Value

bool

true if the class property is tagged with $tag, otherwise false

bool isPropertyAnnotatedWith(string $className, string $propertyName, string $annotationClassName)

Tells if the specified property has the given annotation

Parameters

string $className

Name of the class

string $propertyName

Name of the method

string $annotationClassName

Annotation to check for

Return Value

bool

array getPropertyNamesByAnnotation(string $className, string $annotationClassName)

Searches for and returns all names of class properties which are marked by the specified annotation. If no properties were found, an empty array is returned.

Parameters

string $className

Name of the class containing the properties

string $annotationClassName

Class name of the annotation to search for

Return Value

array

An array of property names carrying the annotation

object[] getPropertyAnnotations(string $className, string $propertyName, string $annotationClassName = null)

Returns the specified property annotations or an empty array

Parameters

string $className

Name of the class

string $propertyName

Name of the property

string $annotationClassName

Annotation to filter for

Return Value

object[]

object|null getPropertyAnnotation(string $className, string $propertyName, string $annotationClassName)

Returns the specified property annotation or NULL.

If multiple annotations are set on the target you will get the first instance of them.

Parameters

string $className

Name of the class

string $propertyName

Name of the property

string $annotationClassName

Annotation to filter for

Return Value

object|null

ClassSchema getClassSchema(mixed $classNameOrObject)

Returns the class schema for the given class

Parameters

mixed $classNameOrObject

The class name or an object

Return Value

ClassSchema

protected string prepareClassReflectionForUsage(string $className)

Initializes the ReflectionService, cleans the given class name and finally reflects the class if necessary.

Parameters

string $className

Return Value

string

The cleaned class name

protected void reflectEmergedClasses()

Checks if the given class names match those which already have been reflected. If the given array contains class names not yet known to this service, these classes will be reflected.

Return Value

void

Exceptions

Exception

protected bool isTagIgnored(string $tagName)

Check if a specific annotation tag is configured to be ignored.

Parameters

string $tagName

The annotation tag to check

Return Value

bool

true if the tag is configured to be ignored, false otherwise

protected void reflectClass(string $className)

Reflects the given class and stores the results in this service's properties.

Parameters

string $className

Full qualified name of the class to reflect

Return Value

void

Exceptions

InvalidClassException

int reflectClassProperty(string $className, PropertyReflection $property)

No description

Parameters

string $className
PropertyReflection $property

Return Value

int visibility

protected array reflectPropertyTag(string $className, PropertyReflection $property, string $tagName, array $tagValues)

No description

Parameters

string $className
PropertyReflection $property
string $tagName
array $tagValues

Return Value

array

protected void addParentClass(string $className, ClassReflection $parentClass)

No description

Parameters

string $className
ClassReflection $parentClass

Return Value

void

protected addImplementedInterface(string $className, ClassReflection $interface)

No description

Parameters

string $className
ClassReflection $interface

Exceptions

InvalidClassException

protected void reflectClassMethod(string $className, MethodReflection $method)

No description

Parameters

string $className
MethodReflection $method

Return Value

void

protected void reflectClassMethodParameter(string $className, MethodReflection $method, ParameterReflection $parameter)

No description

Parameters

string $className
MethodReflection $method
ParameterReflection $parameter

Return Value

void

protected string expandType(ClassReflection $class, string $type)

Expand shortened class names in "var" and "param" annotations, taking use statements into account.

Parameters

ClassReflection $class
string $type

the type inside var/param annotation

Return Value

string

the possibly expanded type

protected ClassReflection[] getParentClasses(ClassReflection $class, array $parentClasses = [])

Finds all parent classes of the given class

Parameters

ClassReflection $class

The class to reflect

array $parentClasses

Array of parent classes

Return Value

ClassReflection[]

protected void buildClassSchemata(array $classNames)

Builds class schemata from classes annotated as entities or value objects

Parameters

array $classNames

Return Value

void

protected ClassSchema buildClassSchema(string $className)

Builds a class schema for the given class name.

Parameters

string $className

Return Value

ClassSchema

protected void addPropertiesToClassSchema(ClassSchema $classSchema)

Adds properties of the class at hand to the class schema.

Properties will be added if they have a var annotation && (!transient-annotation && !inject-annotation)

Invalid annotations will cause an exception to be thrown.

Parameters

ClassSchema $classSchema

Return Value

void

Exceptions

InvalidPropertyTypeException

protected bool evaluateClassPropertyAnnotationsForSchema(ClassSchema $classSchema, string $propertyName)

No description

Parameters

ClassSchema $classSchema
string $propertyName

Return Value

bool

Exceptions

InvalidPropertyTypeException
InvalidArgumentException

protected void completeRepositoryAssignments()

Complete repository-to-entity assignments.

This method looks for repositories that declare themselves responsible for a specific model and sets a repository classname on the corresponding models.

It then walks the inheritance chain for all aggregate roots and checks the subclasses for their aggregate root status - if no repository is assigned yet, that will be done.

Return Value

void

Exceptions

ClassSchemaConstraintViolationException

protected void makeChildClassesAggregateRoot(ClassSchema $classSchema)

Assigns the repository of any aggregate root to all it's subclasses, unless they are aggregate root already.

Parameters

ClassSchema $classSchema

Return Value

void

protected void ensureAggregateRootInheritanceChainConsistency()

Checks whether all aggregate roots having superclasses have a repository assigned up to the tip of their hierarchy.

Return Value

void

Exceptions

Exception

protected void checkValueObjectRequirements(string $className)

Checks if the given class meets the requirements for a value object, i.e.

does have a constructor and does not have any setter methods.

Parameters

string $className

Return Value

void

Exceptions

InvalidValueObjectException

protected array convertParameterDataToArray(array $parametersInformation)

Converts the internal, optimized data structure of parameter information into a human-friendly array with speaking indexes.

Parameters

array $parametersInformation

Raw, internal parameter information

Return Value

array

Developer friendly version

protected array convertParameterReflectionToArray(ParameterReflection $parameter, MethodReflection $method)

Converts the given parameter reflection into an information array

Parameters

ParameterReflection $parameter

The parameter to reflect

MethodReflection $method

The parameter's method

Return Value

array

Parameter information array

protected void forgetChangedClasses()

Checks which classes lack a cache entry and removes their reflection data accordingly.

Return Value

void

protected void forgetClass(string $className)

Forgets all reflection data related to the specified class

Parameters

string $className

Name of the class to forget

Return Value

void

protected bool loadClassReflectionCompiletimeCache()

Tries to load the reflection data from the compile time cache.

The compile time cache is only supported for Development context and thus this function will return in any other context.

If no reflection data was found, this method will at least load the precompiled reflection data of any possible frozen package. Even if precompiled reflection data could be loaded, false will be returned in order to signal that other packages still need to be reflected.

Return Value

bool

true if reflection data could be loaded, otherwise false

protected void loadOrReflectClassIfNecessary(string $className)

Loads reflection data from the cache or reflects the class if needed.

If the class is completely unknown, this method won't try to load or reflect it. If it is known and reflection data has been loaded already, it won't be loaded again.

In Production context, with frozen caches, this method will load reflection data for the specified class from the runtime cache.

Parameters

string $className

Name of the class to load data for

Return Value

void

void freezePackageReflection(string $packageKey)

Stores the current reflection data related to classes of the specified package in the PrecompiledReflectionData directory for the current context.

This method is used by the package manager.

Parameters

string $packageKey

Return Value

void

protected array filterArrayByClassesInPackageNamespace(array $array, string $packageKey)

Filter an array of entries were keys are class names by being in the given package namespace.

Parameters

array $array
string $packageKey

Return Value

array

void unfreezePackageReflection(string $packageKey)

Removes the precompiled reflection data of a frozen package

This method is used by the package manager.

Parameters

string $packageKey

The package to remove the data from

Return Value

void

void saveToCache()

Exports the internal reflection data into the ReflectionData cache

This method is triggered by a signal which is connected to the bootstrap's shutdown sequence.

If the reflection data has previously been loaded from the runtime cache, saving it is omitted as changes are not expected.

In Production context the whole cache is written at once and then frozen in order to be consistent. Frozen cache data in Development is only produced for classes contained in frozen packages.

Return Value

void

Exceptions

Exception

protected saveDevelopmentData()

Save reflection data to cache in Development context.

protected saveProductionData()

Save reflection data to cache in Production context.

protected updateReflectionData()

Set updated reflection data to caches.

protected string cleanClassName(string $className)

Clean a given class name from possibly prefixed backslash

Parameters

string $className

Return Value

string

protected string produceCacheIdentifierFromClassName(string $className)

Transform backslashes to underscores to provide an valid cache identifier.

Parameters

string $className

Return Value

string

protected void log(string $message, string $severity = LogLevel::INFO, array $additionalData = [])

Writes the given message along with the additional information into the log.

Parameters

string $message

The message to log

string $severity

One of the PSR LogLevel constants

array $additionalData

An array containing more information about the event to be logged

Return Value

void

protected string getPrecompiledReflectionStoragePath()

Determines the path to the precompiled reflection data.

Return Value

string

protected bool hasFrozenCacheInProduction()

No description

Return Value

bool