Skip to content

Commit b102f85

Browse files
authored
Require PHP 8.4 (#2895)
* Require PHP 8.4 and ext-mongodb 2.1 * Remove PHP_VERSION_ID checks
1 parent 79f1369 commit b102f85

File tree

13 files changed

+19
-87
lines changed

13 files changed

+19
-87
lines changed

.github/workflows/atlas-ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ jobs:
1818
symfony:
1919
- "stable"
2020
proxy:
21-
- "lazy-ghost"
22-
include:
23-
# Test with ProxyManager
24-
- php-version: "8.1"
25-
symfony: "6.4"
26-
proxy: "proxy-manager"
27-
os: "ubuntu-latest"
28-
21+
- "native"
2922
steps:
3023
- name: "Checkout"
3124
uses: "actions/checkout@v5"

.github/workflows/continuous-integration.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
php-version:
22-
- "8.1"
23-
- "8.2"
24-
- "8.3"
2522
- "8.4"
2623
mongodb-version:
2724
- "8.0"
@@ -35,64 +32,43 @@ jobs:
3532
- "highest"
3633
symfony-version:
3734
- "stable"
38-
proxy:
39-
- "lazy-ghost"
4035
include:
4136
# Test against lowest dependencies
4237
- dependencies: "lowest"
43-
php-version: "8.1"
38+
php-version: "8.4"
4439
mongodb-version: "6.0"
4540
driver-version: "2.1.0"
4641
topology: "server"
4742
symfony-version: "stable"
48-
proxy: "lazy-ghost"
4943
# Test with Symfony 6.4
5044
- topology: "server"
51-
php-version: "8.1"
45+
php-version: "8.4"
5246
mongodb-version: "6.0"
5347
driver-version: "stable"
5448
dependencies: "highest"
5549
symfony-version: "6.4"
56-
proxy: "lazy-ghost"
5750
# Test with a 6.0 replica set
5851
- topology: "replica_set"
59-
php-version: "8.2"
52+
php-version: "8.4"
6053
mongodb-version: "6.0"
6154
driver-version: "stable"
6255
dependencies: "highest"
6356
symfony-version: "stable"
64-
proxy: "lazy-ghost"
6557
# Test with a 8.0 replica set
6658
- topology: "replica_set"
67-
php-version: "8.2"
59+
php-version: "8.4"
6860
mongodb-version: "8.0"
6961
driver-version: "stable"
7062
dependencies: "highest"
7163
symfony-version: "stable"
72-
proxy: "lazy-ghost"
73-
# Test with ProxyManager
74-
- php-version: "8.2"
75-
mongodb-version: "6.0"
76-
driver-version: "stable"
77-
dependencies: "highest"
78-
symfony-version: "stable"
79-
proxy: "proxy-manager"
80-
# Test with Native Lazy Objects
81-
- php-version: "8.4"
82-
mongodb-version: "8.0"
83-
driver-version: "stable"
84-
dependencies: "highest"
85-
symfony-version: "stable"
86-
proxy: "native"
8764
# Test with a sharded cluster
8865
# Currently disabled due to a bug where MongoDB reports "sharding status unknown"
8966
# - topology: "sharded_cluster"
90-
# php-version: "8.2"
67+
# php-version: "8.4"
9168
# mongodb-version: "6.0"
9269
# driver-version: "stable"
9370
# dependencies: "highest"
9471
# symfony-version: "stable"
95-
# proxy: "lazy-ghost"
9672

9773
steps:
9874
- name: "Checkout"
@@ -161,6 +137,6 @@ jobs:
161137
run: "vendor/bin/phpunit --exclude-group=atlas ${{ matrix.dependencies == 'lowest' && '--do-not-fail-on-deprecation --do-not-fail-on-warning --do-not-fail-on-notice' || '' }}"
162138
env:
163139
DOCTRINE_MONGODB_SERVER: ${{ steps.setup-mongodb.outputs.cluster-uri }}
164-
USE_LAZY_GHOST_OBJECT: ${{ matrix.proxy == 'lazy-ghost' && '1' || '0' }}
165-
USE_NATIVE_LAZY_OBJECT: ${{ matrix.proxy == 'native' && '1' || '0' }}
140+
USE_LAZY_GHOST_OBJECT: 0
141+
USE_NATIVE_LAZY_OBJECT: 1
166142
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}

.github/workflows/performance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
php-version:
18-
- "8.1"
18+
- "8.4"
1919

