Skip to content

Commit

Permalink
Make ReflectionEnumProperty::getValue return the enum
Browse files Browse the repository at this point in the history
UoW compares orig and actual value. Orig value is the enum. But without this change, actual value is the inner value of the BackedEnum. Therefore, Entities with enum field are always considered a change.
  • Loading branch information
simPod committed Oct 13, 2022
1 parent 13d1c7b commit c2430cf
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(ReflectionProperty $originalReflectionProperty, stri
*
* @param object|null $object
*
* @return int|string|int[]|string[]|null
* @return BackedEnum|null
*/
#[ReturnTypeWillChange]
public function getValue($object = null)
Expand All @@ -53,13 +53,7 @@ public function getValue($object = null)
return null;
}

if (is_array($enum)) {
return array_map(static function (BackedEnum $item): mixed {
return $item->value;
}, $enum);
}

return $enum->value;
return $enum;
}

/**
Expand Down

0 comments on commit c2430cf

Please sign in to comment.