Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/atlas-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ jobs:
symfony:
- "stable"
proxy:
- "lazy-ghost"
include:
# Test with ProxyManager
- php-version: "8.1"
symfony: "6.4"
proxy: "proxy-manager"
os: "ubuntu-latest"

- "native"
steps:
- name: "Checkout"
uses: "actions/checkout@v5"
Expand Down
38 changes: 7 additions & 31 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
mongodb-version:
- "8.0"
Expand All @@ -35,64 +32,43 @@ jobs:
- "highest"
symfony-version:
- "stable"
proxy:
- "lazy-ghost"
include:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the include section?

Copy link
Member Author

@GromNaN GromNaN Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for testing specific Symfony versions and server configurations.
We will add PHP 8.5 later. And we check the low deps job.

# Test against lowest dependencies
- dependencies: "lowest"
php-version: "8.1"
php-version: "8.4"
mongodb-version: "6.0"
driver-version: "2.1.0"
topology: "server"
symfony-version: "stable"
proxy: "lazy-ghost"
# Test with Symfony 6.4
- topology: "server"
php-version: "8.1"
php-version: "8.4"
mongodb-version: "6.0"
driver-version: "stable"
dependencies: "highest"
symfony-version: "6.4"
proxy: "lazy-ghost"
# Test with a 6.0 replica set
- topology: "replica_set"
php-version: "8.2"
php-version: "8.4"
mongodb-version: "6.0"
driver-version: "stable"
dependencies: "highest"
symfony-version: "stable"
proxy: "lazy-ghost"
# Test with a 8.0 replica set
- topology: "replica_set"
php-version: "8.2"
php-version: "8.4"
mongodb-version: "8.0"
driver-version: "stable"
dependencies: "highest"
symfony-version: "stable"
proxy: "lazy-ghost"
# Test with ProxyManager
- php-version: "8.2"
mongodb-version: "6.0"
driver-version: "stable"
dependencies: "highest"
symfony-version: "stable"
proxy: "proxy-manager"
# Test with Native Lazy Objects
- php-version: "8.4"
mongodb-version: "8.0"
driver-version: "stable"
dependencies: "highest"
symfony-version: "stable"
proxy: "native"
# Test with a sharded cluster
# Currently disabled due to a bug where MongoDB reports "sharding status unknown"
# - topology: "sharded_cluster"
# php-version: "8.2"
# php-version: "8.4"
# mongodb-version: "6.0"
# driver-version: "stable"
# dependencies: "highest"
# symfony-version: "stable"
# proxy: "lazy-ghost"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -161,6 +137,6 @@ jobs:
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' || '' }}"
env:
DOCTRINE_MONGODB_SERVER: ${{ steps.setup-mongodb.outputs.cluster-uri }}
USE_LAZY_GHOST_OBJECT: ${{ matrix.proxy == 'lazy-ghost' && '1' || '0' }}
USE_NATIVE_LAZY_OBJECT: ${{ matrix.proxy == 'native' && '1' || '0' }}
USE_LAZY_GHOST_OBJECT: 0
USE_NATIVE_LAZY_OBJECT: 1
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}
2 changes: 1 addition & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.4"

