Skip to content

Commit

Permalink
Don't mark enum keys as deprecated when their value changed
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Apr 10, 2023
1 parent 8bfce15 commit bd571f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dev/SpecUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ public static function update(Event $event): void
$enumCases[] = new EnumCase($name, $value);
}

$existingValues = array_map(static function (\BackedEnum $backedEnum) {
return $backedEnum->value;
}, $specFQN::cases());
foreach (array_diff($existingValues, $nameValuePairs) as $deprecatedValue) {
$existingValues = [];
foreach ($specFQN::cases() as $existingValue) {
$existingValues[$existingValue->name] = $existingValue->value;
}
foreach (array_diff_key($existingValues, $nameValuePairs) as $deprecatedKey => $deprecatedValue) {
if (array_key_exists($deprecatedKey, $existingValues)) {
continue;
}

$enumCases[] = new EnumCase($specFQN::from($deprecatedValue)->name, $deprecatedValue, true);
}

Expand Down

0 comments on commit bd571f2

Please sign in to comment.