Linker
The linker contains all rules to replace FQSENs in the ProjectDescriptor with aliases to objects.
This object contains a list of class FQCNs for Descriptors and their associated linker rules.
An example scenario should be:
The Descriptor ``\phpDocumentor\Descriptor\ClassDescriptor`` has a *Substitute* rule determining that the
contents of the ``Parent`` field should be substituted with another ClassDescriptor with the FQCN
represented by the value of the Parent field. In addition (second element) it has an *Analyse* rule
specifying that the contents of the ``Methods`` field should be interpreted by the linker. Because that field
contains an array or Descriptor Collection will each element be analysed by the linker.
As can be seen in the above example is it possible to analyse a tree structure and substitute FQSENs where encountered.
Interfaces, Classes & Used Traits
- CompilerPassInterface
- Represents a single pass / business rule to be executed by the Compiler.
Constants
COMPILER_PRIORITY Line 54
mixed COMPILER_PRIORITY = 10000
Properties
$substitutions Line 57
private$substitutions : string[][]
$processedObjects Line 60
private$processedObjects : string[]
$descriptorRepository Line 63
private$descriptorRepository : \phpDocumentor\Compiler\Linker\DescriptorRepository
Methods
getDescription() Line 65
Returns a textual description of what this pass does for output purposes.
publicgetDescription() : string
Please note that the command line will be truncated to 68 characters (
Returns
string —
__construct() Line 75
Initializes the linker with a series of Descriptors to link to.
public__construct(string[][] $substitutions, DescriptorRepository $descriptorRepository) : mixed
This method will execute the business logic associated with a given compiler pass and allow it to manipulate or consumer the Object Graph using the ProjectDescriptor object.
getSubstitutions() Line 97
Returns the list of substitutions for the linker.
publicgetSubstitutions() : string[][]
Returns
string[][] —
substitute() Line 130
Substitutes the given item or its children's FQCN with an object alias.
publicsubstitute(mixed $item[, DescriptorAbstract|null $container = null ]) : string|DescriptorAbstract|array|null
This method may do either of the following depending on the item's type
FQSEN or String If the given item is a string then this method will attempt to find an appropriate Class, Interface or TraitDescriptor object and return that. See \phpDocumentor\Compiler\Linker\DescriptorRepository::findAlias() for more information on the normalization of these strings.
Array or Traversable Iterate through each item, pass each key's contents to a new call to substitute and replace the key's contents if the contents is not an object (objects automatically update and this saves performance).
Object Determines all eligible substitutions using the substitutions property, construct a getter and retrieve the field's contents. Pass these contents to a new call of substitute and use a setter to replace the field's contents if anything other than null is returned.
This method will return null if no substitution was possible and all of the above should not update the parent item when null is passed.
Parameters
A descriptor that acts as container for all elements underneath or null if there is no current container.
Returns
string|DescriptorAbstract|array|null —
substituteChildrenOfCollection() Line 165
privatesubstituteChildrenOfCollection(iterable $collection, DescriptorAbstract|null $container) : array
Parameters
Returns
array —<string|DescriptorAbstract|null>|(ArrayAccess<array-key, string|DescriptorAbstract>&iterable<array-key, string|DescriptorAbstract>)|null
findFieldValue() Line 191
Returns the value of a field in the given object.
privatefindFieldValue(object $object, string $fieldName) : string|object
Parameters
Returns
string|object —
isDescriptorContainer() Line 201
Returns true if the given Descriptor is a container type.
privateisDescriptorContainer(object $item) : bool