services:
mongodb:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"docs": "composer update -d docs && ./docs/vendor/bin/build-docs.sh @additional_args"
},
"require": {
"php": "^8.1",
"ext-mongodb": "^2.0",
"php": "^8.4",
"ext-mongodb": "^2.1",
"composer-runtime-api": "^2.0",
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/collections": "^1.5 || ^2.0",
Expand Down
8 changes: 1 addition & 7 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
use function trigger_deprecation;
use function trim;

use const PHP_VERSION_ID;

/**
* Configuration class for the DocumentManager. When setting up your DocumentManager
* you can optionally specify an instance of this class as the second argument.
Expand Down Expand Up @@ -713,17 +711,13 @@ public function isLazyGhostObjectEnabled(): bool

public function setUseNativeLazyObject(bool $nativeLazyObject): void
{
if (PHP_VERSION_ID < 80400 && $nativeLazyObject) {
throw new LogicException('Native lazy objects require PHP 8.4 or higher.');
}

$this->nativeLazyObject = $nativeLazyObject;
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
}

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

Expand Down
5 changes: 1 addition & 4 deletions src/Hydrator/HydratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use function uniqid;

use const DIRECTORY_SEPARATOR;
use const PHP_VERSION_ID;

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

if (PHP_VERSION_ID >= 80400) {
$metadata->reflClass->markLazyObjectAsInitialized($document);
}
$metadata->reflClass->markLazyObjectAsInitialized($document);

if ($document instanceof InternalProxy) {
// Skip initialization to not load any object data
Expand Down
8 changes: 3 additions & 5 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
use function strtoupper;
use function trigger_deprecation;

use const PHP_VERSION_ID;

/**
* A <tt>ClassMetadata</tt> instance holds all the object-document mapping metadata
* of a document and it's references.
Expand Down Expand Up @@ -1992,7 +1990,7 @@ public function setFieldValue(object $document, string $field, $value): void
$document->__load();
} elseif ($document instanceof GhostObjectInterface && ! $document->isProxyInitialized()) {
$document->initializeProxy();
} elseif (PHP_VERSION_ID >= 80400) {
} else {
$this->reflClass->initializeLazyObject($document);
}

Expand All @@ -2010,7 +2008,7 @@ public function getFieldValue(object $document, string $field)
$document->__load();
} elseif ($document instanceof GhostObjectInterface && $field !== $this->identifier && ! $document->isProxyInitialized()) {
$document->initializeProxy();
} elseif (PHP_VERSION_ID >= 80400 && $field !== $this->identifier && $this->reflClass->isUninitializedLazyObject($document)) {
} elseif ($field !== $this->identifier && $this->reflClass->isUninitializedLazyObject($document)) {
$this->reflClass->initializeLazyObject($document);
}

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

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

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

Expand Down
6 changes: 0 additions & 6 deletions src/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
use function trigger_deprecation;
use function ucfirst;

use const PHP_VERSION_ID;

/**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
* metadata mapping informations of a class which describes how a class should be mapped
Expand Down Expand Up @@ -119,10 +117,6 @@ protected function getDriver(): MappingDriver

protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService): void
{
if (PHP_VERSION_ID < 80400) {
return;
}

foreach ($class->propertyAccessors as $propertyAccessor) {
$property = $propertyAccessor->getUnderlyingReflector();

Expand Down
6 changes: 1 addition & 5 deletions src/Mapping/PropertyAccessors/PropertyAccessorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use ReflectionProperty;

use const PHP_VERSION_ID;

/** @internal */
class PropertyAccessorFactory
{
Expand All @@ -16,9 +14,7 @@ public static function createPropertyAccessor(string $className, string $propert
{
$reflectionProperty = new ReflectionProperty($className, $propertyName);

$accessor = PHP_VERSION_ID >= 80400
? RawValuePropertyAccessor::fromReflectionProperty($reflectionProperty)
: ObjectCastPropertyAccessor::fromReflectionProperty($reflectionProperty);
$accessor = RawValuePropertyAccessor::fromReflectionProperty($reflectionProperty);

if ($reflectionProperty->hasType() && ! $reflectionProperty->getType()->allowsNull()) {
$accessor = new TypedNoDefaultPropertyAccessor($accessor, $reflectionProperty);
Expand Down
6 changes: 0 additions & 6 deletions src/Mapping/PropertyAccessors/RawValuePropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
namespace Doctrine\ODM\MongoDB\Mapping\PropertyAccessors;

use Doctrine\ODM\MongoDB\Proxy\InternalProxy;
use LogicException;
use ProxyManager\Proxy\GhostObjectInterface;
use ReflectionProperty;

use function ltrim;

use const PHP_VERSION_ID;

/**
* This is a PHP 8.4 and up only class and replaces {@see ObjectCastPropertyAccessor}.
*
Expand All @@ -39,9 +36,6 @@ public static function fromReflectionProperty(ReflectionProperty $reflectionProp

private function __construct(private ReflectionProperty $reflectionProperty, private string $key)
{
if (PHP_VERSION_ID < 80400) {
throw new LogicException('This class requires PHP 8.4 or higher.');
}
}

public function setValue(object $object, mixed $value): void
Expand Down
4 changes: 1 addition & 3 deletions src/Proxy/Factory/LazyGhostProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
use function file_exists;
use function file_put_contents;
use function filemtime;
use function get_debug_type;
use function is_dir;
use function is_int;
use function is_scalar;
use function is_writable;
use function ltrim;
use function mkdir;
Expand Down Expand Up @@ -115,7 +113,7 @@ public function __construct(
}

if (is_int($autoGenerate) && ($autoGenerate < 0 || $autoGenerate > 4)) {
throw new InvalidArgumentException(sprintf('Invalid auto generate mode "%s" given.', is_scalar($autoGenerate) ? (string) $autoGenerate : get_debug_type($autoGenerate)));
throw new InvalidArgumentException(sprintf('Invalid auto generate mode "%d" given.', $autoGenerate));
}

$this->uow = $dm->getUnitOfWork();
Expand Down
6 changes: 0 additions & 6 deletions src/Proxy/Factory/NativeLazyObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

use function count;

use const PHP_VERSION_ID;

/** @internal */
class NativeLazyObjectFactory implements ProxyFactory
{
Expand All @@ -30,10 +28,6 @@ class NativeLazyObjectFactory implements ProxyFactory
public function __construct(
DocumentManager $documentManager,
) {
if (PHP_VERSION_ID < 80400) {
throw new LogicException('Native lazy objects require PHP 8.4 or higher.');
}

$this->unitOfWork = $documentManager->getUnitOfWork();
$this->lifecycleEventManager = new LifecycleEventManager($documentManager, $this->unitOfWork, $documentManager->getEventManager());
}
Expand Down
4 changes: 1 addition & 3 deletions src/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
use function sprintf;
use function trigger_deprecation;

use const PHP_VERSION_ID;

/**
* The UnitOfWork is responsible for tracking changes to objects during an
* "object-level" transaction and for writing out changes to the database
Expand Down Expand Up @@ -3065,7 +3063,7 @@ public function initializeObject(object $obj): void
$obj->initializeProxy();
} elseif ($obj instanceof PersistentCollectionInterface) {
$obj->initialize();
} elseif (PHP_VERSION_ID >= 80400) {
} else {
$this->dm->getClassMetadata($obj::class)->reflClass->initializeLazyObject($obj);
}
}
Expand Down