コード例 #1
0
    /**
     * {@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
);
    }