2020
services:
2121
mongodb:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"docs": "composer update -d docs && ./docs/vendor/bin/build-docs.sh @additional_args"
2525
},
2626
"require": {
27-
"php": "^8.1",
28-
"ext-mongodb": "^2.0",
27+
"php": "^8.4",
28+
"ext-mongodb": "^2.1",
2929
"composer-runtime-api": "^2.0",
3030
"doctrine/cache": "^1.11 || ^2.0",
3131
"doctrine/collections": "^1.5 || ^2.0",

src/Configuration.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
use function trigger_deprecation;
4848
use function trim;
4949

50-
use const PHP_VERSION_ID;
51-
5250
/**
5351
* Configuration class for the DocumentManager. When setting up your DocumentManager
5452
* you can optionally specify an instance of this class as the second argument.
@@ -713,17 +711,13 @@ public function isLazyGhostObjectEnabled(): bool
713711

714712
public function setUseNativeLazyObject(bool $nativeLazyObject): void
715713
{
716-
if (PHP_VERSION_ID < 80400 && $nativeLazyObject) {
717-
throw new LogicException('Native lazy objects require PHP 8.4 or higher.');
718-
}
719-
720714
$this->nativeLazyObject = $nativeLazyObject;
721715
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
722716
}
723717

724718
public function isNativeLazyObjectEnabled(): bool
725719
{
726-
if (PHP_VERSION_ID >= 80400 && ! $this->nativeLazyObject) {
720+
if (! $this->nativeLazyObject) {
727721
trigger_deprecation('doctrine/mongodb-odm', '2.14', 'Not using native lazy objects is deprecated and will be impossible in Doctrine MongoDB ODM 3.0.');
728722
}
729723

src/Hydrator/HydratorFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use function uniqid;
3434

3535
use const DIRECTORY_SEPARATOR;
36-
use const PHP_VERSION_ID;
3736

3837
/**
3938
* The HydratorFactory class is responsible for instantiating a correct hydrator
@@ -451,9 +450,7 @@ public function hydrate(object $document, array $data, array $hints = []): array
451450
}
452451
}
453452

454-
if (PHP_VERSION_ID >= 80400) {
455-
$metadata->reflClass->markLazyObjectAsInitialized($document);
456-
}
453+
$metadata->reflClass->markLazyObjectAsInitialized($document);
457454

458455
if ($document instanceof InternalProxy) {
459456
// Skip initialization to not load any object data

src/Mapping/ClassMetadata.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
use function strtoupper;
6464
use function trigger_deprecation;
6565

66-
use const PHP_VERSION_ID;
67-
6866
/**
6967
* A <tt>ClassMetadata</tt> instance holds all the object-document mapping metadata
7068
* of a document and it's references.
@@ -1992,7 +1990,7 @@ public function setFieldValue(object $document, string $field, $value): void
19921990
$document->__load();
19931991
} elseif ($document instanceof GhostObjectInterface && ! $document->isProxyInitialized()) {
19941992
$document->initializeProxy();
1995-
} elseif (PHP_VERSION_ID >= 80400) {
1993+
} else {
19961994
$this->reflClass->initializeLazyObject($document);
19971995
}
19981996

@@ -2010,7 +2008,7 @@ public function getFieldValue(object $document, string $field)
20102008
$document->__load();
20112009
} elseif ($document instanceof GhostObjectInterface && $field !== $this->identifier && ! $document->isProxyInitialized()) {
20122010
$document->initializeProxy();
2013-
} elseif (PHP_VERSION_ID >= 80400 && $field !== $this->identifier && $this->reflClass->isUninitializedLazyObject($document)) {
2011+
} elseif ($field !== $this->identifier && $this->reflClass->isUninitializedLazyObject($document)) {
20142012
$this->reflClass->initializeLazyObject($document);
20152013
}
20162014

@@ -2587,7 +2585,7 @@ public function mapField(array $mapping): array
25872585

25882586
$accessor = PropertyAccessorFactory::createPropertyAccessor($this->name, $mapping['fieldName']);
25892587

2590-
if (PHP_VERSION_ID >= 80400 && $accessor->getUnderlyingReflector()->isVirtual()) {
2588+
if ($accessor->getUnderlyingReflector()->isVirtual()) {
25912589
throw MappingException::mappingVirtualPropertyNotAllowed($this->name, $mapping['fieldName']);
25922590
}
25932591

src/Mapping/ClassMetadataFactory.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
use function trigger_deprecation;
3232
use function ucfirst;
3333

34-
use const PHP_VERSION_ID;
35-
3634
/**
3735
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
3836
* metadata mapping informations of a class which describes how a class should be mapped
@@ -119,10 +117,6 @@ protected function getDriver(): MappingDriver
119117

120118
protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService): void
121119
{
122-
if (PHP_VERSION_ID < 80400) {
123-
return;
124-
}
125-
126120
foreach ($class->propertyAccessors as $propertyAccessor) {
127121
$property = $propertyAccessor->getUnderlyingReflector();
128122

src/Mapping/PropertyAccessors/PropertyAccessorFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use ReflectionProperty;
88

9-
use const PHP_VERSION_ID;
10-
119
/** @internal */
1210
class PropertyAccessorFactory
1311
{
@@ -16,9 +14,7 @@ public static function createPropertyAccessor(string $className, string $propert
1614
{
1715
$reflectionProperty = new ReflectionProperty($className, $propertyName);
1816

19-
$accessor = PHP_VERSION_ID >= 80400
20-
? RawValuePropertyAccessor::fromReflectionProperty($reflectionProperty)
21-
: ObjectCastPropertyAccessor::fromReflectionProperty($reflectionProperty);
17+
$accessor = RawValuePropertyAccessor::fromReflectionProperty($reflectionProperty);
2218

2319
if ($reflectionProperty->hasType() && ! $reflectionProperty->getType()->allowsNull()) {
2420
$accessor = new TypedNoDefaultPropertyAccessor($accessor, $reflectionProperty);

src/Mapping/PropertyAccessors/RawValuePropertyAccessor.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
namespace Doctrine\ODM\MongoDB\Mapping\PropertyAccessors;
66

77
use Doctrine\ODM\MongoDB\Proxy\InternalProxy;
8-
use LogicException;
98
use ProxyManager\Proxy\GhostObjectInterface;
109
use ReflectionProperty;
1110

1211
use function ltrim;
1312

14-
use const PHP_VERSION_ID;
15-
1613
/**
1714
* This is a PHP 8.4 and up only class and replaces {@see ObjectCastPropertyAccessor}.
1815
*
@@ -39,9 +36,6 @@ public static function fromReflectionProperty(ReflectionProperty $reflectionProp
3936

4037
private function __construct(private ReflectionProperty $reflectionProperty, private string $key)
4138
{
42-
if (PHP_VERSION_ID < 80400) {
43-
throw new LogicException('This class requires PHP 8.4 or higher.');
44-
}
4539
}
4640

4741
public function setValue(object $object, mixed $value): void

0 commit comments

Comments
 (0)