mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-11 01:46:37 +00:00
ff4d01f940
The implementation contains an optimized implementation of the function for the common case of using a string literal as the argument. It will validate the enum existence during compilation and compile the code to use `MyEnum::cases()` directly.
14 lines
378 B
Plaintext
14 lines
378 B
Plaintext
--TEST--
|
|
"enum_cases" function with invalid dynamic enum class
|
|
--CONDITION--
|
|
\PHP_VERSION_ID >= 80100
|
|
--TEMPLATE--
|
|
{% set from_variable = 'Twig\\Tests\\NonExistentEnum' %}
|
|
{% for c in enum_cases(from_variable) %}
|
|
{{~ c.name }}
|
|
{% endfor %}
|
|
--DATA--
|
|
return []
|
|
--EXCEPTION--
|
|
Twig\Error\RuntimeError: Enum "Twig\Tests\NonExistentEnum" does not exist in "index.twig" at line 3.
|