mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +01:00
Rename ParserInterface to Parser
And drop the alias of Parser to Parser\Php5.
This commit is contained in:
parent
d8312a09a3
commit
f2b7a31509
@ -2,4 +2,23 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class Parser extends Parser\Php5 {}
|
||||
interface Parser {
|
||||
/**
|
||||
* Parses PHP code into a node tree.
|
||||
*
|
||||
* @param string $code The source code to parse
|
||||
*
|
||||
* @return Node[]|null Array of statements (or null if the 'throwOnError' option is disabled and the parser was
|
||||
* unable to recover from an error).
|
||||
*/
|
||||
public function parse($code);
|
||||
|
||||
/**
|
||||
* Get array of errors that occurred during the last parse.
|
||||
*
|
||||
* This method may only return multiple errors if the 'throwOnError' option is disabled.
|
||||
*
|
||||
* @return Error[]
|
||||
*/
|
||||
public function getErrors();
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace PhpParser\Parser;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PhpParser\ParserInterface;
|
||||
use PhpParser\Parser;
|
||||
|
||||
class Multiple implements ParserInterface {
|
||||
/** @var ParserInterface[] List of parsers to try, in order of preference */
|
||||
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;
|
||||
@ -18,7 +18,7 @@ class Multiple implements ParserInterface {
|
||||
* errors, it's output is returned. Otherwise the errors (and PhpParser\Error exception) of the first parser are
|
||||
* used.
|
||||
*
|
||||
* @param ParserInterface[] $parsers
|
||||
* @param Parser[] $parsers
|
||||
*/
|
||||
public function __construct(array $parsers) {
|
||||
$this->parsers = $parsers;
|
||||
@ -51,7 +51,7 @@ class Multiple implements ParserInterface {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
private function tryParse(ParserInterface $parser, $code) {
|
||||
private function tryParse(Parser $parser, $code) {
|
||||
$stmts = null;
|
||||
$error = null;
|
||||
try {
|
||||
|
@ -8,7 +8,7 @@ namespace PhpParser;
|
||||
*/
|
||||
use PhpParser\Node\Name;
|
||||
|
||||
abstract class ParserAbstract implements ParserInterface
|
||||
abstract class ParserAbstract implements Parser
|
||||
{
|
||||
const SYMBOL_NONE = -1;
|
||||
|
||||
|
@ -10,7 +10,7 @@ class ParserFactory {
|
||||
|
||||
/**
|
||||
* @param int $kind
|
||||
* @return ParserInterface
|
||||
* @return Parser
|
||||
*/
|
||||
public function create($kind) {
|
||||
$lexer = new Lexer\Emulative();
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
interface ParserInterface {
|
||||
/**
|
||||
* Parses PHP code into a node tree.
|
||||
*
|
||||
* @param string $code The source code to parse
|
||||
*
|
||||
* @return Node[]|null Array of statements (or null if the 'throwOnError' option is disabled and the parser was
|
||||
* unable to recover from an error).
|
||||
*/
|
||||
public function parse($code);
|
||||
|
||||
/**
|
||||
* Get array of errors that occurred during the last parse.
|
||||
*
|
||||
* This method may only return multiple errors if the 'throwOnError' option is disabled.
|
||||
*
|
||||
* @return Error[]
|
||||
*/
|
||||
public function getErrors();
|
||||
}
|
@ -37,7 +37,7 @@ class CodeParsingTest extends CodeTestAbstract
|
||||
}
|
||||
}
|
||||
|
||||
private function getParseOutput(ParserInterface $parser, $code) {
|
||||
private function getParseOutput(Parser $parser, $code) {
|
||||
$stmts = $parser->parse($code);
|
||||
$errors = $parser->getErrors();
|
||||
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Comment;
|
||||
|
||||
abstract class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @returns ParserInterface */
|
||||
/** @returns Parser */
|
||||
abstract protected function getParser(Lexer $lexer);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user