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

Breadcrumb

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

function PrettyPrinterAbstract::pCommaSeparatedMultiline

Pretty prints a comma-separated list of nodes in multiline style, including comments.

The result includes a leading newline and one level of indentation (same as pStmts).

Parameters

Node[] $nodes Array of Nodes to be printed:

bool $trailingComma Whether to use a trailing comma:

Return value

string Comma separated pretty printed nodes in multiline style

2 calls to PrettyPrinterAbstract::pCommaSeparatedMultiline()
Standard::pExpr_Match in vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php
Standard::pMaybeMultiline in vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php

File

vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php, line 499

Class

PrettyPrinterAbstract

Namespace

PhpParser

Code

protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string {
    $this->indent();
    $result = '';
    $lastIdx = count($nodes) - 1;
    foreach ($nodes as $idx => $node) {
        if ($node !== null) {
            $comments = $node->getComments();
            if ($comments) {
                $result .= $this->nl . $this->pComments($comments);
            }
            $result .= $this->nl . $this->p($node);
        }
        else {
            $result .= $this->nl;
        }
        if ($trailingComma || $idx !== $lastIdx) {
            $result .= ',';
        }
    }
    $this->outdent();
    return $result;
}

API Navigation

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