Composes roles that refine PHP classes.

There are two sensible ways to implement this kind of composer: mixin-based inheritance and superimposition. Here, we implement the former because of its relative simplicity (though it has runtime overhead).

package Default
inherited_from \FeaturePhp\Collaboration\Composer

 Methods

Creates a class composer.

__construct(string $targetClass = null, string $parentClass = null, array<mixed,array> $ast = array()

Parameters

$targetClass

string

$parentClass

string

$ast

array<mixed,array>

Creates a composer from a kind.

fromKind(string $kind) : \FeaturePhp\Collaboration\Composer
InheritedStatic

Parameters

$kind

string

Returns

\FeaturePhp\Collaboration\Composer

Returns a map from all composer kinds to class names.

getComposerMap() : array<mixed,string>
InheritedStatic

Returns

array<mixed,string>

Returns the refined file's content.

getContent() : \FeaturePhp\File\TextFileContent
inherited_from \FeaturePhp\Collaboration\Composer::getContent()

Returns

\FeaturePhp\File\TextFileContent

Returns the refined file's content.

getContent() : \FeaturePhp\File\FileContent
Inherited

Returns

\FeaturePhp\File\FileContent

Returns the class composer's kind.

getKind() : string
inherited_from \FeaturePhp\Collaboration\Composer::getKind()

Returns

string

Returns the composer's kind.

getKind() : string
Inherited

Returns

string

Returns a new class composer containing a role's refinements.

refine(\FeaturePhp\Collaboration\Role $role) : \FeaturePhp\Collaboration\ClassComposer
inherited_from \FeaturePhp\Collaboration\Composer::refine()

Parameters

$role

\FeaturePhp\Collaboration\Role

Returns

\FeaturePhp\Collaboration\ClassComposer

Returns a new composer containing a role's refinements.

refine(\FeaturePhp\Collaboration\Role $role) : \FeaturePhp\Collaboration\Composer
Inherited

Parameters

$role

\FeaturePhp\Collaboration\Role

Returns

\FeaturePhp\Collaboration\Composer

Extends a class with the parent class.

extendClass(\PhpParser\Node\Stmt\Class_ $class) 

Parameters

$class

\PhpParser\Node\Stmt\Class_

Returns the class names of all composers.

getComposers() : array<mixed,string>
InheritedStatic

Returns

array<mixed,string>

Returns the mangled class name for a role.

getMangledClassName(\FeaturePhp\Collaboration\Role $role) : string

The mangled class name encodes the corresponding feature identifier, this facilitates debugging.

Parameters

$role

\FeaturePhp\Collaboration\Role

Returns

string

Mangles the class name for a role.

mangleClassName(\PhpParser\Node\Stmt\Class_ $class, \FeaturePhp\Collaboration\Role $role) 

Parameters

$class

\PhpParser\Node\Stmt\Class_

$role

\FeaturePhp\Collaboration\Role

 Properties

 

the abstract syntax tree so far

$ast : array<mixed,array>

Default

 

the name of the parent class that is being refined

$parentClass : string

Default

 

the name of the target class (defined by the first role)

$targetClass : string

Default