Class Kitab\Compiler\IntermediateRepresentation\Entity

abstract class Entity
{
    pub fn getNamespaceName(): string;
    pub fn getShortName(): string;
    pub fn inNamespace(): bool;
    pub static fn getType(): string;
}

An entity intermediate representation.

This is an abstract class aiming at representing all kind of entity, like class, interface, trait, function…

Constants

pub const TYPE = '(unknown)';

The kind of the entity, defined as a simple string.

Attributes

pub $file

File containing the entity, as an instance of Kitab\Compiler\IntermediateRepresentation\File.

pub $lineStart = 0;

Unsigned integer representing where the entity declaration starts in the file.

pub $lineEnd = 0;

Unsigned integer representing where the entity declaration ends in the file.

pub $name

The fully-qualified name of the entity, i.e. it includes namespaces.

pub $documentation = null;

Associated documentation of the entity as an instance of Kitab\Compiler\IntermediateRepresentation\Documentation.

Methods

pub fn getNamespaceName(): string

The name of the entity without the short name, i.e. only the namespaces.

Examples

$class = new Kitab\Compiler\IntermediateRepresentation\Class_('Foo\\Bar\\Baz');

assert($class->getNamespaceName() === 'Foo\\Bar');
pub fn getShortName(): string

The name of the entity without the namespaces, only the short name.

Examples

$class = new Kitab\Compiler\IntermediateRepresentation\Class_('Foo\\Bar\\Baz');

assert($class->getShortName() === 'Baz');
pub fn inNamespace(): bool

An entity is in a namespace if its fully-qualified name contains at least one namespace separator (aka \).

Examples

$classA = new Kitab\Compiler\IntermediateRepresentation\Class_('Foo\\Bar\\Baz');

assert(true === $classA->inNamespace());

$classB = new Kitab\Compiler\IntermediateRepresentation\Class_('Qux');

assert(false === $classB->inNamespace());
pub static fn getType(): string

Return the type of the entity defined by the TYPE class constant.