function Standard::pKey
3 calls to Standard::pKey()
- Standard::pArrayItem in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter/ Standard.php - Standard::pExpr_Yield in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter/ Standard.php - Standard::pMatchArm in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter/ Standard.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter/ Standard.php, line 604
Class
Namespace
PhpParser\PrettyPrinterCode
protected function pKey(?Node $node) : string {
if ($node === null) {
return '';
}
// => is not really an operator and does not typically participate in precedence resolution.
// However, there is an exception if yield expressions with keys are involved:
// [yield $a => $b] is interpreted as [(yield $a => $b)], so we need to ensure that
// [(yield $a) => $b] is printed with parentheses. We approximate this by lowering the LHS
// precedence to that of yield (which will also print unnecessary parentheses for rare low
// precedence unary operators like include).
$yieldPrecedence = $this->precedenceMap[Expr\Yield_::class][0];
return $this->p($node, self::MAX_PRECEDENCE, $yieldPrecedence) . ' => ';
}