Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Foreach_.php

class Foreach_

Hierarchy

  • class \PhpParser\Node\Stmt\Foreach_ extends \Node\Stmt

Expanded class hierarchy of Foreach_

1 file declares its use of Foreach_
CyclomaticComplexityCalculatingVisitor.php in vendor/sebastian/complexity/src/Visitor/CyclomaticComplexityCalculatingVisitor.php

File

vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php, line 7

Namespace

PhpParser\Node\Stmt
View source
class Foreach_ extends Node\Stmt {
    
    /** @var Node\Expr Expression to iterate */
    public Node\Expr $expr;
    
    /** @var null|Node\Expr Variable to assign key to */
    public ?Node\Expr $keyVar;
    
    /** @var bool Whether to assign value by reference */
    public bool $byRef;
    
    /** @var Node\Expr Variable to assign value to */
    public Node\Expr $valueVar;
    
    /** @var Node\Stmt[] Statements */
    public array $stmts;
    
    /**
     * Constructs a foreach node.
     *
     * @param Node\Expr $expr Expression to iterate
     * @param Node\Expr $valueVar Variable to assign value to
     * @param array{
     *     keyVar?: Node\Expr|null,
     *     byRef?: bool,
     *     stmts?: Node\Stmt[],
     * } $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
     * @param array<string, mixed> $attributes Additional attributes
     */
    public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) {
        $this->attributes = $attributes;
        $this->expr = $expr;
        $this->keyVar = $subNodes['keyVar'] ?? null;
        $this->byRef = $subNodes['byRef'] ?? false;
        $this->valueVar = $valueVar;
        $this->stmts = $subNodes['stmts'] ?? [];
    }
    public function getSubNodeNames() : array {
        return [
            'expr',
            'keyVar',
            'byRef',
            'valueVar',
            'stmts',
        ];
    }
    public function getType() : string {
        return 'Stmt_Foreach';
    }

}

Members

Title Sort descending Modifiers Object type Summary
Foreach_::$byRef public property @var bool Whether to assign value by reference
Foreach_::$expr public property @var Node\Expr Expression to iterate
Foreach_::$keyVar public property @var null|Node\Expr Variable to assign key to
Foreach_::$stmts public property @var Node\Stmt[] Statements
Foreach_::$valueVar public property @var Node\Expr Variable to assign value to
Foreach_::getSubNodeNames public function
Foreach_::getType public function
Foreach_::__construct public function Constructs a foreach node.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal