Psr2 Code Generator

PhpProperty extends AbstractPhpMember implements ValueInterface Uses TypeDocblockGeneratorPart, ValuePart

Represents a PHP property.

Tags
author

Johannes M. Schmitt schmittjoh@gmail.com

author

Thomas Gossmann

psalm-suppress

PropertyNotSetInConstructor

Interfaces, Classes and Traits

ValueInterface

Table of Contents

VISIBILITY_PRIVATE  = 'private'
Private visibility.
VISIBILITY_PROTECTED  = 'protected'
Protected visibility.
VISIBILITY_PUBLIC  = 'public'
Public visibility.
$description  : string
$docblock  : Docblock
$expression  : string
$hasExpression  : bool
$hasValue  : bool
$longDescription  : string
$name  : string
$parent  : AbstractPhpStruct|null
$static  : bool
$type  : string
$typeDescription  : string
$value  : mixed
$visibility  : string
__construct()  : mixed
PhpProperty constructor.
create()  : static
Creates a new PHP property.
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.
getVisibility()  : string
Returns the visibility state of this member.
hasValue()  : bool
Checks whether a value or expression is set.
isExpression()  : bool
Returns whether an expression is set.
isStatic()  : bool
Returns whether this member is static.
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.
setStatic()  : $this
Sets whether or not this member is static.
setType()  : $this
Sets the type.
setTypeDescription()  : $this
Sets the description for the type.
setValue()  : $this
Sets the value.
setVisibility()  : $this
Sets the members visibility.
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.

Constants

VISIBILITY_PRIVATE

Private visibility.

public string VISIBILITY_PRIVATE = 'private'

VISIBILITY_PROTECTED

Protected visibility.

public string VISIBILITY_PROTECTED = 'protected'

VISIBILITY_PUBLIC

Public visibility.

public string VISIBILITY_PUBLIC = 'public'

Properties

$hasExpression

private bool $hasExpression = false

$typeDescription

private string $typeDescription = ''

Methods

create()

Creates a new PHP property.

public static create([string $name = '' ]) : static
Parameters
$name : string = ''

the properties name

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

getVisibility()

Returns the visibility state of this member.

public getVisibility() : string
Return values
string

the visibility

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

isStatic()

Returns whether this member is static.

public isStatic() : bool
Return values
bool

true if static and false if not

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

setStatic()

Sets whether or not this member is static.

public setStatic(bool $bool) : $this
Parameters
$bool : bool
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

setVisibility()

Sets the members visibility.

public setVisibility(string $visibility) : $this
Parameters
$visibility : string

the new visibility

Tags
see
self::VISIBILITY_PUBLIC
see
self::VISIBILITY_PROTECTED
see
self::VISIBILITY_PRIVATE
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