Laravel version update
Laravel version update
This commit is contained in:
@@ -1,63 +1,55 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Parser;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PhpParser\ErrorHandler;
|
||||
use PhpParser\Parser;
|
||||
|
||||
class Multiple implements Parser {
|
||||
class Multiple implements Parser
|
||||
{
|
||||
/** @var Parser[] List of parsers to try, in order of preference */
|
||||
private $parsers;
|
||||
/** @var Error[] Errors collected during last parse */
|
||||
private $errors;
|
||||
|
||||
/**
|
||||
* Create a parser which will try multiple parsers in an order of preference.
|
||||
*
|
||||
* Parsers will be invoked in the order they're provided to the constructor. If one of the
|
||||
* parsers runs without errors, it's output is returned. Otherwise the errors (and
|
||||
* PhpParser\Error exception) of the first parser are used.
|
||||
* parsers runs without throwing, it's output is returned. Otherwise the exception that the
|
||||
* first parser generated is thrown.
|
||||
*
|
||||
* @param Parser[] $parsers
|
||||
*/
|
||||
public function __construct(array $parsers) {
|
||||
$this->parsers = $parsers;
|
||||
$this->errors = [];
|
||||
}
|
||||
|
||||
public function parse($code) {
|
||||
list($firstStmts, $firstErrors, $firstError) = $this->tryParse($this->parsers[0], $code);
|
||||
if ($firstErrors === []) {
|
||||
$this->errors = [];
|
||||
public function parse(string $code, ErrorHandler $errorHandler = null) {
|
||||
if (null === $errorHandler) {
|
||||
$errorHandler = new ErrorHandler\Throwing;
|
||||
}
|
||||
|
||||
list($firstStmts, $firstError) = $this->tryParse($this->parsers[0], $errorHandler, $code);
|
||||
if ($firstError === null) {
|
||||
return $firstStmts;
|
||||
}
|
||||
|
||||
for ($i = 1, $c = count($this->parsers); $i < $c; ++$i) {
|
||||
list($stmts, $errors) = $this->tryParse($this->parsers[$i], $code);
|
||||
if ($errors === []) {
|
||||
$this->errors = [];
|
||||
list($stmts, $error) = $this->tryParse($this->parsers[$i], $errorHandler, $code);
|
||||
if ($error === null) {
|
||||
return $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = $firstErrors;
|
||||
if ($firstError) {
|
||||
throw $firstError;
|
||||
}
|
||||
return $firstStmts;
|
||||
throw $firstError;
|
||||
}
|
||||
|
||||
public function getErrors() {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
private function tryParse(Parser $parser, $code) {
|
||||
private function tryParse(Parser $parser, ErrorHandler $errorHandler, $code) {
|
||||
$stmts = null;
|
||||
$error = null;
|
||||
try {
|
||||
$stmts = $parser->parse($code);
|
||||
$stmts = $parser->parse($code, $errorHandler);
|
||||
} catch (Error $error) {}
|
||||
$errors = $parser->getErrors();
|
||||
return [$stmts, $errors, $error];
|
||||
return [$stmts, $error];
|
||||
}
|
||||
}
|
||||
|
5105
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
5105
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
File diff suppressed because it is too large
Load Diff
4521
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
4521
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user