class AbstractPhpStruct extends AbstractModel implements NamespaceInterface, DocblockInterface

Represents an abstract php structure (class, trait or interface).

Traits

Docblock Part
Long description part
Qualified name part
Name part

Methods

string
getDescription()

Returns this description

$this
setDescription(string|array $description)

Sets the description, which will also be used when generating a docblock

$this
setDocblock(Docblock|string $doc)

Sets the docblock

Docblock
getDocblock()

Returns the docblock

string
getLongDescription()

Returns the long description

$this
setLongDescription(string $longDescription)

Sets the long description

$this
setName(string $name)

Sets the name

from NamePart
string
getName()

Returns the name

from NamePart
$this
setNamespace(string $namespace)

Sets the namespace

$this
setQualifiedName(string $name)

In contrast to setName(), this method accepts the fully qualified name including the namespace.

string
getNamespace()

Returns the namespace

string
getQualifiedName()

Returns the qualified name

create(string $name = null)

Creates a new struct

__construct(string $name = null)

Creates a new struct

$this
setRequiredFiles(array $files)

Sets requried files

$this
addRequiredFile(string $file)

Adds a new required file

Set
getRequiredFiles()

Returns required files

$this
setUseStatements(array $useStatements)

Sets use statements

$this
addUseStatement(string $qualifiedName, null|string $alias = null)

Adds a use statement with an optional alias

$this
clearUseStatements()

Clears all use statements

$this
declareUses()

Declares multiple use statements at once.

string
declareUse(string $qualifiedName, null|string $alias = null)

Declares a "use $fullClassName" with " as $alias" if $alias is available, and returns its alias (or not qualified classname) to be used in your actual php code.

bool
hasUseStatement(string $qualifiedName)

Returns whether the given use statement is present

string
getUseAlias(string $qualifiedName)

Returns the usable alias for a qualified name

$this
removeUseStatement(string $qualifiedName)

Removes a use statement

Map
getUseStatements()

Returns all use statements

$this
setMethods(array $methods)

Sets a collection of methods

$this
setMethod(PhpMethod $method)

Adds a method

$this
removeMethod(string|PhpMethod $nameOrMethod)

Removes a method

bool
hasMethod(string|PhpMethod $nameOrMethod)

Checks whether a method exists or not

getMethod(string $nameOrMethod)

Returns a method

Map
getMethods()

Returns all methods

Set
getMethodNames()

Returns all method names

$this
clearMethods()

Clears all methods

$this
generateDocblock()

Generates a docblock from provided information

Details

in AbstractModel at line line 19
string getDescription()

Returns this description

Return Value

string

in AbstractModel at line line 29
$this setDescription(string|array $description)

Sets the description, which will also be used when generating a docblock

Parameters

string|array $description

Return Value

$this

in DocblockPart at line line 24
$this setDocblock(Docblock|string $doc)

Sets the docblock

Parameters

Docblock|string $doc

Return Value

$this

in DocblockPart at line line 39
Docblock getDocblock()

Returns the docblock

Return Value

Docblock

in LongDescriptionPart at line line 21
string getLongDescription()

Returns the long description

Return Value

string

in LongDescriptionPart at line line 31
$this setLongDescription(string $longDescription)

Sets the long description

Parameters

string $longDescription

Return Value

$this

in NamePart at line line 22
$this setName(string $name)

Sets the name

Parameters

string $name

Return Value

$this

in NamePart at line line 33
string getName()

Returns the name

Return Value

string

in QualifiedNamePart at line line 24
$this setNamespace(string $namespace)

Sets the namespace

Parameters

string $namespace

Return Value

$this

in QualifiedNamePart at line line 37
$this setQualifiedName(string $name)

In contrast to setName(), this method accepts the fully qualified name including the namespace.

Parameters

string $name

Return Value

$this

in QualifiedNamePart at line line 56
string getNamespace()

Returns the namespace

Return Value

string

in QualifiedNamePart at line line 65
string getQualifiedName()

Returns the qualified name

Return Value

string

at line line 53
static AbstractPhpStruct create(string $name = null)

Creates a new struct

Parameters

string $name the fqcn

Return Value

AbstractPhpStruct

at line line 62
__construct(string $name = null)

Creates a new struct

Parameters

string $name the fqcn

at line line 76
$this setRequiredFiles(array $files)

Sets requried files

Parameters

array $files

Return Value

$this

at line line 88
$this addRequiredFile(string $file)

Adds a new required file

Parameters

string $file

Return Value

$this

at line line 99
Set getRequiredFiles()

Returns required files

Return Value

Set collection of filenames

at line line 111
$this setUseStatements(array $useStatements)

Sets use statements

Parameters

array $useStatements

Return Value

$this

See also

#addUseStatement
#declareUses()

at line line 127
$this addUseStatement(string $qualifiedName, null|string $alias = null)

Adds a use statement with an optional alias

Parameters

string $qualifiedName
null|string $alias

Return Value

$this

at line line 146
$this clearUseStatements()

Clears all use statements

Return Value

$this

at line line 158
$this declareUses()

Declares multiple use statements at once.

Return Value

$this

at line line 176
string declareUse(string $qualifiedName, null|string $alias = null)

Declares a "use $fullClassName" with " as $alias" if $alias is available, and returns its alias (or not qualified classname) to be used in your actual php code.

If the class has already been declared you get only the set alias.

Parameters

string $qualifiedName
null|string $alias

Return Value

string the used alias

at line line 190
bool hasUseStatement(string $qualifiedName)

Returns whether the given use statement is present

Parameters

string $qualifiedName

Return Value

bool

at line line 200
string getUseAlias(string $qualifiedName)

Returns the usable alias for a qualified name

Parameters

string $qualifiedName

Return Value

string the alias

at line line 210
$this removeUseStatement(string $qualifiedName)

Removes a use statement

Parameters

string $qualifiedName

Return Value

$this

at line line 220
Map getUseStatements()

Returns all use statements

Return Value

Map collection of use statements

at line line 230
$this setMethods(array $methods)

Sets a collection of methods

Parameters

array $methods

Return Value

$this

at line line 249
$this setMethod(PhpMethod $method)

Adds a method

Parameters

PhpMethod $method

Return Value

$this

at line line 263
$this removeMethod(string|PhpMethod $nameOrMethod)

Removes a method

Parameters

string|PhpMethod $nameOrMethod method name or Method instance

Return Value

$this

Exceptions

InvalidArgumentException if the method cannot be found

at line line 284
bool hasMethod(string|PhpMethod $nameOrMethod)

Checks whether a method exists or not

Parameters

string|PhpMethod $nameOrMethod method name or Method instance

Return Value

bool true if it exists and false if not

at line line 299
PhpMethod getMethod(string $nameOrMethod)

Returns a method

Parameters

string $nameOrMethod the methods name

Return Value

PhpMethod

Exceptions

InvalidArgumentException if the method cannot be found

at line line 316
Map getMethods()

Returns all methods

Return Value

Map collection of methods

at line line 325
Set getMethodNames()

Returns all method names

Return Value

Set

at line line 334
$this clearMethods()

Clears all methods

Return Value

$this

at line line 348
$this generateDocblock()

Generates a docblock from provided information

Return Value

$this