AbstractPhpStruct extends AbstractModel implements NamespaceInterface, DocblockInterface Uses DocblockPart, LongDescriptionPart, QualifiedNamePart
Represents an abstract php structure (class, trait or interface).
Tags
Interfaces, Classes and Traits
- NamespaceInterface
- Represents models that have a namespace.
- DocblockInterface
- Docblock interface to represent models that have a docblock.
Table of Contents
- $description : string
- $docblock : Docblock
- $longDescription : string
- $methods : Map
- $namespace : string
- $requiredFiles : Set
- $useStatements : Map
- __construct() : mixed
- Creates a new struct.
- addRequiredFile() : $this
- Adds a new required file.
- addUseStatement() : $this
- Adds a use statement with an optional alias.
- clearMethods() : $this
- Clears all methods.
- clearUseStatements() : $this
- Clears all use statements.
- create() : static
- Creates a new struct.
- declareUse() : string
- 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.
- declareUses() : $this
- Declares multiple use statements at once.
- generateDocblock() : $this
- Generates a docblock from provided information.
- getDescription() : string
- Returns this description.
- getDocblock() : Docblock
- Returns the docblock.
- getLongDescription() : string
- Returns the long description.
- getMethod() : PhpMethod
- Returns a method.
- getMethodByName() : PhpMethod
- Returns amethod.
- getMethodNames() : Set
- Returns all method names.
- getMethods() : Map
- Returns all methods.
- getNamespace() : string
- Returns the namespace.
- getQualifiedName() : string
- Returns the qualified name.
- getRequiredFiles() : Set
- Returns required files.
- getUseAlias() : string
- Returns the usable alias for a qualified name.
- getUseStatements() : Map
- Returns all use statements.
- hasMethod() : bool
- Checks whether a method exists or not.
- hasMethodByName() : bool
- Checks whether a method exists or not.
- hasUseStatement() : bool
- Returns whether the given use statement is present.
- removeMethod() : $this
- Removes a method.
- removeMethodByName() : $this
- Removes a method.
- removeUseStatement() : $this
- Removes a use statement.
- setDescription() : $this
- Sets the description, which will also be used when generating a docblock.
- setDocblock() : $this
- Sets the docblock.
- setLongDescription() : $this
- Sets the long description.
- setMethod() : $this
- Adds a method.
- setMethods() : $this
- Sets a collection of methods.
- setMultilineDescription() : $this
- Sets a multi-line description, which will also be used when generating a docblock.
- setNamespace() : $this
- Sets the namespace.
- setQualifiedName() : $this
- In contrast to setName(), this method accepts the fully qualified name including the namespace.
- setRequiredFiles() : $this
- Sets requried files.
- setUseStatements() : $this
- Sets use statements.
Properties
$description
protected
string
$description
= ''
$docblock
private
Docblock
$docblock
$longDescription
private
string
$longDescription
= ''
$methods
private
Map
$methods
$namespace
private
string
$namespace
= ''
$requiredFiles
private
Set
$requiredFiles
$useStatements
private
Map
$useStatements
Methods
__construct()
Creates a new struct.
public
__construct([string $name = '' ]) : mixed
Parameters
- $name : string = ''
-
the fqcn
Return values
mixed —addRequiredFile()
Adds a new required file.
public
addRequiredFile(string $file) : $this
Parameters
- $file : string
Return values
$this —addUseStatement()
Adds a use statement with an optional alias.
public
addUseStatement(string $qualifiedName[, string|null $alias = null ]) : $this
Parameters
- $qualifiedName : string
- $alias : string|null = null
Return values
$this —clearMethods()
Clears all methods.
public
clearMethods() : $this
Return values
$this —clearUseStatements()
Clears all use statements.
public
clearUseStatements() : $this
Return values
$this —create()
Creates a new struct.
public
static create([string $name = '' ]) : static
Parameters
- $name : string = ''
-
the fqcn
Return values
static —declareUse()
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.
public
declareUse(string $qualifiedName[, string|null $alias = null ]) : string
If the class has already been declared you get only the set alias.
Parameters
- $qualifiedName : string
- $alias : string|null = null
Return values
string —the used alias
declareUses()
Declares multiple use statements at once.
public
declareUses() : $this
Return values
$this —generateDocblock()
Generates a docblock from provided information.
public
generateDocblock() : $this
Return values
$this —getDescription()
Returns this description.
public
getDescription() : string
Return values
string —getDocblock()
Returns the docblock.
public
getDocblock() : Docblock
Return values
Docblock —getLongDescription()
Returns the long description.
public
getLongDescription() : string
Return values
string —getMethod()
Returns a method.
public
getMethod(PhpMethod $method) : PhpMethod
Parameters
- $method : PhpMethod
Tags
Return values
PhpMethod —getMethodByName()
Returns amethod.
public
getMethodByName(string $name) : PhpMethod
Parameters
- $name : string
Tags
Return values
PhpMethod —getMethodNames()
Returns all method names.
public
getMethodNames() : Set
Return values
Set —getMethods()
Returns all methods.
public
getMethods() : Map
Return values
Map —collection of methods
getNamespace()
Returns the namespace.
public
getNamespace() : string
Return values
string —getQualifiedName()
Returns the qualified name.
public
getQualifiedName() : string
Return values
string —getRequiredFiles()
Returns required files.
public
getRequiredFiles() : Set
Return values
Set —collection of filenames
getUseAlias()
Returns the usable alias for a qualified name.
public
getUseAlias(string $qualifiedName) : string
Parameters
- $qualifiedName : string
Return values
string —the alias
getUseStatements()
Returns all use statements.
public
getUseStatements() : Map
Return values
Map —collection of use statements
hasMethod()
Checks whether a method exists or not.
public
hasMethod(PhpMethod $method) : bool
Parameters
- $method : PhpMethod
Return values
bool —true
if it exists and false
if not
hasMethodByName()
Checks whether a method exists or not.
public
hasMethodByName(string $name) : bool
Parameters
- $name : string
Return values
bool —hasUseStatement()
Returns whether the given use statement is present.
public
hasUseStatement(string $qualifiedName) : bool
Parameters
- $qualifiedName : string
Return values
bool —removeMethod()
Removes a method.
public
removeMethod(PhpMethod $method) : $this
Parameters
- $method : PhpMethod
-
Method instance
Return values
$this —removeMethodByName()
Removes a method.
public
removeMethodByName(string $name) : $this
Parameters
- $name : string
-
method name or Method instance
Tags
Return values
$this —removeUseStatement()
Removes a use statement.
public
removeUseStatement(string $qualifiedName) : $this
Parameters
- $qualifiedName : string
Return values
$this —setDescription()
Sets the description, which will also be used when generating a docblock.
public
setDescription(string $description) : $this
Parameters
- $description : string
Return values
$this —setDocblock()
Sets the docblock.
public
setDocblock(Docblock|string $doc) : $this
Parameters
- $doc : Docblock|string
Return values
$this —setLongDescription()
Sets the long description.
public
setLongDescription(string $longDescription) : $this
Parameters
- $longDescription : string
Return values
$this —setMethod()
Adds a method.
public
setMethod(PhpMethod $method) : $this
Parameters
- $method : PhpMethod
Return values
$this —setMethods()
Sets a collection of methods.
public
setMethods(array<string|int, PhpMethod> $methods) : $this
Parameters
- $methods : array<string|int, PhpMethod>
Return values
$this —setMultilineDescription()
Sets a multi-line description, which will also be used when generating a docblock.
public
setMultilineDescription(array<string|int, mixed> $description) : $this
Each line is a value of the $description
array.
Parameters
- $description : array<string|int, mixed>
Return values
$this —setNamespace()
Sets the namespace.
public
setNamespace(string $namespace) : $this
Parameters
- $namespace : string
Return values
$this —setQualifiedName()
In contrast to setName(), this method accepts the fully qualified name including the namespace.
public
setQualifiedName(string $name) : $this
Parameters
- $name : string
Return values
$this —setRequiredFiles()
Sets requried files.
public
setRequiredFiles(array<string|int, mixed> $files) : $this
Parameters
- $files : array<string|int, mixed>
Return values
$this —setUseStatements()
Sets use statements.
public
setUseStatements(array<string|int, mixed> $useStatements) : $this
Parameters
- $useStatements : array<string|int, mixed>