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