From 61574a18189219fed22a15a3889829369a5c075c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 19 Jan 2017 20:55:08 +0100 Subject: [PATCH] Drop support for PHP 5.5 --- composer.json | 4 +-- lib/PhpParser/Builder/Use_.php | 2 +- lib/PhpParser/BuilderFactory.php | 2 +- lib/PhpParser/Lexer/Emulative.php | 44 +------------------------------ 4 files changed, 5 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index 62bbd2b..3127c46 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/lib/PhpParser/Builder/Use_.php b/lib/PhpParser/Builder/Use_.php index f6d3a85..e5b2c20 100644 --- a/lib/PhpParser/Builder/Use_.php +++ b/lib/PhpParser/Builder/Use_.php @@ -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)); diff --git a/lib/PhpParser/BuilderFactory.php b/lib/PhpParser/BuilderFactory.php index 42c7f61..9cc2fce 100644 --- a/lib/PhpParser/BuilderFactory.php +++ b/lib/PhpParser/BuilderFactory.php @@ -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)); diff --git a/lib/PhpParser/Lexer/Emulative.php b/lib/PhpParser/Lexer/Emulative.php index 739a328..dc3f75a 100644 --- a/lib/PhpParser/Lexer/Emulative.php +++ b/lib/PhpParser/Lexer/Emulative.php @@ -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('(\.\.\.|(?|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])) {