Class Kitab\Compiler\IntermediateRepresentation\Trait_
class Trait_ extends Kitab\Compiler\IntermediateRepresentation\Entity
{
public function __construct(string $name);
public function getMethods(): array;
}
A trait intermediate representation.
A trait is one of the major entity in PHP. It exposes attributes, and methods. A trait can inherit from one other trait.
Examples
In this example, a new trait T
is built, with 2 attributes: foo
and bar
, and one method: f
.
$trait = new Kitab\Compiler\IntermediateRepresentation\Trait_('T');
$trait->attributes[] = new Kitab\Compiler\IntermediateRepresentation\Attribute('foo');
$trait->attributes[] = new Kitab\Compiler\IntermediateRepresentation\Attribute('bar');
$trait->methods[] = new Kitab\Compiler\IntermediateRepresentation\Method('f');
Constants
public const TYPE = 'trait';
-
Type of the entity. See parent.
Attributes
public $parent = null;
-
Fully-qualified name of the trait it extends if any.
public $attributes = [];
-
Collection of
Kitab\Compiler\IntermediateRepresentation\Attribute
instances. public $methods = [];
-
Collection of
Kitab\Compiler\IntermediateRepresentation\Method
instances.
Methods
-
public function __construct(string $name)
-
Allocate a trait with a fully-qualified name. This is the only mandatory information.
-
public function getMethods(): array
-
Return all methods declared for this entity.
Interfaces
interface Kitab\Compiler\IntermediateRepresentation\HasMethods
- …