upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2018 Justin Hileman
* (c) 2012-2022 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -11,7 +11,6 @@
namespace Psy;
use PhpParser\Lexer;
use PhpParser\Parser;
use PhpParser\ParserFactory as OriginalParserFactory;
@@ -20,8 +19,8 @@ use PhpParser\ParserFactory as OriginalParserFactory;
*/
class ParserFactory
{
const ONLY_PHP5 = 'ONLY_PHP5';
const ONLY_PHP7 = 'ONLY_PHP7';
const ONLY_PHP5 = 'ONLY_PHP5';
const ONLY_PHP7 = 'ONLY_PHP7';
const PREFER_PHP5 = 'PREFER_PHP5';
const PREFER_PHP7 = 'PREFER_PHP7';
@@ -30,23 +29,11 @@ class ParserFactory
*
* @return array
*/
public static function getPossibleKinds()
public static function getPossibleKinds(): array
{
return ['ONLY_PHP5', 'ONLY_PHP7', 'PREFER_PHP5', 'PREFER_PHP7'];
}
/**
* Is this parser factory supports kinds?
*
* PHP parser < 2.0 doesn't support kinds, >= 2.0 — does.
*
* @return bool
*/
public function hasKindsSupport()
{
return \class_exists('PhpParser\ParserFactory');
}
/**
* Default kind (if supported, based on current interpreter's version).
*
@@ -54,9 +41,7 @@ class ParserFactory
*/
public function getDefaultKind()
{
if ($this->hasKindsSupport()) {
return \version_compare(PHP_VERSION, '7.0', '>=') ? static::ONLY_PHP7 : static::ONLY_PHP5;
}
return static::ONLY_PHP7;
}
/**
@@ -66,26 +51,18 @@ class ParserFactory
*
* @return Parser
*/
public function createParser($kind = null)
public function createParser($kind = null): Parser
{
if ($this->hasKindsSupport()) {
$originalFactory = new OriginalParserFactory();
$originalFactory = new OriginalParserFactory();
$kind = $kind ?: $this->getDefaultKind();
$kind = $kind ?: $this->getDefaultKind();
if (!\in_array($kind, static::getPossibleKinds())) {
throw new \InvalidArgumentException('Unknown parser kind');
}
$parser = $originalFactory->create(\constant('PhpParser\ParserFactory::' . $kind));
} else {
if ($kind !== null) {
throw new \InvalidArgumentException('Install PHP Parser v2.x to specify parser kind');
}
$parser = new Parser(new Lexer());
if (!\in_array($kind, static::getPossibleKinds())) {
throw new \InvalidArgumentException('Unknown parser kind');
}
$parser = $originalFactory->create(\constant(OriginalParserFactory::class.'::'.$kind));
return $parser;
}
}