Security update for Core, with self-updated composer
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / PrettyPrinterAbstract.php
index 5bc3966cd1c51c0172cdf85bc7ecc0638864f5e6..24bae5936f4d8b5ae0b8a24ed16d24f180bc94cf 100644 (file)
@@ -286,6 +286,38 @@ abstract class PrettyPrinterAbstract
         return $this->pImplode($nodes, ', ');
     }
 
+    /**
+     * 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).
+     *
+     * @param Node[] $nodes         Array of Nodes to be printed
+     * @param bool   $trailingComma Whether to use a trailing comma
+     *
+     * @return string Comma separated pretty printed nodes in multiline style
+     */
+    protected function pCommaSeparatedMultiline(array $nodes, $trailingComma) {
+        $result = '';
+        $lastIdx = count($nodes) - 1;
+        foreach ($nodes as $idx => $node) {
+            if ($node !== null) {
+                $comments = $node->getAttribute('comments', array());
+                if ($comments) {
+                    $result .= "\n" . $this->pComments($comments);
+                }
+
+                $result .= "\n" . $this->p($node);
+            } else {
+                $result .= "\n";
+            }
+            if ($trailingComma || $idx !== $lastIdx) {
+                $result .= ',';
+            }
+        }
+
+        return preg_replace('~\n(?!$|' . $this->noIndentToken . ')~', "\n    ", $result);
+    }
+
     /**
      * Signals the pretty printer that a string shall not be indented.
      *