public function createParser($kind = null)
    {
        if ($this->hasKindsSupport()) {
            $originalFactory = new OriginalParserFactory();

            $kind = $kind ?: $this->getDefaultKind();

            if (!\in_array($kind, static::getPossibleKinds())) {
                throw new \InvalidArgumentException('Unknown parser kind');
            }

            $parser = $originalFactory->create(\constant('PhpParser\ParserFactory::' . $kind));
        } else {
            if ($kind !== null) {
                throw new \InvalidArgumentException('Install PHP Parser v2.x to specify parser kind');
            }

            $parser = new Parser(new Lexer());
        }

        return $parser;
    }
public function createParser($kind = null)
    {
        if ($this->hasKindsSupport()) {
            $originalFactory = new OriginalParserFactory();

            $kind = $kind ?: $this->getDefaultKind();

            if (!\in_array($kind, static::getPossibleKinds())) {
                throw new \InvalidArgumentException('Unknown parser kind');
            }

            $parser = $originalFactory->create(\constant('PhpParser\ParserFactory::' . $kind));
        } else {
            if ($kind !== null) {
                throw new \InvalidArgumentException('Install PHP Parser v2.x to specify parser kind');
            }

            $parser = new Parser(new Lexer());
        }

        return $parser;
    }
public function createParser ( $ kind = null ) { if ( $ this -> hasKindsSupport ( ) ) { $ originalFactory = new OriginalParserFactory ( ) ; $ kind = $ kind ? : $ this -> getDefaultKind ( ) ; if ( ! \ in_array ( $ kind , static :: getPossibleKinds ( ) ) ) { throw new \ InvalidArgumentException ( 'Unknown parser kind' ) ; } $ parser = $ originalFactory -> create ( \ constant ( 'PhpParser\ParserFactory::' . $ kind ) ) ; } else { if ( $ kind !== null ) { throw new \ InvalidArgumentException ( 'Install PHP Parser v2.x to specify parser kind' ) ; } $ parser = new Parser ( new Lexer ( ) ) ; } return $ parser ; }
New parser instance with given kind.

@param string|null $kind One of class constants (only for PHP parser 2.0 and above)

@return Parser
New parser instance with given kind .