PhpParser\PrettyPrinterAbstract::prettyPrint PHP Метод

prettyPrint() публичный Метод

Pretty prints an array of statements.
public prettyPrint ( array $stmts ) : string
$stmts array Array of statements
Результат string Pretty printed statements
    public function prettyPrint(array $stmts)
    {
        $this->preprocessNodes($stmts);
        return ltrim($this->handleMagicTokens($this->pStmts($stmts, false)));
    }

Usage Example

Пример #1
0
 /**
  * Prints information about a single recursive call. Override to change format.
  *
  * @param RecursiveCall $call
  */
 public function printSingleRecursiveCall(RecursiveCall $call)
 {
     // Get the code for the recursive call, but strip out comment lines
     $code = $this->nodePrinter->prettyPrint(array($call->getUsageNode()));
     $code = implode("\n", array_filter(explode("\n", $code), function ($line) {
         return !preg_match('#^[\\t ]*//#', $line);
     }));
     // Create the output that indicates where the recursive call was found
     echo "LOCATED IN FILE: " . $call->getFile()->getRealPath() . "\n";
     echo "DECLARED ON LINE #" . $call->getDeclarationNode()->getLine() . " ";
     echo "AND CALLED ON LINE #" . $call->getUsageNode()->getLine() . "\n";
     echo "CALLING CODE: {$code}\n\n";
 }
All Usage Examples Of PhpParser\PrettyPrinterAbstract::prettyPrint