diff --git a/Makefile b/Makefile index 5e190cd0..5e38f842 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ blackfire: vendor .PHONY: e2e e2e: ## Runs end-to-end tests -e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 e2e_028 e2e_029 e2e_030 e2e_031 e2e_032 e2e_033 +e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 e2e_028 e2e_029 e2e_030 e2e_031 e2e_032 e2e_033 e2e_034 .PHONY: e2e_004 e2e_004: ## Runs end-to-end tests for the fixture set 004 — Minimalistic codebase @@ -495,6 +495,25 @@ e2e_033: $(PHP_SCOPER_PHAR_BIN) diff fixtures/set033-user-global-function/expected-output build/set033-user-global-function/output + +.PHONY: e2e_034 +e2e_034: ## Runs end-to-end tests for the fixture set 034 — Leverage Composer InstalledVersions +e2e_034: $(PHP_SCOPER_PHAR_BIN) + $(PHP_SCOPER_PHAR) add-prefix \ + --working-dir=fixtures/set034-installed-versions \ + --output-dir=../../build/set034-installed-versions \ + --force \ + --no-interaction \ + --stop-on-failure + + php fixtures/set034-installed-versions/index.php > fixtures/set034-installed-versions/expected-output + + composer --working-dir=build/set034-installed-versions dump-autoload --no-dev + php build/set034-installed-versions/index.php > build/set034-installed-versions/output + + diff fixtures/set034-installed-versions/expected-output build/set034-installed-versions/output + + # # Rules from files #--------------------------------------------------------------------------- diff --git a/fixtures/set034-installed-versions/composer.json b/fixtures/set034-installed-versions/composer.json new file mode 100644 index 00000000..8aa15271 --- /dev/null +++ b/fixtures/set034-installed-versions/composer.json @@ -0,0 +1,6 @@ +{ + "bin": "index.php", + "require": { + "nikic/iter": "^2.0" + } +} diff --git a/fixtures/set034-installed-versions/composer.lock b/fixtures/set034-installed-versions/composer.lock new file mode 100644 index 00000000..856f1d17 --- /dev/null +++ b/fixtures/set034-installed-versions/composer.lock @@ -0,0 +1,69 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "0e88c545a234e507aec82c192563842e", + "packages": [ + { + "name": "nikic/iter", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/iter.git", + "reference": "d1323929952ddcb0b06439991f93bde3816a39e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/iter/zipball/d1323929952ddcb0b06439991f93bde3816a39e9", + "reference": "d1323929952ddcb0b06439991f93bde3816a39e9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/iter.func.php", + "src/iter.php", + "src/iter.rewindable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + } + ], + "description": "Iteration primitives using generators", + "keywords": [ + "functional", + "generator", + "iterator" + ], + "support": { + "issues": "https://github.com/nikic/iter/issues", + "source": "https://github.com/nikic/iter/tree/v2.2.0" + }, + "time": "2021-08-02T15:04:32+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/fixtures/set034-installed-versions/expected-output b/fixtures/set034-installed-versions/expected-output new file mode 100644 index 00000000..90b5016e --- /dev/null +++ b/fixtures/set034-installed-versions/expected-output @@ -0,0 +1 @@ +ok. diff --git a/fixtures/set034-installed-versions/index.php b/fixtures/set034-installed-versions/index.php new file mode 100644 index 00000000..44b1fbf7 --- /dev/null +++ b/fixtures/set034-installed-versions/index.php @@ -0,0 +1,15 @@ + [ + (new Finder()) + ->files() + ->in(__DIR__), + ], + 'exclude-functions' => ['trigger_deprecation'], +]; diff --git a/src/Autoload/ScoperAutoloadGenerator.php b/src/Autoload/ScoperAutoloadGenerator.php index 4fdc9c67..781a234f 100644 --- a/src/Autoload/ScoperAutoloadGenerator.php +++ b/src/Autoload/ScoperAutoloadGenerator.php @@ -79,6 +79,7 @@ public function dump(): string namespace { \$loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; } {$statements} @@ -95,6 +96,7 @@ public function dump(): string // scoper-autoload.php @generated by PhpScoper \$loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; {$statements} diff --git a/tests/Autoload/ScoperAutoloadGeneratorTest.php b/tests/Autoload/ScoperAutoloadGeneratorTest.php index 70d0e5df..84ec0677 100644 --- a/tests/Autoload/ScoperAutoloadGeneratorTest.php +++ b/tests/Autoload/ScoperAutoloadGeneratorTest.php @@ -45,6 +45,7 @@ public static function provideRegistry(): iterable // scoper-autoload.php @generated by PhpScoper $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; return $loader; @@ -65,6 +66,7 @@ public static function provideRegistry(): iterable // scoper-autoload.php @generated by PhpScoper $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; // Exposed functions. For more information see: // https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-functions @@ -100,6 +102,7 @@ function bar() { namespace { $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; } // Exposed functions. For more information see: @@ -146,6 +149,7 @@ function baz() { // scoper-autoload.php @generated by PhpScoper $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; // Exposed classes. For more information see: // https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-classes @@ -172,6 +176,7 @@ function baz() { // scoper-autoload.php @generated by PhpScoper $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; // Exposed classes. For more information see: // https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-classes @@ -207,6 +212,7 @@ function baz() { namespace { $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; } // Exposed classes. For more information see: @@ -276,6 +282,7 @@ function baz() { // scoper-autoload.php @generated by PhpScoper $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; // Exposed functions. For more information see: // https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-functions @@ -306,6 +313,7 @@ function __autoload($className) { namespace { $loader = require_once __DIR__.'/autoload.php'; + require_once __DIR__.'/composer/InstalledVersions.php'; } // Exposed functions. For more information see: