Skip to content

Commit

Permalink
Add PHP 8.4 support, drop PHP < 8.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Aug 8, 2024
1 parent 6312d72 commit 155b536
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "8.1.99"
"php": "8.2.99"
}
},
"extra": {
Expand All @@ -31,7 +31,7 @@
}
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"laminas/laminas-stdlib": "^3.3",
"webmozart/assert": "^1.10"
},
Expand Down
6 changes: 5 additions & 1 deletion src/Filter/NumberOfParameterFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use ReflectionException;
use ReflectionMethod;

use function method_exists;
use function sprintf;

final class NumberOfParameterFilter implements FilterInterface
Expand All @@ -31,7 +32,10 @@ public function filter(string $property, ?object $instance = null): bool
try {
$reflectionMethod = $instance !== null
? new ReflectionMethod($instance, $property)
: new ReflectionMethod($property);
: (method_exists(ReflectionMethod::class, 'createFromMethodName')
? ReflectionMethod::createFromMethodName($property)
: new ReflectionMethod($property)
);
} catch (ReflectionException) {
throw new InvalidArgumentException(sprintf(
'Method %s does not exist',
Expand Down
6 changes: 5 additions & 1 deletion src/Filter/OptionalParametersFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use function array_filter;
use function array_key_exists;
use function method_exists;
use function sprintf;

/**
Expand Down Expand Up @@ -46,7 +47,10 @@ public function filter(string $property, ?object $instance = null): bool
try {
$reflectionMethod = $instance !== null
? new ReflectionMethod($instance, $property)
: new ReflectionMethod($property);
: (method_exists(ReflectionMethod::class, 'createFromMethodName')
? ReflectionMethod::createFromMethodName($property)
: new ReflectionMethod($property)
);
} catch (ReflectionException) {
throw new InvalidArgumentException(sprintf('Method %s does not exist', $property));
}
Expand Down
11 changes: 0 additions & 11 deletions test/Strategy/BackedEnumStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

use const PHP_VERSION_ID;

#[CoversClass(BackedEnumStrategy::class)]
class BackedEnumStrategyTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();

if (PHP_VERSION_ID < 80100) {
self::markTestSkipped("PHP 8.1+ required");
}
}

public function testExtractInvalidValueThrowsException(): void
{
$strategy = new BackedEnumStrategy(TestBackedEnum::class);
Expand Down

0 comments on commit 155b536

Please sign in to comment.