From d146a214611b75b1dc03c88cd8f581a6bb62b1c3 Mon Sep 17 00:00:00 2001 From: smoench Date: Fri, 13 Nov 2020 15:44:30 +0100 Subject: [PATCH] try emulative lexer --- .github/workflows/build.yml | 4 -- composer.json | 12 +++-- composer.lock | 43 +++++++++------ src/Configuration/Configuration.php | 2 +- src/PhpScoper/Container.php | 84 ----------------------------- 5 files changed, 36 insertions(+), 109 deletions(-) delete mode 100644 src/PhpScoper/Container.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36846ca8c..1ee352982 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,6 @@ jobs: fail-fast: false matrix: include: - - php: 7.2 - tools: "composer:v1" - coverage: "none" - git-fetch-depth: 1 - php: 7.3 tools: "composer:v1" coverage: "none" diff --git a/composer.json b/composer.json index e4bce8fd8..83dd6bafe 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^7.2", + "php": "^7.3", "ext-phar": "*", "amphp/parallel-functions": "^0.1.3", "beberlei/assert": "^3.2", @@ -49,7 +49,7 @@ "composer/semver": "^3.2", "composer/xdebug-handler": "^1.3.2", "hoa/compiler": "^3.17", - "humbug/php-scoper": "^0.13", + "humbug/php-scoper": "dev-emulative@dev", "justinrainbow/json-schema": "^5.2.9", "nikic/iter": "^2.0", "nikic/php-parser": "^4.2", @@ -73,11 +73,17 @@ "suggest": { "ext-openssl": "To accelerate private key generation." }, + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:smoench/php-scoper.git" + } + ], "config": { "bin-dir": "bin", "platform": { - "php": "7.2.9" + "php": "7.3" }, "sort-packages": true }, diff --git a/composer.lock b/composer.lock index e52fda612..0a75270c2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bbbbb7a1630e8e14e027106485de288c", + "content-hash": "a6c988761b028fc8a6ff93c53a5815de", "packages": [ { "name": "amphp/amp", @@ -1691,23 +1691,23 @@ }, { "name": "humbug/php-scoper", - "version": "0.13.9", + "version": "dev-emulative", "source": { "type": "git", - "url": "https://github.com/humbug/php-scoper.git", - "reference": "d6d7e83e44ec7a61202289159d4600b476e303e6" + "url": "https://github.com/smoench/php-scoper.git", + "reference": "6f3db1480e6e1f82e0df44bec64639511dc2c9b5" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/humbug/php-scoper/zipball/d6d7e83e44ec7a61202289159d4600b476e303e6", - "reference": "d6d7e83e44ec7a61202289159d4600b476e303e6", + "url": "https://github.com/gitapi/repos/smoench/php-scoper/zipball/6f3db1480e6e1f82e0df44bec64639511dc2c9b5", + "reference": "6f3db1480e6e1f82e0df44bec64639511dc2c9b5", "shasum": "" }, "require": { "composer/package-versions-deprecated": "^1.8", "jetbrains/phpstorm-stubs": "dev-master", "nikic/php-parser": "^4.0", - "php": "^7.2", + "php": "^7.3", "symfony/console": "^3.2 || ^4.0", "symfony/filesystem": "^3.2 || ^4.0", "symfony/finder": "^3.2 || ^4.0" @@ -1741,7 +1741,15 @@ "Humbug\\PhpScoper\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "files": [ + "tests/functions.php", + "src/json.php" + ], + "psr-4": { + "Humbug\\PhpScoper\\": "tests/" + } + }, "license": [ "MIT" ], @@ -1761,16 +1769,15 @@ ], "description": "Prefixes all PHP namespaces in a file or directory.", "support": { - "issues": "https://github.com/humbug/php-scoper/issues", - "source": "https://github.com/humbug/php-scoper/tree/0.13.9" + "source": "https://github.com/smoench/php-scoper/tree/emulative" }, "funding": [ { - "url": "https://github.com/theofidry", - "type": "github" + "type": "github", + "url": "https://github.com/theofidry" } ], - "time": "2020-11-06T23:14:56+00:00" + "time": "2020-11-17T11:48:12+00:00" }, { "name": "jetbrains/phpstorm-stubs", @@ -1819,7 +1826,7 @@ "support": { "source": "https://github.com/JetBrains/phpstorm-stubs/tree/master" }, - "time": "2020-11-16T19:39:13+00:00" + "time": "2020-11-17T11:49:11+00:00" }, { "name": "justinrainbow/json-schema", @@ -5225,16 +5232,18 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "humbug/php-scoper": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.2", + "php": "^7.3", "ext-phar": "*" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.9" + "php": "7.3" }, "plugin-api-version": "2.0.0" } diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index da29509aa..6c0dd57d5 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -2855,7 +2855,7 @@ static function (string $path) use ($basePath): string { $scoper = new SerializablePhpScoper( static function () use ($whitelistedFiles): Scoper { - $scoper = (new \KevinGH\Box\PhpScoper\Container())->getScoper(); + $scoper = (new Container())->getScoper(); if ([] !== $whitelistedFiles) { return new FileWhitelistScoper($scoper, ...$whitelistedFiles); diff --git a/src/PhpScoper/Container.php b/src/PhpScoper/Container.php deleted file mode 100644 index e0d9af1c3..000000000 --- a/src/PhpScoper/Container.php +++ /dev/null @@ -1,84 +0,0 @@ -, - * Pádraic Brady - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace KevinGH\Box\PhpScoper; - -use Humbug\PhpScoper\PhpParser\TraverserFactory; -use Humbug\PhpScoper\Reflector; -use Humbug\PhpScoper\Scoper; -use Humbug\PhpScoper\Scoper\Composer\InstalledPackagesScoper; -use Humbug\PhpScoper\Scoper\Composer\JsonFileScoper; -use Humbug\PhpScoper\Scoper\NullScoper; -use Humbug\PhpScoper\Scoper\PatchScoper; -use Humbug\PhpScoper\Scoper\PhpScoper; -use Humbug\PhpScoper\Scoper\SymfonyScoper; -use PhpParser\Lexer; -use PhpParser\Parser; -use PhpParser\ParserFactory; - -/** - * Copied for testing purpose - */ -final class Container -{ - private $parser; - private $reflector; - private $scoper; - - public function getScoper(): Scoper - { - if (null === $this->scoper) { - $this->scoper = new PatchScoper( - new PhpScoper( - $this->getParser(), - new JsonFileScoper( - new InstalledPackagesScoper( - new SymfonyScoper( - new NullScoper() - ) - ) - ), - new TraverserFactory($this->getReflector()) - ) - ); - } - - return $this->scoper; - } - - public function getParser(): Parser - { - if (null === $this->parser) { - $phpVersion = Lexer\Emulative::PHP_7_3; - if (PHP_VERSION_ID >= 80000) { - $phpVersion = Lexer\Emulative::PHP_8_0; - } elseif (PHP_VERSION_ID >= 70400) { - $phpVersion = Lexer\Emulative::PHP_7_4; - } - - $this->parser = (new ParserFactory())->create(ParserFactory::ONLY_PHP7, new Lexer\Emulative(['phpVersion' => $phpVersion])); - } - - return $this->parser; - } - - public function getReflector(): Reflector - { - if (null === $this->reflector) { - $this->reflector = new Reflector(); - } - - return $this->reflector; - } -}