Skip to content

Commit

Permalink
[CSM] fix: Handle enum as values (#1042)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Weaver <weaverryan+github@gmail.com>
Co-authored-by: Jesse Rushlow <jr@rushlow.dev>
  • Loading branch information
3 people committed May 17, 2022
1 parent 090f40b commit e09a55b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Util/ClassSourceManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ private function quoteAnnotationValue($value)
throw new \Exception('Invalid value: loop before quoting.');
}

if (\function_exists('enum_exists')) {
// do we have an enum ?
if (\is_object($value) && enum_exists(\get_class($value))) {
$value = $value->value;
}
}

return sprintf('"%s"', $value);
}

Expand Down

0 comments on commit e09a55b

Please sign in to comment.