private function getParser()
 {
     if (!isset($this->parser)) {
         $parserFactory = new ParserFactory();
         $this->parser = $parserFactory->createParser();
     }
     return $this->parser;
 }
 /**
  * CodeCleaner constructor.
  *
  * @param Parser        $parser    A PhpParser Parser instance. One will be created if not explicitly supplied.
  * @param Printer       $printer   A PhpParser Printer instance. One will be created if not explicitly supplied.
  * @param NodeTraverser $traverser A PhpParser NodeTraverser instance. One will be created if not explicitly supplied.
  */
 public function __construct(Parser $parser = null, Printer $printer = null, NodeTraverser $traverser = null)
 {
     if ($parser === null) {
         $parserFactory = new ParserFactory();
         $parser = $parserFactory->createParser();
     }
     $this->parser = $parser;
     $this->printer = $printer ?: new Printer();
     $this->traverser = $traverser ?: new NodeTraverser();
     foreach ($this->getDefaultPasses() as $pass) {
         $this->traverser->addVisitor($pass);
     }
 }
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $definition = array(new InputArgument('code', InputArgument::REQUIRED, 'PHP code to parse.'), new InputOption('depth', '', InputOption::VALUE_REQUIRED, 'Depth to parse', 10));
        if ($this->parserFactory->hasKindsSupport()) {
            $msg = 'One of PhpParser\\ParserFactory constants: ' . implode(', ', ParserFactory::getPossibleKinds()) . " (default is based on current interpreter's version)";
            $defaultKind = $this->parserFactory->getDefaultKind();
            $definition[] = new InputOption('kind', '', InputOption::VALUE_REQUIRED, $msg, $defaultKind);
        }
        $this->setName('parse')->setDefinition($definition)->setDescription('Parse PHP code and show the abstract syntax tree.')->setHelp(<<<'HELP'
Parse PHP code and show the abstract syntax tree.

This command is used in the development of PsySH. Given a string of PHP code,
it pretty-prints the PHP Parser parse tree.

See https://github.com/nikic/PHP-Parser

It prolly won't be super useful for most of you, but it's here if you want to play.
HELP
);
    }