Skip to content

Commit

Permalink
Merge branch '3.1.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.1.x:
  Use class from persistence package  (#11330)
  Refator array_map into simple loop for performance. (#11332)
  • Loading branch information
derrabus committed Mar 3, 2024
2 parents f8b5ef0 + 507c73c commit a5cb7c2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Using array access on instances of the following classes is no longer possible:

# Upgrade to 3.1

## Deprecate `Doctrine\ORM\Mapping\ReflectionEnumProperty`

This class is deprecated and will be removed in 4.0.
Instead, use `Doctrine\Persistence\Reflection\EnumReflectionProperty` from
`doctrine/persistence`.

## Deprecate passing null to `ClassMetadata::fullyQualifiedClassName()`

Passing `null` to `Doctrine\ORM\ClassMetadata::fullyQualifiedClassName()` is
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"doctrine/inflector": "^1.4 || ^2.0",
"doctrine/instantiator": "^1.3 || ^2",
"doctrine/lexer": "^3",
"doctrine/persistence": "^3.1.1",
"doctrine/persistence": "^3.3.1",
"psr/cache": "^1 || ^2 || ^3",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/var-exporter": "~6.2.13 || ^6.3.2 || ^7.0"
Expand Down
5 changes: 3 additions & 2 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\ORM\Id\AbstractIdGenerator;
use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata;
use Doctrine\Persistence\Mapping\ReflectionService;
use Doctrine\Persistence\Reflection\EnumReflectionProperty;
use InvalidArgumentException;
use LogicException;
use ReflectionClass;
Expand Down Expand Up @@ -821,7 +822,7 @@ public function wakeupReflection(ReflectionService $reflService): void
assert($childProperty !== null);

if (isset($mapping->enumType)) {
$childProperty = new ReflectionEnumProperty(
$childProperty = new EnumReflectionProperty(
$childProperty,
$mapping->enumType,
);
Expand All @@ -840,7 +841,7 @@ public function wakeupReflection(ReflectionService $reflService): void
: $this->getAccessibleProperty($reflService, $this->name, $field);

if (isset($mapping->enumType) && $this->reflFields[$field] !== null) {
$this->reflFields[$field] = new ReflectionEnumProperty(
$this->reflFields[$field] = new EnumReflectionProperty(
$this->reflFields[$field],
$mapping->enumType,
);
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/ReflectionEmbeddedProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
private readonly ReflectionProperty $childProperty,
private readonly string $embeddedClass,
) {
parent::__construct($childProperty->class, $childProperty->name);
parent::__construct($childProperty->getDeclaringClass()->name, $childProperty->getName());
}

public function getValue(object|null $object = null): mixed
Expand Down
1 change: 1 addition & 0 deletions src/Mapping/ReflectionEnumProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use function array_map;
use function is_array;

/** @deprecated use Doctrine\Persistence\Reflection\EnumReflectionProperty instead */
final class ReflectionEnumProperty extends ReflectionProperty
{
/** @param class-string<BackedEnum> $enumType */
Expand Down
17 changes: 7 additions & 10 deletions src/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1557,18 +1557,15 @@ public function addToIdentityMap(object $entity): bool
*/
final public static function getIdHashByIdentifier(array $identifier): string
{
foreach ($identifier as $k => $value) {
if ($value instanceof BackedEnum) {
$identifier[$k] = $value->value;
}
}

return implode(
' ',
array_map(
static function ($value) {
if ($value instanceof BackedEnum) {
return $value->value;
}

return $value;
},
$identifier,
),
$identifier,
);
}

Expand Down

0 comments on commit a5cb7c2

Please sign in to comment.