Class Kitab\Compiler\IntermediateRepresentation\Trait_

class Trait_ extends Kitab\Compiler\IntermediateRepresentation\Entity
{
    pub fn __construct(string $name);
    pub fn 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

pub const TYPE = 'trait';

Type of the entity. See parent.

Attributes

pub $parent = null;

Fully-qualified name of the trait it extends if any.

pub $attributes = [];

Collection of Kitab\Compiler\IntermediateRepresentation\Attribute instances.

pub $methods = [];

Collection of Kitab\Compiler\IntermediateRepresentation\Method instances.

Methods

pub fn __construct(string $name)

Allocate a trait with a fully-qualified name. This is the only mandatory information.

pub fn getMethods(): array

Return all methods declared for this entity.

Interfaces

interface Kitab\Compiler\IntermediateRepresentation\HasMethods