Documentation

Class_ extends ClassLike
in package

Table of Contents

Constants

MODIFIER_ABSTRACT  = 16
MODIFIER_FINAL  = 32
MODIFIER_PRIVATE  = 4
MODIFIER_PROTECTED  = 2
MODIFIER_PUBLIC  = 1
MODIFIER_READONLY  = 64
MODIFIER_STATIC  = 8
VISIBILITY_MODIFIER_MASK  = 7

Properties

$attrGroups  : array<string|int, AttributeGroup>
$extends  : null|Name
$flags  : int
$implements  : array<string|int, Name>
$name  : Identifier|null
$namespacedName  : Name|null
$stmts  : array<string|int, Stmt>
$attributes  : array<string, mixed>

Methods

__construct()  : mixed
Constructs a class node.
getAttribute()  : mixed
Returns the value of an attribute.
getAttributes()  : array<string, mixed>
Returns all the attributes of this node.
getComments()  : array<string|int, Comment>
Gets all comments directly preceding this node.
getConstants()  : array<string|int, ClassConst>
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).
getMethod()  : ClassMethod|null
Gets method with the given name defined directly in this class/interface/trait.
getMethods()  : array<string|int, ClassMethod>
Gets all methods defined directly in this class/interface/trait
getProperties()  : array<string|int, Property>
getProperty()  : Property|null
Gets property with the given name defined directly in this class/interface/trait.
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.
getSubNodeNames()  : array<string|int, string>
Gets the names of the sub nodes.
getTraitUses()  : array<string|int, TraitUse>
getType()  : string
Gets the type of the node.
hasAttribute()  : bool
Returns whether an attribute exists.
isAbstract()  : bool
Whether the class is explicitly abstract.
isAnonymous()  : bool
Whether the class is anonymous.
isFinal()  : bool
Whether the class is final.
isReadonly()  : bool
jsonSerialize()  : array<string, mixed>
setAttribute()  : void
Sets an attribute on a node.
setAttributes()  : void
Replaces all the attributes of this node.
setDocComment()  : void
Sets the doc comment of the node.

Constants

MODIFIER_ABSTRACT

Use Modifiers::ABSTRACT instead

public mixed MODIFIER_ABSTRACT = 16

MODIFIER_FINAL

Use Modifiers::FINAL instead

public mixed MODIFIER_FINAL = 32

MODIFIER_PRIVATE

Use Modifiers::PRIVATE instead

public mixed MODIFIER_PRIVATE = 4

MODIFIER_PROTECTED

Use Modifiers::PROTECTED instead

public mixed MODIFIER_PROTECTED = 2

MODIFIER_PUBLIC

Use Modifiers::PUBLIC instead

public mixed MODIFIER_PUBLIC = 1

MODIFIER_READONLY

Use Modifiers::READONLY instead

public mixed MODIFIER_READONLY = 64

MODIFIER_STATIC

Use Modifiers::STATIC instead

public mixed MODIFIER_STATIC = 8

VISIBILITY_MODIFIER_MASK

Use Modifiers::VISIBILITY_MASK instead

public mixed VISIBILITY_MODIFIER_MASK = 7

Properties

$extends

public null|Name $extends

Name of extended class

$flags

public int $flags

Modifiers

$implements

public array<string|int, Name> $implements

Names of implemented interfaces

$namespacedName

public Name|null $namespacedName

Namespaced name (if using NameResolver)

$attributes

protected array<string, mixed> $attributes

Attributes

Methods

__construct()

Constructs a class node.

public __construct(string|Identifier|null $name[, AttributeGroup[]} $subNodes = [] ][, array<string, mixed> $attributes = [] ]) : mixed
Parameters
$name : string|Identifier|null

Name

$subNodes : AttributeGroup[]} = []

Array of the following optional subnodes: 'flags' => 0 : Flags 'extends' => null : Name of extended class 'implements' => array(): Names of implemented interfaces 'stmts' => array(): Statements 'attrGroups' => array(): PHP attribute groups

$attributes : array<string, mixed> = []

Additional attributes

getAttribute()

Returns the value of an attribute.

public getAttribute(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string
$default : mixed = null

getAttributes()

Returns all the attributes of this node.

public getAttributes() : array<string, mixed>
Return values
array<string, 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).

Tags
phpstan-return

-1|positive-int

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
Tags
phpstan-return

-1|positive-int

Return values
int

Start line (or -1 if not available)

getMethod()

Gets method with the given name defined directly in this class/interface/trait.

public getMethod(string $name) : ClassMethod|null
Parameters
$name : string

Name of the method (compared case-insensitively)

Return values
ClassMethod|null

Method node or null if the method does not exist

getMethods()

Gets all methods defined directly in this class/interface/trait

public getMethods() : array<string|int, ClassMethod>
Return values
array<string|int, ClassMethod>

getProperty()

Gets property with the given name defined directly in this class/interface/trait.

public getProperty(string $name) : Property|null
Parameters
$name : string

Name of the property

Return values
Property|null

Property node or null if the property does not exist

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

Tags
phpstan-return

-1|positive-int

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)

getSubNodeNames()

Gets the names of the sub nodes.

public getSubNodeNames() : array<string|int, string>
Return values
array<string|int, string>

Names of sub nodes

getType()

Gets the type of the node.

public getType() : string
Return values
string

Type of the node

hasAttribute()

Returns whether an attribute exists.

public hasAttribute(string $key) : bool
Parameters
$key : string
Return values
bool

isAbstract()

Whether the class is explicitly abstract.

public isAbstract() : bool
Return values
bool

isAnonymous()

Whether the class is anonymous.

public isAnonymous() : bool
Return values
bool

isFinal()

Whether the class is final.

public isFinal() : bool
Return values
bool

isReadonly()

public isReadonly() : bool
Return values
bool

jsonSerialize()

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

setAttribute()

Sets an attribute on a node.

public setAttribute(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed

setAttributes()

Replaces all the attributes of this node.

public setAttributes(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>

setDocComment()

Sets the doc comment of the node.

public setDocComment(Doc $docComment) : void

This will either replace an existing doc comment or add it to the comments array.

Parameters
$docComment : Doc

Doc comment to set


        
On this page

Search results