PhpParser\PrettyPrinterAbstract::prettyPrintExpr PHP Method

prettyPrintExpr() public method

Pretty prints an expression.
public prettyPrintExpr ( PhpParser\Node\Expr $node ) : string
$node PhpParser\Node\Expr Expression node
return string Pretty printed node
    public function prettyPrintExpr(Expr $node)
    {
        return $this->handleMagicTokens($this->p($node));
    }

Usage Example

 /**
  * Returns a simple human readable output for a value.
  *
  * @param \PhpParser\Node\Expr $value The value node as provided by
  *     PHP-Parser.
  *
  * @return string
  */
 protected function getRepresentationOfValue(\PhpParser\Node\Expr $value = null)
 {
     if (null === $value) {
         return '';
     }
     if (!self::$prettyPrinter) {
         self::$prettyPrinter = new PrettyPrinter();
     }
     return self::$prettyPrinter->prettyPrintExpr($value);
 }