Skip to content

Commit 4692659

Browse files
committed
Remove PHP_VERSION_ID checks
1 parent 6e8cb43 commit 4692659

File tree

8 files changed

+7
-42
lines changed

8 files changed

+7
-42
lines changed

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

src/Proxy/Factory/NativeLazyObjectFactory.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
use function count;
1818

19-
use const PHP_VERSION_ID;
20-
2119
/** @internal */
2220
class NativeLazyObjectFactory implements ProxyFactory
2321
{
@@ -30,10 +28,6 @@ class NativeLazyObjectFactory implements ProxyFactory
3028
public function __construct(
3129
DocumentManager $documentManager,
3230
) {
33-
if (PHP_VERSION_ID < 80400) {
34-
throw new LogicException('Native lazy objects require PHP 8.4 or higher.');
35-
}
36-
3731
$this->unitOfWork = $documentManager->getUnitOfWork();
3832
$this->lifecycleEventManager = new LifecycleEventManager($documentManager, $this->unitOfWork, $documentManager->getEventManager());
3933
}

src/UnitOfWork.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
use function sprintf;
5353
use function trigger_deprecation;
5454

55-
use const PHP_VERSION_ID;
56-
5755
/**
5856
* The UnitOfWork is responsible for tracking changes to objects during an
5957
* "object-level" transaction and for writing out changes to the database
@@ -3065,7 +3063,7 @@ public function initializeObject(object $obj): void
30653063
$obj->initializeProxy();
30663064
} elseif ($obj instanceof PersistentCollectionInterface) {
30673065
$obj->initialize();
3068-
} elseif (PHP_VERSION_ID >= 80400) {
3066+
} else {
30693067
$this->dm->getClassMetadata($obj::class)->reflClass->initializeLazyObject($obj);
30703068
}
30713069
}

0 commit comments

Comments
 (0)