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

Breadcrumb

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

function PrettyPrinterAbstract::safeAppend

Appends to a string, ensuring whitespace between label characters.

Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x". Without safeAppend the result would be "echox", which does not preserve semantics.

2 calls to PrettyPrinterAbstract::safeAppend()
PrettyPrinterAbstract::p in vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php
Pretty prints a node.
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 1119

Class

PrettyPrinterAbstract

Namespace

PhpParser

Code

protected function safeAppend(string &$str, string $append) : void {
    if ($str === "") {
        $str = $append;
        return;
    }
    if ($append === "") {
        return;
    }
    if (!$this->labelCharMap[$append[0]] || !$this->labelCharMap[$str[\strlen($str) - 1]]) {
        $str .= $append;
    }
    else {
        $str .= " " . $append;
    }
}

API Navigation

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