From 7de1d81a55f82731fb8a8e7d8e7f7592be547f81 Mon Sep 17 00:00:00 2001 From: Mustafa Hussain Date: Tue, 1 Aug 2023 15:36:12 +0300 Subject: [PATCH] support PHP 8.2 (#25) * add support to PHP 8.2 * replace ocramius/proxy-manager with friendsofphp/proxy-manager-lts * drop PHP 7.4 support * remove better-reflection v4 --- .github/workflows/tests.yml | 2 +- composer.json | 10 +++++----- .../rg/injektor/DependencyInjectionContainerTest.php | 4 ---- .../FactoryOnlyDependencyInjectionContainerTest.php | 12 ++++-------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9939033..6326688 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: tests: strategy: matrix: - php-versions: ['7.4', '8.0'] + php-versions: ['8.0', '8.1', '8.2'] runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index 62e6519..d47afd2 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,15 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "doctrine/annotations": "^1.0.0", - "laminas/laminas-code": "^4.0.0", + "php": ">=8.0", + "doctrine/annotations": "^2.0.0", + "laminas/laminas-code": "^4.7.0", "psr/log": "^1.0.0" }, "require-dev": { - "ocramius/proxy-manager": "^2.1.0", + "friendsofphp/proxy-manager-lts": "^1.0", "phpunit/phpunit": "^9.0.0", - "roave/better-reflection": "^4.0.0 || ^5.0.0" + "roave/better-reflection": "^5.0.0" }, "suggest": { "ocramius/proxy-manager": "For lazy loading" diff --git a/test/rg/injektor/DependencyInjectionContainerTest.php b/test/rg/injektor/DependencyInjectionContainerTest.php index 2308054..1975456 100644 --- a/test/rg/injektor/DependencyInjectionContainerTest.php +++ b/test/rg/injektor/DependencyInjectionContainerTest.php @@ -10,7 +10,6 @@ namespace rg\injektor; use PHPUnit\Framework\TestCase; -use const PHP_VERSION_ID; include_once 'test_classes.php'; @@ -844,9 +843,6 @@ public function test_getInstanceOfClass_givenClassWithTypedProperties_injectsCor } public function test_getInstanceOfClass_givenClassWithUnionTypedProperties_injectsCorrectClassesIntoProperties() { - if (PHP_VERSION_ID < 80000) { - $this->markTestSkipped('Needs PHP 8.0 or higher'); - } include_once 'test_classes_php80.php'; $config = new Configuration(null, __DIR__ . '/_factories'); diff --git a/test/rg/injektor/FactoryOnlyDependencyInjectionContainerTest.php b/test/rg/injektor/FactoryOnlyDependencyInjectionContainerTest.php index 130843f..fc43fb2 100644 --- a/test/rg/injektor/FactoryOnlyDependencyInjectionContainerTest.php +++ b/test/rg/injektor/FactoryOnlyDependencyInjectionContainerTest.php @@ -12,6 +12,7 @@ use rg\injektor\generators\WritingFactoryGenerator; use Roave\BetterReflection\BetterReflection; use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator; +use Roave\BetterReflection\Reflector\DefaultReflector; use function class_exists; require_once 'DependencyInjectionContainerTest.php'; @@ -51,14 +52,9 @@ private function processClassesOfFile(string $fileName, WritingFactoryGenerator require_once $fileName; $astLocator = (new BetterReflection())->astLocator(); - // bc break between v4 and v5. Can be switched to DefaultReflector fully when min version is PHP 8.0 - if (class_exists(\Roave\BetterReflection\Reflector\ClassReflector::class)) { - $reflector = new \Roave\BetterReflection\Reflector\ClassReflector(new SingleFileSourceLocator($fileName, $astLocator)); - $classes = $reflector->getAllClasses(); - } else { - $reflector = new \Roave\BetterReflection\Reflector\DefaultReflector(new SingleFileSourceLocator($fileName, $astLocator)); - $classes = $reflector->reflectAllClasses(); - } + $reflector = new DefaultReflector(new SingleFileSourceLocator($fileName, $astLocator)); + $classes = $reflector->reflectAllClasses(); + foreach ($classes as $class) { $generator->processFileForClass($class->getName()); }