Rename ParserInterface to Parser

And drop the alias of Parser to Parser\Php5.
This commit is contained in:
Nikita Popov 2015-06-20 11:47:25 +02:00
parent d8312a09a3
commit f2b7a31509
7 changed files with 29 additions and 34 deletions

View File

@ -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();
}

View File

@ -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 {

View File

@ -8,7 +8,7 @@ namespace PhpParser;
*/
use PhpParser\Node\Name;
abstract class ParserAbstract implements ParserInterface
abstract class ParserAbstract implements Parser
{
const SYMBOL_NONE = -1;

View File

@ -10,7 +10,7 @@ class ParserFactory {
/**
* @param int $kind
* @return ParserInterface
* @return Parser
*/
public function create($kind) {
$lexer = new Lexer\Emulative();

View File

@ -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();
}

View File

@ -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();

View File

@ -6,7 +6,7 @@ use PhpParser\Comment;
abstract class ParserTest extends \PHPUnit_Framework_TestCase
{
/** @returns ParserInterface */
/** @returns Parser */
abstract protected function getParser(Lexer $lexer);
/**