Class Kitab\Compiler\IntermediateRepresentation\Entity
abstract class Entity
{
public function getNamespaceName(): string;
public function getShortName(): string;
public function inNamespace(): bool;
public static function getType(): string;
}
An entity intermediate representation.
This is an abstract class aiming at representing all kind of entity, like class, interface, trait, function…
Constants
public const TYPE = '(unknown)';
-
The kind of the entity, defined as a simple string.
Attributes
public $file
-
File containing the entity, as an instance of
Kitab\Compiler\IntermediateRepresentation\File
. public $lineStart = 0;
-
Unsigned integer representing where the entity declaration starts in the file.
public $lineEnd = 0;
-
Unsigned integer representing where the entity declaration ends in the file.
public $name
-
The fully-qualified name of the entity, i.e. it includes namespaces.
public $documentation = null;
-
Associated documentation of the entity as an instance of
Kitab\Compiler\IntermediateRepresentation\Documentation
.
Methods
-
public function 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');
-
public function 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');
-
public function 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());
-
public static function getType(): string
-
Return the type of the entity defined by the
TYPE
class constant.