ClassMethod
extends Stmt
in package
implements
FunctionLike
Interfaces, Classes, Traits and Enums
Table of Contents
- $attrGroups : array<string|int, AttributeGroup>
- $byRef : bool
- $flags : int
- $name : Identifier
- $params : array<string|int, Param>
- $returnType : null|Identifier|Name|ComplexType
- $stmts : array<string|int, Stmt>|null
- $attributes : mixed
- $magicNames : mixed
- __construct() : mixed
- Constructs a class method node.
- getAttrGroups() : array<string|int, AttributeGroup>
- Get PHP attribute groups.
- getAttribute() : mixed
- Returns the value of an attribute.
- getAttributes() : array<string|int, mixed>
- Returns all the attributes of this node.
- getComments() : array<string|int, Comment>
- Gets all comments directly preceding this node.
- getDocComment() : null|Doc
- Gets the doc comment of the node.
- getEndFilePos() : int
- Gets the file offset of the last character that is part of this node.
- getEndLine() : int
- Gets the line the node ended in.
- getEndTokenPos() : int
- Gets the token offset of the last token that is part of this node.
- getLine() : int
- Gets line the node started in (alias of getStartLine).
- getParams() : array<string|int, Param>
- List of parameters
- getReturnType() : null|Identifier|Name|ComplexType
- Get the declared return type or null
- getStartFilePos() : int
- Gets the file offset of the first character that is part of this node.
- getStartLine() : int
- Gets line the node started in.
- getStartTokenPos() : int
- Gets the token offset of the first token that is part of this node.
- getStmts() : array<string|int, Stmt>|null
- The function body
- getSubNodeNames() : array<string|int, mixed>
- getType() : string
- hasAttribute() : bool
- Returns whether an attribute exists.
- isAbstract() : bool
- Whether the method is abstract.
- isFinal() : bool
- Whether the method is final.
- isMagic() : bool
- Whether the method is magic.
- isPrivate() : bool
- Whether the method is private.
- isProtected() : bool
- Whether the method is protected.
- isPublic() : bool
- Whether the method is explicitly or implicitly public.
- isStatic() : bool
- Whether the method is static.
- jsonSerialize() : array<string|int, mixed>
- returnsByRef() : bool
- Whether to return by reference
- setAttribute() : mixed
- Sets an attribute on a node.
- setAttributes() : mixed
- Replaces all the attributes of this node.
- setDocComment() : mixed
- Sets the doc comment of the node.
Properties
$attrGroups
public
array<string|int, AttributeGroup>
$attrGroups
PHP attribute groups
$byRef
public
bool
$byRef
Whether to return by reference
$flags
public
int
$flags
Flags
$name
public
Identifier
$name
Name
$params
public
array<string|int, Param>
$params
Parameters
$returnType
public
null|Identifier|Name|ComplexType
$returnType
Return type
$stmts
public
array<string|int, Stmt>|null
$stmts
Statements
$attributes
protected
mixed
$attributes
$magicNames
private
static mixed
$magicNames
= ['__construct' => true, '__destruct' => true, '__call' => true, '__callstatic' => true, '__get' => true, '__set' => true, '__isset' => true, '__unset' => true, '__sleep' => true, '__wakeup' => true, '__tostring' => true, '__set_state' => true, '__clone' => true, '__invoke' => true, '__debuginfo' => true]
Methods
__construct()
Constructs a class method node.
public
__construct(string|Identifier $name[, array<string|int, mixed> $subNodes = [] ][, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $name : string|Identifier
-
Name
- $subNodes : array<string|int, mixed> = []
-
Array of the following optional subnodes: 'flags => MODIFIER_PUBLIC: Flags 'byRef' => false : Whether to return by reference 'params' => array() : Parameters 'returnType' => null : Return type 'stmts' => array() : Statements 'attrGroups' => array() : PHP attribute groups
- $attributes : array<string|int, mixed> = []
-
Additional attributes
Return values
mixed —getAttrGroups()
Get PHP attribute groups.
public
getAttrGroups() : array<string|int, AttributeGroup>
Return values
array<string|int, AttributeGroup> —getAttribute()
Returns the value of an attribute.
public
getAttribute(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
Return values
mixed —getAttributes()
Returns all the attributes of this node.
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getComments()
Gets all comments directly preceding this node.
public
getComments() : array<string|int, Comment>
The comments are also available through the "comments" attribute.
Return values
array<string|int, Comment> —getDocComment()
Gets the doc comment of the node.
public
getDocComment() : null|Doc
Return values
null|Doc —Doc comment object or null
getEndFilePos()
Gets the file offset of the last character that is part of this node.
public
getEndFilePos() : int
Requires the 'endFilePos' attribute to be enabled in the lexer (DISABLED by default).
Return values
int —File end position (or -1 if not available)
getEndLine()
Gets the line the node ended in.
public
getEndLine() : int
Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
Return values
int —End line (or -1 if not available)
getEndTokenPos()
Gets the token offset of the last token that is part of this node.
public
getEndTokenPos() : int
The offset is an index into the array returned by Lexer::getTokens().
Requires the 'endTokenPos' attribute to be enabled in the lexer (DISABLED by default).
Return values
int —Token end position (or -1 if not available)
getLine()
Gets line the node started in (alias of getStartLine).
public
getLine() : int
Return values
int —Start line (or -1 if not available)
getParams()
List of parameters
public
getParams() : array<string|int, Param>
Return values
array<string|int, Param> —getReturnType()
Get the declared return type or null
public
getReturnType() : null|Identifier|Name|ComplexType
Return values
null|Identifier|Name|ComplexType —getStartFilePos()
Gets the file offset of the first character that is part of this node.
public
getStartFilePos() : int
Requires the 'startFilePos' attribute to be enabled in the lexer (DISABLED by default).
Return values
int —File start position (or -1 if not available)
getStartLine()
Gets line the node started in.
public
getStartLine() : int
Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
Return values
int —Start line (or -1 if not available)
getStartTokenPos()
Gets the token offset of the first token that is part of this node.
public
getStartTokenPos() : int
The offset is an index into the array returned by Lexer::getTokens().
Requires the 'startTokenPos' attribute to be enabled in the lexer (DISABLED by default).
Return values
int —Token start position (or -1 if not available)
getStmts()
The function body
public
getStmts() : array<string|int, Stmt>|null
Return values
array<string|int, Stmt>|null —getSubNodeNames()
public
getSubNodeNames() : array<string|int, mixed>
Return values
array<string|int, mixed> —getType()
public
getType() : string
Return values
string —hasAttribute()
Returns whether an attribute exists.
public
hasAttribute(string $key) : bool
Parameters
- $key : string
Return values
bool —isAbstract()
Whether the method is abstract.
public
isAbstract() : bool
Return values
bool —isFinal()
Whether the method is final.
public
isFinal() : bool
Return values
bool —isMagic()
Whether the method is magic.
public
isMagic() : bool
Return values
bool —isPrivate()
Whether the method is private.
public
isPrivate() : bool
Return values
bool —isProtected()
Whether the method is protected.
public
isProtected() : bool
Return values
bool —isPublic()
Whether the method is explicitly or implicitly public.
public
isPublic() : bool
Return values
bool —isStatic()
Whether the method is static.
public
isStatic() : bool
Return values
bool —jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —returnsByRef()
Whether to return by reference
public
returnsByRef() : bool
Return values
bool —setAttribute()
Sets an attribute on a node.
public
setAttribute(string $key, mixed $value) : mixed
Parameters
- $key : string
- $value : mixed
Return values
mixed —setAttributes()
Replaces all the attributes of this node.
public
setAttributes(array<string|int, mixed> $attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
Return values
mixed —setDocComment()
Sets the doc comment of the node.
public
setDocComment(Doc $docComment) : mixed
This will either replace an existing doc comment or add it to the comments array.
Parameters
- $docComment : Doc
-
Doc comment to set