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

protected VISIBILITY_PRIVATE

protected VISIBILITY_PROTECTED

protected VISIBILITY_PUBLIC

protected DATA_INTERFACE_IMPLEMENTATIONS

protected DATA_CLASS_INTERFACES

protected DATA_CLASS_SUBCLASSES

protected DATA_CLASS_TAGS_VALUES

protected DATA_CLASS_ANNOTATIONS

protected DATA_CLASS_ABSTRACT

protected DATA_CLASS_FINAL

protected DATA_CLASS_READONLY

protected DATA_CLASS_METHODS

protected DATA_CLASS_PROPERTIES

protected DATA_METHOD_FINAL

protected DATA_METHOD_STATIC

protected DATA_METHOD_VISIBILITY

protected DATA_METHOD_PARAMETERS

protected DATA_METHOD_DECLARED_RETURN_TYPE

protected DATA_PROPERTY_TAGS_VALUES

protected DATA_PROPERTY_ANNOTATIONS

protected DATA_PROPERTY_VISIBILITY

protected DATA_PROPERTY_TYPE

protected DATA_PROPERTY_PROMOTED

protected DATA_PARAMETER_POSITION

protected DATA_PARAMETER_OPTIONAL

protected DATA_PARAMETER_TYPE

protected DATA_PARAMETER_ARRAY

protected DATA_PARAMETER_CLASS

protected DATA_PARAMETER_ALLOWS_NULL

protected DATA_PARAMETER_DEFAULT_VALUE

protected DATA_PARAMETER_BY_REFERENCE

protected DATA_PARAMETER_SCALAR_DECLARATION

protected DATA_PARAMETER_ANNOTATIONS

Properties

protected $annotationReader
protected $availableClassNames
protected $statusCache
protected $reflectionDataCompiletimeCache
protected $reflectionDataRuntimeCache
protected $classSchemataRuntimeCache
protected $logger
protected $packageManager
protected $environment
protected $context
protected $doctrinePhpParser

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

protected $useStatementsForClassCache

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

protected $loadFromClassSchemaRuntimeCache

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

protected $settings
protected $annotatedClasses

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

protected $classesByMethodAnnotations

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

protected ClassSchema|false> $classSchemata

Schemata of all classes which can be persisted

protected $classesCurrentlyBeingForgotten

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

protected $classReflectionData

Array with reflection information indexed by class name

protected $updatedReflectionData

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

protected $initialized
protected $methodAnnotationsRuntimeCache

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

Methods

void
setStatusCache(StringFrontend $cache)

Sets the status cache

void
void
void
injectSettings(array $settings)

No description

void
injectLogger(LoggerInterface $logger)

No description

void
injectPackageManager(PackageManager $packageManager)

No description

void
injectEnvironment(Environment $environment)

No description

PhpParser
getDoctrinePhpParser()

No description

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.

string|bool
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

