ClassyDeclaration

A declared interface, trait, or class.

class ClassyDeclaration implements TokenDeclaration<ScannedClass>
Copyright
2016 Appertly
License
Apache-2.0

Constructors / Destructors

Public
ReturnsSignature and Description
void
__construct(ScannedClass $class, Block $block, ConstMap<string,PropertyDeclaration> $properties, ConstMap<string,MethodDeclaration> $methods, ConstMap<string,ConstantDeclaration> $constants, ConstMap<string,TypeConstantDeclaration> $typeConstants)

Creates a new ClassDeclaration.

Instance Methods

Public
ReturnsSignature and Description
?ConstantDeclaration
getConstant(string $name)

Gets a constant by name

ConstMap<string,ConstantDeclaration>

Gets all constants in this class by name

Block

Gets the doc comment block.

string

Gets the source filename.

?MethodDeclaration
getMethod(string $name)

Gets a method by name

ConstMap<string,MethodDeclaration>

Gets all methods in this class by name

string

Gets the name of the declaration.

ConstMap<string,PropertyDeclaration>

Gets all properties in this class by name

?PropertyDeclaration
getProperty(string $name)

Gets a property by name

ScannedClass

Gets the scanned token.

?TypeConstantDeclaration
getTypeConstant(string $name)

Gets a type constant by name

ConstMap<string,TypeConstantDeclaration>

Gets all type constants in this class by name

bool

Whether this class is an interface

bool

Whether this class is a trait

Static Methods

Public
ReturnsSignature and Description
ClassyDeclaration
factory(ScannedClass $token, Parser $parser, Mapper $mapper)

Convenience method to create a new ClassyDeclaration.

Protected
ReturnsSignature and Description
ConstMap<string,ConstantDeclaration>
mergeConstants(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited constants and make sure doc blocks are inherited.

ConstMap<string,MethodDeclaration>
mergeMethods(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited methods and make sure doc blocks are inherited.

ConstMap<string,PropertyDeclaration>
mergeProperties(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited properties and make sure doc blocks are inherited.

ConstMap<string,TypeConstantDeclaration>
mergeTypeConstants(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited constants and make sure doc blocks are inherited.

Method Details

__construct

public function __construct(ScannedClass $class, Block $block, ConstMap<string,PropertyDeclaration> $properties, ConstMap<string,MethodDeclaration> $methods, ConstMap<string,ConstantDeclaration> $constants, ConstMap<string,TypeConstantDeclaration> $typeConstants)

Creates a new ClassDeclaration.

Parameters
NameTypeDescription
$classScannedClass

The interface, trait, or class

$blockBlock
$propertiesConstMap<string,PropertyDeclaration>
$methodsConstMap<string,MethodDeclaration>
$constantsConstMap<string,ConstantDeclaration>
$typeConstantsConstMap<string,TypeConstantDeclaration>

factory

public static function factory(ScannedClass $token, Parser $parser, Mapper $mapper)

Convenience method to create a new ClassyDeclaration.

Parameters
NameTypeDescription
$tokenScannedClass

The class to read

$parserParser

The doc comment parser

$mapperMapper

The mapper

Returns
TypeDescription
ClassyDeclaration

The created ClassyDeclaration

getConstant

public function getConstant(string $name)

Gets a constant by name

Parameters
NameTypeDescription
$namestring

The constant name

Returns
TypeDescription
?ConstantDeclaration

The constant found or null

getConstants

public function getConstants()

Gets all constants in this class by name

Returns
TypeDescription
ConstMap<string,ConstantDeclaration>

All constants in this class

getDocBlock

public function getDocBlock()

Gets the doc comment block.

Returns
TypeDescription
Block

The doc block, which could be empty

getFilename

public function getFilename()

Gets the source filename.

Returns
TypeDescription
string

The filename

getMethod

public function getMethod(string $name)

Gets a method by name

Parameters
NameTypeDescription
$namestring

The method name

Returns
TypeDescription
?MethodDeclaration

The method found or null

getMethods

public function getMethods()

Gets all methods in this class by name

Returns
TypeDescription
ConstMap<string,MethodDeclaration>

All methods in this class

getName

public function getName()

Gets the name of the declaration.

Returns
TypeDescription
string

The declaration name

getProperties

public function getProperties()

Gets all properties in this class by name

Returns
TypeDescription
ConstMap<string,PropertyDeclaration>

All properties in this class

getProperty

public function getProperty(string $name)

Gets a property by name

Parameters
NameTypeDescription
$namestring

The property name

Returns
TypeDescription
?PropertyDeclaration

The property found or null

getToken

public function getToken()

Gets the scanned token.

Returns
TypeDescription
ScannedClass

The scanned token

getTypeConstant

public function getTypeConstant(string $name)

Gets a type constant by name

Parameters
NameTypeDescription
$namestring

The constant name

Returns
TypeDescription
?TypeConstantDeclaration

The type constant found or null

getTypeConstants

public function getTypeConstants()

Gets all type constants in this class by name

Returns
TypeDescription
ConstMap<string,TypeConstantDeclaration>

All type constants in this class

isInterface

public function isInterface()

Whether this class is an interface

Returns
TypeDescription
bool

true if this class is an interface

isTrait

public function isTrait()

Whether this class is a trait

Returns
TypeDescription
bool

true if this class is a trait

mergeConstants

static protected function mergeConstants(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited constants and make sure doc blocks are inherited.

Parameters
NameTypeDescription
$cScannedClass

The token

$parserParser

The doc block parser

$mapperMapper

The mapper

Returns
TypeDescription
ConstMap<string,ConstantDeclaration>

The constants by name

mergeMethods

static protected function mergeMethods(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited methods and make sure doc blocks are inherited.

Parameters
NameTypeDescription
$cScannedClass

The token

$parserParser

The doc block parser

$mapperMapper

The mapper

Returns
TypeDescription
ConstMap<string,MethodDeclaration>

The methods by name

mergeProperties

static protected function mergeProperties(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited properties and make sure doc blocks are inherited.

Parameters
NameTypeDescription
$cScannedClass

The token

$parserParser

The doc block parser

$mapperMapper

The mapper

Returns
TypeDescription
ConstMap<string,PropertyDeclaration>

The properties by name

mergeTypeConstants

static protected function mergeTypeConstants(ScannedClass $c, Parser $parser, Mapper $mapper)

Grab any inherited constants and make sure doc blocks are inherited.

Parameters
NameTypeDescription
$cScannedClass

The token

$parserParser

The doc block parser

$mapperMapper

The mapper

Returns
TypeDescription
ConstMap<string,TypeConstantDeclaration>

The constants by name