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

Breadcrumb

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

function PrettyPrinterAbstract::isMultiline

Determine whether a list of nodes uses multiline formatting.

Parameters

(Node|null)[] $nodes Node list:

Return value

bool Whether multiline formatting is used

1 call to PrettyPrinterAbstract::isMultiline()
PrettyPrinterAbstract::pArray in vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
Perform a format-preserving pretty print of an array.

File

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

Class

PrettyPrinterAbstract

Namespace

PhpParser

Code

protected function isMultiline(array $nodes) : bool {
    if (\count($nodes) < 2) {
        return false;
    }
    $pos = -1;
    foreach ($nodes as $node) {
        if (null === $node) {
            continue;
        }
        $endPos = $node->getEndTokenPos() + 1;
        if ($pos >= 0) {
            $text = $this->origTokens
                ->getTokenCode($pos, $endPos, 0);
            if (false === strpos($text, "\n")) {
                // We require that a newline is present between *every* item. If the formatting
                // is inconsistent, with only some items having newlines, we don't consider it
                // as multiline
                return false;
            }
        }
        $pos = $endPos;
    }
    return true;
}

API Navigation

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