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

Breadcrumb

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

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

Standard

Namespace

PhpParser\PrettyPrinter

Code

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) . ' => ';
}

API Navigation

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