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

Breadcrumb

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

function BuilderHelpers::normalizeStmt

Normalizes a node to a statement.

Expressions are wrapped in a Stmt\Expression node.

Parameters

Node|Builder $node The node to normalize:

Return value

Stmt The normalized statement node

3 calls to BuilderHelpers::normalizeStmt()
Function_::addStmt in vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php
Adds a statement.
Method::addStmt in vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php
Adds a statement.
Namespace_::addStmt in vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php
Adds a statement.

File

vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php, line 48

Class

BuilderHelpers
This class defines helpers used in the implementation of builders. Don't use it directly.

Namespace

PhpParser

Code

public static function normalizeStmt($node) : Stmt {
    $node = self::normalizeNode($node);
    if ($node instanceof Stmt) {
        return $node;
    }
    if ($node instanceof Expr) {
        return new Stmt\Expression($node);
    }
    throw new \LogicException('Expected statement or expression node');
}

API Navigation

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