Skip to content

Commit 23069c8

Browse files
authored
Merge pull request doctrine#437 from xabbuh/php-8.5
fix compatibility with PHP 8.5
2 parents 360e458 + 7e43f4e commit 23069c8

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@7.3.0"
1616
with:
1717
composer-root-version: "3.0"
18-
php-versions: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]'
18+
php-versions: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]'
1919
secrets:
2020
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"

src/Persistence/Mapping/RuntimeReflectionService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use function phpversion;
1818
use function version_compare;
1919

20+
use const PHP_VERSION_ID;
21+
2022
/**
2123
* PHP Runtime Reflection Service.
2224
*/
@@ -90,7 +92,9 @@ public function getAccessibleProperty(string $class, string $property)
9092
$reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property);
9193
}
9294

93-
$reflectionProperty->setAccessible(true);
95+
if (PHP_VERSION_ID < 80100) {
96+
$reflectionProperty->setAccessible(true);
97+
}
9498

9599
return $reflectionProperty;
96100
}

tests/Persistence/Mapping/ClassMetadataFactoryTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use stdClass;
1717
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1818

19+
use const PHP_VERSION_ID;
20+
1921
/** @covers \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory */
2022
class ClassMetadataFactoryTest extends DoctrineTestCase
2123
{
@@ -196,7 +198,9 @@ public function testWillNotCacheFallbackMetadata(): void
196198
private static function getCache(AbstractClassMetadataFactory $classMetadataFactory): ?CacheItemPoolInterface
197199
{
198200
$method = new ReflectionMethod($classMetadataFactory, 'getCache');
199-
$method->setAccessible(true);
201+
if (PHP_VERSION_ID < 80100) {
202+
$method->setAccessible(true);
203+
}
200204

201205
return $method->invoke($classMetadataFactory);
202206
}

tests/Persistence/RuntimeReflectionPropertyTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use LogicException;
1212
use PHPUnit\Framework\TestCase;
1313

14+
use const PHP_VERSION_ID;
15+
1416
class DummyMock
1517
{
1618
public function callGet(): void
@@ -36,7 +38,10 @@ public function testGetSetValue(string $name, string $value): void
3638

3739
self::assertSame($value, $reflProperty->getValue($object));
3840

39-
$reflProperty->setAccessible(true);
41+
if (PHP_VERSION_ID < 80100) {
42+
$reflProperty->setAccessible(true);
43+
}
44+
4045
$reflProperty->setValue($object, 'changedValue');
4146

4247
self::assertSame('changedValue', $reflProperty->getValue($object));

tests_php74/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Doctrine\Persistence\Reflection\TypedNoDefaultReflectionProperty;
88
use PHPUnit\Framework\TestCase;
99

10+
use const PHP_VERSION_ID;
11+
1012
class TypedNoDefaultReflectionPropertyTest extends TestCase
1113
{
1214
public function testGetValue(): void
@@ -29,7 +31,9 @@ public function testGetValue(): void
2931
public function testSetValueNull(): void
3032
{
3133
$reflection = new TypedNoDefaultReflectionProperty(TypedFoo::class, 'id');
32-
$reflection->setAccessible(true);
34+
if (PHP_VERSION_ID < 80100) {
35+
$reflection->setAccessible(true);
36+
}
3337

3438
$object = new TypedFoo();
3539
$object->setId(1);
@@ -45,7 +49,9 @@ public function testSetValueNull(): void
4549
public function testSetValueNullOnNullableProperty(): void
4650
{
4751
$reflection = new TypedNoDefaultReflectionProperty(TypedNullableFoo::class, 'value');
48-
$reflection->setAccessible(true);
52+
if (PHP_VERSION_ID < 80100) {
53+
$reflection->setAccessible(true);
54+
}
4955

5056
$object = new TypedNullableFoo();
5157

0 commit comments

Comments
 (0)