Psr2 Code Generator

PhpConstant extends AbstractModel implements GenerateableInterface, DocblockInterface, ValueInterface Uses DocblockPart, LongDescriptionPart, NamePart, TypeDocblockGeneratorPart, TypePart, ValuePart

Represents a PHP constant.

Tags
author

Thomas Gossmann

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

$hasExpression

private bool $hasExpression = false

$typeDescription

private string $typeDescription = ''

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

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

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
throws
InvalidArgumentException

if the value is not an accepted primitve

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
Return values
string

Search results