<?php declare(strict_types=1); namespace PhpParser; class ParserFactory { const PREFER_PHP7 = 1; const PREFER_PHP5 = 2; const ONLY_PHP7 = 3; const ONLY_PHP5 = 4; /** * Creates a Parser instance, according to the provided kind. * * @param int $kind One of ::PREFER_PHP7, ::PREFER_PHP5, ::ONLY_PHP7 or ::ONLY_PHP5 * @param Lexer|null $lexer Lexer to use. Defaults to emulative lexer when not specified * @param array $parserOptions Parser options. See ParserAbstract::__construct() argument * * @return Parser The parser instance */ public function create(int $kind, Lexer $lexer = null, array $parserOptions = []) : Parser { if (null === $lexer) { $lexer = new Lexer\Emulative(); } switch ($kind) { case self::PREFER_PHP7: return new Parser\Multiple([ new Parser\Php7($lexer, $parserOptions), new Parser\Php5($lexer, $parserOptions) ]); case self::PREFER_PHP5: return new Parser\Multiple([ new Parser\Php5($lexer, $parserOptions), new Parser\Php7($lexer, $parserOptions) ]); case self::ONLY_PHP7: return new Parser\Php7($lexer, $parserOptions); case self::ONLY_PHP5: return new Parser\Php5($lexer, $parserOptions); default: throw new \LogicException( 'Kind must be one of ::PREFER_PHP7, ::PREFER_PHP5, ::ONLY_PHP7 or ::ONLY_PHP5' ); } } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Builder | Folder | 0755 |
|
|
Comment | Folder | 0755 |
|
|
ErrorHandler | Folder | 0755 |
|
|
Internal | Folder | 0755 |
|
|
Lexer | Folder | 0755 |
|
|
Node | Folder | 0755 |
|
|
NodeVisitor | Folder | 0755 |
|
|
Parser | Folder | 0755 |
|
|
PrettyPrinter | Folder | 0755 |
|
|
Builder.php | File | 203 B | 0644 |
|
BuilderFactory.php | File | 10.84 KB | 0644 |
|
BuilderHelpers.php | File | 9.54 KB | 0644 |
|
Comment.php | File | 7.37 KB | 0644 |
|
ConstExprEvaluationException.php | File | 86 B | 0644 |
|
ConstExprEvaluator.php | File | 9.05 KB | 0644 |
|
Error.php | File | 4.92 KB | 0644 |
|
ErrorHandler.php | File | 294 B | 0644 |
|
JsonDecoder.php | File | 3.3 KB | 0644 |
|
Lexer.php | File | 23.51 KB | 0644 |
|
NameContext.php | File | 9.69 KB | 0644 |
|
Node.php | File | 3.88 KB | 0644 |
|
NodeAbstract.php | File | 5.03 KB | 0644 |
|
NodeDumper.php | File | 6.69 KB | 0644 |
|
NodeFinder.php | File | 2.39 KB | 0644 |
|
NodeTraverser.php | File | 10.34 KB | 0644 |
|
NodeTraverserInterface.php | File | 629 B | 0644 |
|
NodeVisitor.php | File | 1.98 KB | 0644 |
|
NodeVisitorAbstract.php | File | 438 B | 0644 |
|
Parser.php | File | 628 B | 0644 |
|
ParserAbstract.php | File | 41.22 KB | 0644 |
|
ParserFactory.php | File | 1.58 KB | 0644 |
|
PrettyPrinterAbstract.php | File | 60.3 KB | 0644 |
|