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
Namespace
PhpParserCode
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;
}