PhpConstant extends AbstractModel implements GenerateableInterface, DocblockInterface, ValueInterface Uses DocblockPart, LongDescriptionPart, NamePart, TypeDocblockGeneratorPart, TypePart, ValuePart
Represents a PHP constant.
Tags
Interfaces, Classes and Traits
- GenerateableInterface
- Represents all models that can be generated with a code generator.
- DocblockInterface
- Docblock interface to represent models that have a docblock.
- ValueInterface
Table of Contents
- $description : string
- $docblock : Docblock
- $expression : string
- $hasExpression : bool
- $hasValue : bool
- $longDescription : string
- $name : string
- $type : string
- $typeDescription : string
- $value : mixed
- __construct() : mixed
- Creates a new PHP constant.
- create() : static
- Creates a new PHP constant.
- generateDocblock() : mixed
- Generates docblock based on provided information.
- getDescription() : string
- Returns this description.
- getDocblock() : Docblock
- Returns the docblock.
- getExpression() : string
- Returns the expression.
- getLongDescription() : string
- Returns the long description.
- getName() : string
- Returns the name.
- getType() : string
- Returns the type.
- getTypeDescription() : string
- Returns the type description.
- getValue() : null|bool|float|int|PhpConstant|string
- Returns the value.
- hasValue() : bool
- Checks whether a value or expression is set.
- isExpression() : bool
- Returns whether an expression is set.
- setDescription() : $this
- Sets the description, which will also be used when generating a docblock.
- setDocblock() : $this
- Sets the docblock.
- setExpression() : $this
- Sets an expression.
- setLongDescription() : $this
- Sets the long description.
- setMultilineDescription() : $this
- Sets a multi-line description, which will also be used when generating a docblock.
- setName() : $this
- Sets the name.
- setType() : $this
- Sets the type.
- setTypeDescription() : $this
- Sets the description for the type.
- setValue() : $this
- Sets the value.
- unsetExpression() : $this
- Unsets the expression.
- unsetValue() : $this
- Unsets the value.
- generateTypeTag() : void
- Generates a type tag (return or var) but checks if one exists and updates this one.
- isPrimitive() : bool
- Returns whether the given value is a primitive.
- transformNullable() : string
- Transform a `?type` PHP notation in `type|null` docblock notation.
Properties
$description
protected
string
$description
= ''
$docblock
private
Docblock
$docblock
$expression
private
string
$expression
= ''
$hasExpression
private
bool
$hasExpression
= false
$hasValue
private
bool
$hasValue
= false
$longDescription
private
string
$longDescription
= ''
$name
private
string
$name
= ''
$type
private
string
$type
= ''
$typeDescription
private
string
$typeDescription
= ''
$value
private
mixed
$value
Methods
__construct()
Creates a new PHP constant.
public
final __construct([string $name = '' ][, mixed $value = null ][, bool $isExpression = false ]) : mixed
Parameters
- $name : string = ''
- $value : mixed = null
- $isExpression : bool = false
Return values
mixed —create()
Creates a new PHP constant.
public
static create([string $name = '' ][, mixed $value = null ][, bool $isExpression = false ]) : static
Parameters
- $name : string = ''
- $value : mixed = null
- $isExpression : bool = false
Return values
static —generateDocblock()
Generates docblock based on provided information.
public
generateDocblock() : mixed
Return values
mixed —getDescription()
Returns this description.
public
getDescription() : string
Return values
string —getDocblock()
Returns the docblock.
public
abstract getDocblock() : Docblock
Return values
Docblock —getExpression()
Returns the expression.
public
getExpression() : string
Return values
string —getLongDescription()
Returns the long description.
public
getLongDescription() : string
Return values
string —getName()
Returns the name.
public
getName() : string
Return values
string —getType()
Returns the type.
public
getType() : string
Return values
string —getTypeDescription()
Returns the type description.
public
getTypeDescription() : string
Return values
string —getValue()
Returns the value.
public
getValue() : null|bool|float|int|PhpConstant|string
Return values
null|bool|float|int|PhpConstant|string —hasValue()
Checks whether a value or expression is set.
public
hasValue() : bool
Return values
bool —isExpression()
Returns whether an expression is set.
public
isExpression() : bool
Return values
bool —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 —setExpression()
Sets an expression.
public
setExpression(string $expr) : $this
Parameters
- $expr : string
Return values
$this —setLongDescription()
Sets the long description.
public
setLongDescription(string $longDescription) : $this
Parameters
- $longDescription : string
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 —setName()
Sets the name.
public
setName(string $name) : $this
Parameters
- $name : string
Return values
$this —setType()
Sets the type.
public
setType(string $type[, string $description = '' ]) : $this
Parameters
- $type : string
- $description : string = ''
Return values
$this —setTypeDescription()
Sets the description for the type.
public
setTypeDescription(string $description) : $this
Parameters
- $description : string
Return values
$this —setValue()
Sets the value.
public
setValue(mixed $value) : $this
Parameters
- $value : mixed
Tags
Return values
$this —unsetExpression()
Unsets the expression.
public
unsetExpression() : $this
Return values
$this —unsetValue()
Unsets the value.
public
unsetValue() : $this
Return values
$this —generateTypeTag()
Generates a type tag (return or var) but checks if one exists and updates this one.
protected
generateTypeTag(AbstractTypeTag $tag) : void
Parameters
- $tag : AbstractTypeTag
Return values
void —isPrimitive()
Returns whether the given value is a primitive.
private
isPrimitive(mixed $value) : bool
Parameters
- $value : mixed
Return values
bool —transformNullable()
Transform a `?type` PHP notation in `type|null` docblock notation.
private
transformNullable(string $type) : string
Parameters
- $type : string