Skip to content

Commit 224ff97

Browse files
authored
Merge pull request doctrine#12050 from greg0ire/no-legacy-refl-fields
Remove ClassMetadata::$reflFields
2 parents a2ea72c + 68c7152 commit 224ff97

File tree

4 files changed

+8
-223
lines changed

4 files changed

+8
-223
lines changed

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Upgrade to 4.0
22

3+
## BC BREAK: `Doctrine\ORM\Mapping\LegacyReflectionFields` is removed
4+
5+
The `Doctrine\ORM\Mapping\LegacyReflectionFields` class has been removed.
6+
Also, `Doctrine\ORM\Mapping\ClassMetadata::$reflFields` has been removed, as
7+
well as methods depending on it.
8+
39
## BC BREAK: Userland lazy objects are no longer supported
410

511
Userland lazy objects are no longer supported.

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,18 +1434,6 @@ parameters:
14341434
count: 1
14351435
path: src/Mapping/JoinTableMapping.php
14361436

1437-
-
1438-
message: '#^Method Doctrine\\ORM\\Mapping\\LegacyReflectionFields\:\:__construct\(\) has parameter \$classMetadata with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
1439-
identifier: missingType.generics
1440-
count: 1
1441-
path: src/Mapping/LegacyReflectionFields.php
1442-
1443-
-
1444-
message: '#^Parameter \#1 \$class of method Doctrine\\Persistence\\Mapping\\ReflectionService\:\:getAccessibleProperty\(\) expects class\-string, string given\.$#'
1445-
identifier: argument.type
1446-
count: 1
1447-
path: src/Mapping/LegacyReflectionFields.php
1448-
14491437
-
14501438
message: '#^Method Doctrine\\ORM\\Mapping\\MappedSuperclass\:\:__construct\(\) has parameter \$repositoryClass with generic class Doctrine\\ORM\\EntityRepository but does not specify its types\: T$#'
14511439
identifier: missingType.generics

src/Mapping/ClassMetadata.php

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use LogicException;
2525
use ReflectionClass;
2626
use ReflectionNamedType;
27-
use ReflectionProperty;
2827
use Stringable;
2928

3029
use function array_column;
@@ -538,13 +537,6 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable
538537
*/
539538
protected NamingStrategy $namingStrategy;
540539

541-
/**
542-
* The ReflectionProperty instances of the mapped class.
543-
*
544-
* @var LegacyReflectionFields|array<string, ReflectionProperty>
545-
*/
546-
public LegacyReflectionFields|array $reflFields = [];
547-
548540
/** @var array<string, PropertyAccessors\PropertyAccessor> */
549541
public array $propertyAccessors = [];
550542

@@ -567,17 +559,6 @@ public function __construct(public string $name, NamingStrategy|null $namingStra
567559
$this->typedFieldMapper = $typedFieldMapper ?? new DefaultTypedFieldMapper();
568560
}
569561

570-
/**
571-
* Gets the ReflectionProperties of the mapped class.
572-
*
573-
* @return LegacyReflectionFields|ReflectionProperty[] An array of ReflectionProperty instances.
574-
* @phpstan-return LegacyReflectionFields|array<string, ReflectionProperty>
575-
*/
576-
public function getReflectionProperties(): array|LegacyReflectionFields
577-
{
578-
return $this->reflFields;
579-
}
580-
581562
/**
582563
* Gets the ReflectionProperties of the mapped class.
583564
*
@@ -588,29 +569,11 @@ public function getPropertyAccessors(): array
588569
return $this->propertyAccessors;
589570
}
590571

591-
/**
592-
* Gets a ReflectionProperty for a specific field of the mapped class.
593-
*/
594-
public function getReflectionProperty(string $name): ReflectionProperty|null
595-
{
596-
return $this->reflFields[$name];
597-
}
598-
599572
public function getPropertyAccessor(string $name): PropertyAccessor|null
600573
{
601574
return $this->propertyAccessors[$name] ?? null;
602575
}
603576

604-
/** @throws BadMethodCallException If the class has a composite identifier. */
605-
public function getSingleIdReflectionProperty(): ReflectionProperty|null
606-
{
607-
if ($this->isIdentifierComposite) {
608-
throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.');
609-
}
610-
611-
return $this->reflFields[$this->identifier[0]];
612-
}
613-
614577
/** @throws BadMethodCallException If the class has a composite identifier. */
615578
public function getSingleIdPropertyAccessor(): PropertyAccessor|null
616579
{
@@ -704,9 +667,8 @@ public function __toString(): string
704667
* That means any metadata properties that are not set or empty or simply have
705668
* their default value are NOT serialized.
706669
*
707-
* Parts that are also NOT serialized because they can not be properly unserialized:
708-
* - reflClass (ReflectionClass)
709-
* - reflFields (ReflectionProperty array)
670+
* Parts that are also NOT serialized because they can not be properly
671+
* unserialized, e.g. reflClass (ReflectionClass)
710672
*
711673
* @return string[] The names of all the fields that should be serialized.
712674
*/
@@ -816,7 +778,6 @@ public function wakeupReflection(ReflectionService $reflService): void
816778
{
817779
// Restore ReflectionClass and properties
818780
$this->reflClass = $reflService->getClass($this->name);
819-
$this->reflFields = new LegacyReflectionFields($this, $reflService);
820781
$this->instantiator = $this->instantiator ?: new Instantiator();
821782

822783
$parentAccessors = [];

src/Mapping/LegacyReflectionFields.php

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)