Skip to content

Commit

Permalink
support PHP 8.2 (#25)
Browse files Browse the repository at this point in the history
* add support to PHP 8.2
* replace ocramius/proxy-manager with friendsofphp/proxy-manager-lts
* drop PHP 7.4 support
* remove better-reflection v4
  • Loading branch information
mustafah15 authored Aug 1, 2023
1 parent d1cece3 commit 7de1d81
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions test/rg/injektor/DependencyInjectionContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace rg\injektor;

use PHPUnit\Framework\TestCase;
use const PHP_VERSION_ID;

include_once 'test_classes.php';

Expand Down Expand Up @@ -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');
Expand Down
12 changes: 4 additions & 8 deletions test/rg/injektor/FactoryOnlyDependencyInjectionContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 7de1d81

Please sign in to comment.