array
getClassAnnotations(string $className, string|null $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
isClassReadonly(string $className)

Tells if the specified class is readonly 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

array
getMethodAnnotations(string $className, string $methodName, string|null $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|null
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.

mixed
getPropertyTagsValues(string $className, string $propertyName)

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

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

Returns the values of the specified class property tag

string|null
getPropertyType(string $className, string $propertyName)

Returns the property type

bool
isPropertyPrivate(string $className, string $propertyName)

Tells if the specified property is private

bool
isPropertyPromoted(string $className, string $propertyName)

Tells if the specified property is promoted

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.

array
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.

ClassSchema|null
getClassSchema(string|object $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|null
reflectPropertyTag(string $className, PropertyReflection $property, string $tagName, array $tagValues)

No description

void
addParentClass(string $className, ClassReflection $parentClass)

No description

void
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.

array
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)

No description

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((int|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((int|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, int|string $packageKey)

Filter an array of entries where 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

void
saveDevelopmentData()

Save reflection data to cache in Development context.

void
saveProductionData()

Save reflection data to cache in Production context.

void
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 a 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
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

Return Value

void

void setReflectionDataCompiletimeCache(VariableFrontend $cache)

No description

Parameters

VariableFrontend $cache

Return Value

void

void setReflectionDataRuntimeCache(VariableFrontend $cache)

No description

Parameters

VariableFrontend $cache

Return Value

void

void setClassSchemataRuntimeCache(VariableFrontend $cache)

No description

Parameters

VariableFrontend $cache

Return Value

void

void injectSettings(array $settings)

No description

Parameters

array $settings

Return Value

void

void injectLogger(LoggerInterface $logger)

No description

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()

No description

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

Exceptions

FilesException
Exception

void buildReflectionData(array $availableClassNames)

Builds the reflection data cache during compile time.

This method is called by the Compile Time Object Manager which also determines the list of classes to consider for reflection.

bool isClassReflected(string $className)

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

Parameters

string $className

Return Value

bool

array getAllClassNames()

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

Return Value

array

string|bool 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

Return Value

string|bool

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

Return Value

array

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException

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

Return Value

array

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException

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

Return Value

array

bool isClassAnnotatedWith(string $className, string $annotationClassName)

Tells if the specified class has the given annotation

Parameters

string $className
string $annotationClassName

Return Value

bool

array getClassAnnotations(string $className, string|null $annotationClassName = null)

Returns the specified class annotations or an empty array

Parameters

string $className
string|null $annotationClassName

Return Value

array

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
string $annotationClassName

Return Value

object|null

bool isClassImplementationOf(string $className, string $interfaceName)

Tells if the specified class implements the given interface

Parameters

string $className
string $interfaceName

Return Value

bool

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException

bool isClassAbstract(string $className)

Tells if the specified class is abstract or not

Parameters

string $className

Return Value

bool

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 isClassReadonly(string $className)

Tells if the specified class is readonly or not

Parameters

string $className

Name of the class to analyze

Return Value

bool

true if the class is readonly, otherwise false

bool isClassUnconfigurable(string $className)

Tells if the class is unconfigurable or not

Parameters

string $className

Return Value

bool

array getClassesContainingMethodsAnnotatedWith(string $annotationClassName)

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

Parameters

string $annotationClassName

Return Value

array

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
string $annotationClassName

Return Value

array

bool isMethodFinal(string $className, string $methodName)

Tells if the specified method is final or not

Parameters

string $className
string $methodName

Return Value

bool

bool isMethodStatic(string $className, string $methodName)

Tells if the specified method is declared as static or not

Parameters

string $className
string $methodName

Return Value

bool

bool isMethodPublic(string $className, string $methodName)

Tells if the specified method is public

Parameters

string $className
string $methodName

Return Value

bool

bool isMethodProtected(string $className, string $methodName)

Tells if the specified method is protected

Parameters

string $className
string $methodName

Return Value

bool

bool isMethodPrivate(string $className, string $methodName)

Tells if the specified method is private

Parameters

string $className
string $methodName

Return Value

bool

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

Tells if the specified method is tagged with the given tag

Parameters

string $className
string $methodName
string $tag

Return Value

bool

Exceptions

ReflectionException

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
string $methodName
string $annotationClassName

Return Value

bool

Exceptions

ReflectionException

array getMethodAnnotations(string $className, string $methodName, string|null $annotationClassName = null)

Returns the specified method annotations or an empty array

Parameters

string $className
string $methodName
string|null $annotationClassName

Return Value

array

Exceptions

FilesException
ReflectionException
Exception

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
string $methodName
string $annotationClassName

Return Value

object|null

Exceptions

ReflectionException

array getClassPropertyNames(string $className)

Returns the names of all properties of the specified class

Parameters

string $className

Return Value

array

bool hasMethod(string $className, string $methodName)

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

Parameters

string $className
string $methodName

Return Value

bool

array getMethodTagsValues(string $className, string $methodName)

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

Parameters

string $className
string $methodName

Return Value

array

Exceptions

ReflectionException

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
string $methodName

Return Value

array

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

string|null 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|null

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
string $tag

Return Value

array

mixed getPropertyTagsValues(string $className, string $propertyName)

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

Parameters

string $className
string $propertyName

Return Value

mixed

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

Returns the values of the specified class property tag

Parameters

string $className
string $propertyName
string $tag

string|null getPropertyType(string $className, string $propertyName)

Returns the property type

Parameters

string $className
string $propertyName

Return Value

string|null

bool isPropertyPrivate(string $className, string $propertyName)

Tells if the specified property is private

Parameters

string $className
string $propertyName

Return Value

bool

bool isPropertyPromoted(string $className, string $propertyName)

Tells if the specified property is promoted

Parameters

string $className
string $propertyName

Return Value

bool

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

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

Parameters

string $className
string $propertyName
string $tag

Return Value

bool

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

Tells if the specified property has the given annotation

Parameters

string $className
string $propertyName
string $annotationClassName

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
string $annotationClassName

Return Value

array

array getPropertyAnnotations(string $className, string $propertyName, string $annotationClassName = null)

Returns the specified property annotations or an empty array

Parameters

string $className
string $propertyName
string $annotationClassName

Return Value

array

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
string $propertyName
string $annotationClassName

Return Value

object|null

ClassSchema|null getClassSchema(string|object $classNameOrObject)

Returns the class schema for the given class

Parameters

string|object $classNameOrObject

Return Value

ClassSchema|null

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

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.

protected bool isTagIgnored(string $tagName)

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

Parameters

string $tagName

Return Value

bool

protected void reflectClass(string $className)

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

Parameters

string $className

Return Value

void

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException
ReflectionException

int reflectClassProperty(string $className, PropertyReflection $property)

No description

Parameters

string $className
PropertyReflection $property

Return Value

int visibility

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

No description

Parameters

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

Return Value

array|null

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

No description

Parameters

string $className
ClassReflection $parentClass

Return Value

void

Exceptions

InvalidClassException
ClassLoadingForReflectionFailedException
ReflectionException

protected void addImplementedInterface(string $className, ClassReflection $interface)

No description

Parameters

string $className
ClassReflection $interface

Return Value

void

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException
ReflectionException

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

No description

Parameters

string $className
MethodReflection $method

Return Value

void

Exceptions

FilesException
ReflectionException
Exception

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

Return Value

string

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

Finds all parent classes of the given class

Parameters

ClassReflection $class
array $parentClasses

Return Value

array

protected void buildClassSchemata(array $classNames)

Builds class schemata from classes annotated as entities or value objects

protected ClassSchema buildClassSchema(string $className)

No description

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
ClassSchemaConstraintViolationException

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

No description

Parameters

ClassSchema $classSchema
string $propertyName

Return Value

bool

Exceptions

InvalidPropertyTypeException
InvalidArgumentException
ClassSchemaConstraintViolationException

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.

protected void makeChildClassesAggregateRoot(ClassSchema $classSchema)

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

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
MethodReflection $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((int|string) $className)

Forgets all reflection data related to the specified class

Parameters

(int|string) $className

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

Exceptions

FilesException
Exception

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

Return Value

void

Exceptions

ClassLoadingForReflectionFailedException
InvalidClassException
ReflectionException

void freezePackageReflection((int|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

(int|string) $packageKey

Return Value

void

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

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

Parameters

array $array
int|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

Return Value

void

Exceptions

FilesException
Exception

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 void saveDevelopmentData()

Save reflection data to cache in Development context.

Return Value

void

Exceptions

FilesException
Exception

protected void saveProductionData()

Save reflection data to cache in Production context.

Return Value

void

Exceptions

Exception

protected void updateReflectionData()

Set updated reflection data to caches.

Return Value

void

Exceptions

Exception

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 a 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
string $severity
array $additionalData

Return Value

void

protected string getPrecompiledReflectionStoragePath()

No description

Return Value

string

Exceptions

Exception
FilesException

protected bool hasFrozenCacheInProduction()

No description

Return Value

bool