class PhpFunction extends AbstractModel implements GenerateableInterface, NamespaceInterface, DocblockInterface, RoutineInterface

Represents a PHP function.

Traits

Body Part
Docblock Part
Long description part
Parameters Part
Qualified name part
Reference return part
Type docblock generator part
Type 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
setBody(string $body)

Sets the body for this

from BodyPart
string
getBody()

Returns the body

from BodyPart
$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
setParameters(array $parameters)

Sets a collection of parameters

$this
addParameter(PhpParameter $parameter)

Adds a parameter

bool
hasParameter(string $name)

Checks whether a parameter exists

$this
addSimpleParameter(string $name, null|string $type = null, mixed $defaultValue = null)

A quick way to add a parameter which is created from the given parameters

$this
addSimpleDescParameter(string $name, null|string $type = null, null|string $typeDescription = null, mixed $defaultValue = null)

A quick way to add a parameter with description which is created from the given parameters

getParameter(string|int $nameOrIndex)

Returns a parameter by index or name

$this
replaceParameter(int $position, PhpParameter $parameter)

Replaces a parameter at a given position

$this
removeParameter(int|string|PhpParameter $param)

Remove a parameter at a given position

array
getParameters()

Returns a collection of parameters

$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

$this
setReferenceReturned(bool $bool)

Set true if a reference is returned of false if not

bool
isReferenceReturned()

Returns whether a reference is returned

string
getType()

Returns the type

from TypePart
string
getTypeDescription()

Returns the type description

from TypePart
$this
setType(string $type, string $description = null)

Sets the type

from TypePart
$this
setTypeDescription(string $description)

Sets the description for the type

from TypePart
static PhpFunction
fromReflection(ReflectionFunction $ref) deprecated

Creates a PHP function from reflection

static PhpFunction
create(string $name = null)

Creates a new PHP function

__construct(string $name = null)

Creates a new PHP function

generateDocblock()

No description

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 BodyPart at line line 22
$this setBody(string $body)

Sets the body for this

Parameters

string $body

Return Value

$this

in BodyPart at line line 33
string getBody()

Returns the body

Return Value

string

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 ParametersPart at line line 31
$this setParameters(array $parameters)

Sets a collection of parameters

Note: clears all parameters before setting the new ones

Parameters

array $parameters

Return Value

$this

in ParametersPart at line line 46
$this addParameter(PhpParameter $parameter)

Adds a parameter

Parameters

PhpParameter $parameter

Return Value

$this

in ParametersPart at line line 58
bool hasParameter(string $name)

Checks whether a parameter exists

Parameters

string $name parameter name

Return Value

bool true if a parameter exists and false if not

in ParametersPart at line line 77
$this addSimpleParameter(string $name, null|string $type = null, mixed $defaultValue = null)

A quick way to add a parameter which is created from the given parameters

Parameters

string $name
null|string $type
mixed $defaultValue omit the argument to define no default value

Return Value

$this

in ParametersPart at line line 99
$this addSimpleDescParameter(string $name, null|string $type = null, null|string $typeDescription = null, mixed $defaultValue = null)

A quick way to add a parameter with description which is created from the given parameters

Parameters

string $name
null|string $type
null|string $typeDescription
mixed $defaultValue omit the argument to define no default value

Return Value

$this

in ParametersPart at line line 119
PhpParameter getParameter(string|int $nameOrIndex)

Returns a parameter by index or name

Parameters

string|int $nameOrIndex

Return Value

PhpParameter

Exceptions

InvalidArgumentException

in ParametersPart at line line 142
$this replaceParameter(int $position, PhpParameter $parameter)

Replaces a parameter at a given position

Parameters

int $position
PhpParameter $parameter

Return Value

$this

Exceptions

InvalidArgumentException

in ParametersPart at line line 155
$this removeParameter(int|string|PhpParameter $param)

Remove a parameter at a given position

Parameters

int|string|PhpParameter $param

Return Value

$this

in ParametersPart at line line 197
array getParameters()

Returns a collection of parameters

Return Value

array

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

in ReferenceReturnPart at line line 22
$this setReferenceReturned(bool $bool)

Set true if a reference is returned of false if not

Parameters

bool $bool

Return Value

$this

in ReferenceReturnPart at line line 33
bool isReferenceReturned()

Returns whether a reference is returned

Return Value

bool

in TypePart at line line 51
string getType()

Returns the type

Return Value

string

in TypePart at line line 60
string getTypeDescription()

Returns the type description

Return Value

string

in TypePart at line line 26
$this setType(string $type, string $description = null)

Sets the type

Parameters

string $type
string $description

Return Value

$this

in TypePart at line line 41
$this setTypeDescription(string $description)

Sets the description for the type

Parameters

string $description

Return Value

$this

at line line 56
static PhpFunction fromReflection(ReflectionFunction $ref) deprecated

deprecated will be removed in version 0.5

Creates a PHP function from reflection

Parameters

ReflectionFunction $ref

Return Value

PhpFunction

at line line 82
static PhpFunction create(string $name = null)

Creates a new PHP function

Parameters

string $name qualified name

Return Value

PhpFunction

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

Creates a new PHP function

Parameters

string $name qualified name

at line line 100
generateDocblock()