\PhpParser\Node\StmtForeach_

Summary

Methods
Properties
Constants
__construct()
getType()
getLine()
setLine()
getDocComment()
setDocComment()
setAttribute()
hasAttribute()
getAttribute()
getAttributes()
jsonSerialize()
getSubNodeNames()
$expr
$keyVar
$byRef
$valueVar
$stmts
No constants found
No protected methods found
$attributes
N/A
No private methods found
No private properties found
N/A

Properties

$keyVar

$keyVar : null|\PhpParser\Node\Expr

Type

null|\PhpParser\Node\Expr — Variable to assign key to

$byRef

$byRef : boolean

Type

boolean — Whether to assign value by reference

$valueVar

$valueVar : \PhpParser\Node\Expr

Type

\PhpParser\Node\Expr — Variable to assign value to

$stmts

$stmts : array<mixed,\PhpParser\Node>

Type

array<mixed,\PhpParser\Node> — Statements

$attributes

$attributes : 

Type

Methods

__construct()

__construct(\PhpParser\Node\Expr  $expr, \PhpParser\Node\Expr  $valueVar, array  $subNodes = array(), array  $attributes = array()) 

Constructs a foreach node.

Parameters

\PhpParser\Node\Expr $expr

Expression to iterate

\PhpParser\Node\Expr $valueVar

Variable to assign value to

array $subNodes

Array of the following optional subnodes: 'keyVar' => null : Variable to assign key to 'byRef' => false : Whether to assign value by reference 'stmts' => array(): Statements

array $attributes

Additional attributes

getType()

getType() : string

Gets the type of the node.

Returns

string —

Type of the node

getLine()

getLine() : integer

Gets line the node started in.

Returns

integer —

Line

setLine()

setLine(integer  $line) 

Sets line the node started in.

Parameters

integer $line

Line

getDocComment()

getDocComment() : null|\PhpParser\Comment\Doc

Gets the doc comment of the node.

The doc comment has to be the last comment associated with the node.

Returns

null|\PhpParser\Comment\Doc

Doc comment object or null

setDocComment()

setDocComment(\PhpParser\Comment\Doc  $docComment) 

Sets the doc comment of the node.

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

Parameters

\PhpParser\Comment\Doc $docComment

Doc comment to set

setAttribute()

setAttribute(string  $key, mixed  $value) 

Sets an attribute on a node.

Parameters

string $key
mixed $value

hasAttribute()

hasAttribute(string  $key) : boolean

Returns whether an attribute exists.

Parameters

string $key

Returns

boolean

getAttribute()

getAttribute(string  $key, mixed  $default = null) : mixed

Returns the value of an attribute.

Parameters

string $key
mixed $default

Returns

mixed

getAttributes()

getAttributes() : array

Returns all attributes for the given node.

Returns

array

jsonSerialize()

jsonSerialize() 

getSubNodeNames()

getSubNodeNames()