DescriptorRepository
in package
Table of Contents
- CONTEXT_MARKER = '@context'
- $elementList : array<string|int, DescriptorAbstract>
- findAlias() : DescriptorAbstract|string|null
- Attempts to find a Descriptor object alias with the FQSEN of the element it represents.
- setObjectAliasesList() : void
- Sets the list of object aliases to resolve the FQSENs with.
- fetchElementByFqsen() : DescriptorAbstract|null
- Attempts to find an element with the given Fqsen in the list of elements for this project and returns null if it cannot find it.
- getTypeWithClassAsContext() : string
- Normalizes the given FQSEN as if the context marker represents a class/interface/trait as parent.
- getTypeWithGlobalNamespaceAsContext() : string
- Normalizes the given FQSEN as if the context marker represents the global namespace as parent.
- getTypeWithNamespaceAsContext() : string
- Normalizes the given FQSEN as if the context marker represents a class/interface/trait as parent.
- isContextMarkerInFqsen() : bool
- Returns true if the context marker is found in the given FQSEN.
- replacePseudoTypes() : string
- Replaces pseudo-types, such as `self`, into a normalized version based on the last container that was encountered.
Constants
CONTEXT_MARKER
private
mixed
CONTEXT_MARKER
= '@context'
Properties
$elementList
private
array<string|int, DescriptorAbstract>
$elementList
= []
Methods
findAlias()
Attempts to find a Descriptor object alias with the FQSEN of the element it represents.
public
findAlias(string $fqsen[, DescriptorAbstract|null $container = null ]) : DescriptorAbstract|string|null
This method will try to fetch an element after normalizing the provided FQSEN. The FQSEN may contain references
(bindings) that can only be resolved during linking (such as self
) or it may contain a context marker
CONTEXT_MARKER.
If there is a context marker then this method will see if a child of the given container exists that matches the element following the marker. If such a child does not exist in the current container then the namespace is queried if a child exists there that matches.
For example:
Given the Fqsen `@context::myFunction()` and the lastContainer `\My\Class` will this method first check
to see if `\My\Class::myFunction()` exists; if it doesn't it will then check if `\My\myFunction()` exists.
If neither element exists then this method assumes it is an undocumented class/trait/interface and change the
given FQSEN by returning the namespaced element name (thus in the example above that would be
\My\myFunction()
). The calling method substitute() will then replace the value of the field containing
the context marker with this normalized string.
Parameters
- $fqsen : string
- $container : DescriptorAbstract|null = null
Return values
DescriptorAbstract|string|null —setObjectAliasesList()
Sets the list of object aliases to resolve the FQSENs with.
public
setObjectAliasesList(array<string|int, DescriptorAbstract> $elementList) : void
Parameters
- $elementList : array<string|int, DescriptorAbstract>
Return values
void —fetchElementByFqsen()
Attempts to find an element with the given Fqsen in the list of elements for this project and returns null if it cannot find it.
private
fetchElementByFqsen(string $fqsen) : DescriptorAbstract|null
Parameters
- $fqsen : string
Return values
DescriptorAbstract|null —getTypeWithClassAsContext()
Normalizes the given FQSEN as if the context marker represents a class/interface/trait as parent.
private
getTypeWithClassAsContext(string $fqsen, DescriptorAbstract $container) : string
Parameters
- $fqsen : string
- $container : DescriptorAbstract
Return values
string —getTypeWithGlobalNamespaceAsContext()
Normalizes the given FQSEN as if the context marker represents the global namespace as parent.
private
getTypeWithGlobalNamespaceAsContext(string $fqsen) : string
Parameters
- $fqsen : string
Return values
string —getTypeWithNamespaceAsContext()
Normalizes the given FQSEN as if the context marker represents a class/interface/trait as parent.
private
getTypeWithNamespaceAsContext(string $fqsen, DescriptorAbstract $container) : string
Parameters
- $fqsen : string
- $container : DescriptorAbstract
Return values
string —isContextMarkerInFqsen()
Returns true if the context marker is found in the given FQSEN.
private
isContextMarkerInFqsen(string $fqsen) : bool
Parameters
- $fqsen : string
Return values
bool —replacePseudoTypes()
Replaces pseudo-types, such as `self`, into a normalized version based on the last container that was encountered.
private
replacePseudoTypes(string $fqsen, DescriptorAbstract $container) : string
Parameters
- $fqsen : string
- $container : DescriptorAbstract