1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Drop support for PHP 5.5

This commit is contained in:
Nikita Popov 2017-01-19 20:55:08 +01:00
parent be2ed243f6
commit 61574a1818
4 changed files with 5 additions and 47 deletions

View File

@ -10,11 +10,11 @@
}
],
"require": {
"php": ">=5.5",
"php": ">=5.6",
"ext-tokenizer": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpunit": "~5.0"
},
"autoload": {
"psr-4": {

View File

@ -38,7 +38,7 @@ class Use_ extends BuilderAbstract {
}
public function __call($name, $args) {
if (method_exists($this, $name . '_')) {
return call_user_func_array(array($this, $name . '_'), $args);
return $this->{$name . '_'}(...$args);
}
throw new \LogicException(sprintf('Method "%s" does not exist', $name));

View File

@ -119,7 +119,7 @@ class BuilderFactory
public function __call($name, array $args) {
if (method_exists($this, '_' . $name)) {
return call_user_func_array(array($this, '_' . $name), $args);
return $this->{'_' . $name}(...$args);
}
throw new \LogicException(sprintf('Method "%s" does not exist', $name));

View File

@ -10,15 +10,11 @@ class Emulative extends \PhpParser\Lexer
protected $newKeywords;
protected $inObjectAccess;
const T_ELLIPSIS = 1001;
const T_POW = 1002;
const T_POW_EQUAL = 1003;
const T_COALESCE = 1004;
const T_SPACESHIP = 1005;
const T_YIELD_FROM = 1006;
const PHP_7_0 = '7.0.0dev';
const PHP_5_6 = '5.6.0rc1';
public function __construct(array $options = array()) {
parent::__construct($options);
@ -42,13 +38,6 @@ class Emulative extends \PhpParser\Lexer
$this->tokenMap[self::T_COALESCE] = Tokens::T_COALESCE;
$this->tokenMap[self::T_SPACESHIP] = Tokens::T_SPACESHIP;
$this->tokenMap[self::T_YIELD_FROM] = Tokens::T_YIELD_FROM;
if (version_compare(PHP_VERSION, self::PHP_5_6, '>=')) {
return;
}
$this->tokenMap[self::T_ELLIPSIS] = Tokens::T_ELLIPSIS;
$this->tokenMap[self::T_POW] = Tokens::T_POW;
$this->tokenMap[self::T_POW_EQUAL] = Tokens::T_POW_EQUAL;
}
public function startLexing($code, ErrorHandler $errorHandler = null) {
@ -68,15 +57,7 @@ class Emulative extends \PhpParser\Lexer
return false;
}
if (preg_match('(\?\?|<=>|yield[ \n\r\t]+from)', $code)) {
return true;
}
if (version_compare(PHP_VERSION, self::PHP_5_6, '>=')) {
return false;
}
return preg_match('(\.\.\.|(?<!/)\*\*(?!/))', $code);
return preg_match('(\?\?|<=>|yield[ \n\r\t]+from)', $code);
}
/*
@ -105,20 +86,6 @@ class Emulative extends \PhpParser\Lexer
$c--;
continue;
}
if ($this->tokens[$i] === '*' && $this->tokens[$i + 1] === '*') {
array_splice($this->tokens, $i, 2, array(
array(self::T_POW, '**', $line)
));
$c--;
continue;
}
if ($this->tokens[$i] === '*' && $this->tokens[$i + 1][0] === T_MUL_EQUAL) {
array_splice($this->tokens, $i, 2, array(
array(self::T_POW_EQUAL, '**=', $line)
));
$c--;
continue;
}
}
if (isset($this->tokens[$i + 2])) {
@ -137,15 +104,6 @@ class Emulative extends \PhpParser\Lexer
$line += substr_count($this->tokens[$i][1], "\n");
continue;
}
if ($this->tokens[$i] === '.' && $this->tokens[$i + 1] === '.'
&& $this->tokens[$i + 2] === '.'
) {
array_splice($this->tokens, $i, 3, array(
array(self::T_ELLIPSIS, '...', $line)
));
$c -= 2;
continue;
}
}
if (\is_array($this->tokens[$i])) {