From 81df285051f8f8787d38801d8a67116e16378772 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 9 Oct 2024 14:06:23 +0200 Subject: [PATCH 1/3] [TASK] Require at least PHP 7.1 This is in preparation for PHP 8.4 support (deprecated implicitly nullable parameters). --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d75021..65f0c4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] steps: - uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index a6187d0..6f7b045 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "psr-4": { "TYPO3\\ClassAliasLoader\\Test\\": "tests/"} }, "require": { - "php": ">=5.3.7", + "php": ">=7.1", "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { From 47ea85c6bfeff0caa2fbcae8de16a88d7efe3bc9 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 3 Oct 2024 17:57:56 +0200 Subject: [PATCH 2/3] [TASK] Fix PHP 8.4 compatibility Defaulting to null without being nullable (?Foo) is deprecated for typed parameters in PHP 8.4, therefore nullable is now specified explicitly. This change requires at least PHP 7.1 (which has been made a minimum with the parent commit). Additional the call to str_getcsv is adapted to set all optional arguments as the defaults will change in PHP >= 9 and PHP 8.4 deprecated the omission of the optional arguments. Fixes #31 --- src/ClassAliasMapGenerator.php | 2 +- src/Config.php | 5 +++-- src/IncludeFile.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ClassAliasMapGenerator.php b/src/ClassAliasMapGenerator.php index 8c09ee8..ad59130 100644 --- a/src/ClassAliasMapGenerator.php +++ b/src/ClassAliasMapGenerator.php @@ -46,7 +46,7 @@ class ClassAliasMapGenerator * @param Composer $composer * @param IOInterface $io */ - public function __construct(Composer $composer, IOInterface $io = null, $config = null) + public function __construct(Composer $composer, ?IOInterface $io = null, $config = null) { $this->composer = $composer; $this->io = $io ?: new NullIO(); diff --git a/src/Config.php b/src/Config.php index 8155459..a26b40d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ class Config * @param PackageInterface $package * @param IOInterface $io */ - public function __construct(PackageInterface $package, IOInterface $io = null) + public function __construct(PackageInterface $package, ?IOInterface $io = null) { $this->io = $io ?: new NullIO(); $this->setAliasLoaderConfigFromPackage($package); @@ -55,7 +55,8 @@ public function get($configKey) throw new \InvalidArgumentException('Configuration key must not be empty', 1444039407); } // Extract parts of the path - $configKey = str_getcsv($configKey, '.'); + $configKey = str_getcsv($configKey, '.', '"', '\\'); + // Loop through each part and extract its value $value = $this->config; foreach ($configKey as $segment) { diff --git a/src/IncludeFile.php b/src/IncludeFile.php index 308ad4b..0ec2af6 100644 --- a/src/IncludeFile.php +++ b/src/IncludeFile.php @@ -48,7 +48,7 @@ class IncludeFile * @param TokenInterface[] $tokens * @param Filesystem $filesystem */ - public function __construct(IOInterface $io, Composer $composer, array $tokens, Filesystem $filesystem = null) + public function __construct(IOInterface $io, Composer $composer, array $tokens, ?Filesystem $filesystem = null) { $this->io = $io; $this->composer = $composer; From af77b31c3b9b915c2dd6a05cc6c62fe279c5cde8 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 3 Oct 2024 19:06:37 +0200 Subject: [PATCH 3/3] [TASK] Test PHP 8.3 and 8.4 Also drop prophecy workarounds since PHP 8.2 compatibility has been enabled upstream. --- .github/workflows/tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 65f0c4d..ff2acc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - uses: actions/checkout@v2 @@ -28,13 +28,7 @@ jobs: find src/ tests/ -name '*.php' -print0 | xargs -0 -n1 -P4 php -dxdebug.mode=off -l >/dev/null - name: Install dependencies - if: ${{ matrix.php <= '8.1' }} run: composer update - - name: Install dependencies PHP 8.2 - # @todo: Needed until prophecy (req by phpunit) allows PHP 8.2, https://github.com/phpspec/prophecy/issues/556 - if: ${{ matrix.php > '8.1' }} - run: composer update --ignore-platform-req=php+ - - name: Run test suite run: vendor/bin/phpunit