Skip to content

Commit 0186ecb

Browse files
authored
Allow passing null in twig_is_selected_choice
In the cached file of my application I can see the following code fragment that have been generated by Symfony: ```php if (( !((array_key_exists("render_preferred_choices", $context)) ? (_twig_default_filter((isset($context["render_preferred_choices"]) || array_key_exists("render_preferred_choices", $context) ? $context["render_preferred_choices"] : (function () { throw new RuntimeError('Variable "render_preferred_choices" does not exist.', 88, $this->source); })()), false)) : (false)) && Symfony\Bridge\Twig\Extension\twig_is_selected_choice($context["choice"], (isset($context["value"]) || array_key_exists("value", $context) ? $context["value"] : (function () { throw new RuntimeError('Variable "value" does not exist.', 88, $this->source); })())))) { echo " selected=\"selected\""; } ``` The 2nd Arg passed when calling ``twig_is_selected_choice`` if the result of ``(isset($context["value"]) || array_key_exists("value", $context) ? $context["value"]``. In that condition, if ``$context['value'] = null, we pass the null Currently I got the following error: ``` Symfony\Bridge\Twig\Extension\twig_is_selected_choice(): Argument #2 ($selectedValue) must be of type array|string, null given, called in X:\workspace-novento\novento-vip-lounge\var\cache\admin_dev\twig\01\01615438ee40292438687b29025d08a9.php on line 534 ```
1 parent 8cc88b8 commit 0186ecb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function createFieldTranslation(?string $value, array $parameters, strin
188188
*
189189
* @see ChoiceView::isSelected()
190190
*/
191-
function twig_is_selected_choice(ChoiceView $choice, string|array $selectedValue): bool
191+
function twig_is_selected_choice(ChoiceView $choice, string|array|null $selectedValue): bool
192192
{
193193
if (\is_array($selectedValue)) {
194194
return \in_array($choice->value, $selectedValue, true);

0 commit comments

Comments
 (0)