Skip to content

Commit

Permalink
Merge pull request #138 from monro93/patch-1
Browse files Browse the repository at this point in the history
Fix enum_constant function for non-string enum values
  • Loading branch information
fre5h authored Oct 16, 2018
2 parents 276245f + 17ab7f9 commit b175804
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Twig/Extension/EnumConstantTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function getEnumConstant(string $enumConstant, ?string $enumType = null):
if (null !== $enumType) {
$this->throwExceptionIfEnumTypeIsNotRegistered($enumType);

return \constant($this->registeredEnumTypes[$enumType].'::'.$enumConstant);
return (string) \constant($this->registeredEnumTypes[$enumType].'::'.$enumConstant);
}

// If ENUM type wasn't set, e.g. {{ 'CENTER'|enum_constant }}
$this->findOccurrences($enumConstant);

if ($this->onlyOneOccurrenceFound()) {
return \constant(\array_pop($this->occurrences).'::'.$enumConstant);
return (string) \constant(\array_pop($this->occurrences).'::'.$enumConstant);
}

if ($this->moreThanOneOccurrenceFound()) {
Expand Down

0 comments on commit b175804

Please sign in to comment.