From ccf574db379dc4f1ccc6e8c3d56a2e779de4cfa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Mon, 13 May 2024 23:47:51 +0200 Subject: [PATCH] test: standardize the autoload usage (#1031) --- fixtures/set016-symfony-finder/main.php | 4 +++- fixtures/set017-symfony-di/main.php | 4 +++- fixtures/set018-nikic-parser/main.php | 4 +++- fixtures/set024/main.php | 8 +++----- fixtures/set025/main.php | 8 +++----- fixtures/set029-easy-rdf/main.php | 10 +++------- fixtures/set030/main.php | 10 +++------- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/fixtures/set016-symfony-finder/main.php b/fixtures/set016-symfony-finder/main.php index 123db2e14..a731c2721 100644 --- a/fixtures/set016-symfony-finder/main.php +++ b/fixtures/set016-symfony-finder/main.php @@ -5,7 +5,9 @@ use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; -require_once __DIR__ . '/vendor/autoload.php'; +require file_exists(__DIR__.'/vendor/scoper-autoload.php') + ? __DIR__.'/vendor/scoper-autoload.php' + : __DIR__.'/vendor/autoload.php'; $finder = Finder::create()->files()->in(__DIR__)->depth(0)->sortByName(); diff --git a/fixtures/set017-symfony-di/main.php b/fixtures/set017-symfony-di/main.php index 9506f5f45..39a9c3b5f 100644 --- a/fixtures/set017-symfony-di/main.php +++ b/fixtures/set017-symfony-di/main.php @@ -5,7 +5,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -require_once __DIR__ . '/vendor/autoload.php'; +require file_exists(__DIR__.'/vendor/scoper-autoload.php') + ? __DIR__.'/vendor/scoper-autoload.php' + : __DIR__.'/vendor/autoload.php'; interface Salute { diff --git a/fixtures/set018-nikic-parser/main.php b/fixtures/set018-nikic-parser/main.php index ce818f141..f1a7b5851 100644 --- a/fixtures/set018-nikic-parser/main.php +++ b/fixtures/set018-nikic-parser/main.php @@ -5,7 +5,9 @@ use PhpParser\NodeDumper; use PhpParser\ParserFactory; -require_once __DIR__ . '/vendor/autoload.php'; +require file_exists(__DIR__.'/vendor/scoper-autoload.php') + ? __DIR__.'/vendor/scoper-autoload.php' + : __DIR__.'/vendor/autoload.php'; $code = <<<'CODE' load(); diff --git a/fixtures/set030/main.php b/fixtures/set030/main.php index bf843b52f..9d9f61f2c 100644 --- a/fixtures/set030/main.php +++ b/fixtures/set030/main.php @@ -2,13 +2,9 @@ declare(strict_types=1); -$autoload = __DIR__.'/vendor/scoper-autoload.php'; - -if (false === file_exists($autoload)) { - $autoload = __DIR__.'/vendor/autoload.php'; -} - -require_once $autoload; +require file_exists(__DIR__.'/vendor/scoper-autoload.php') + ? __DIR__.'/vendor/scoper-autoload.php' + : __DIR__.'/vendor/autoload.php'; echo foo() ? 'ok' : 'ko'; echo PHP_EOL;