On 21.11.2024 at 10:36, Tim Düsterhus wrote:

> This proposal would not affect that. You would just need to add a colon
> after the `case` statement, not a semicolon. In fact that would more
> closely match the corresponding `switch`, which would also need to have
> a colon:
>
>     <?php $foo = "bar"; ?>
>
>     <?php
>     switch ($foo):
>     case "bar":
>     ?>
>     BAR
>     <?php break; case "baz": ?>
>     BAZ
>     <?php endswitch; ?>
>
> Though using `switch` in such templates is somewhat finicky anyway,
> because it will need to be merged with the first `case`, because otherwise:
>
>> Parse error: syntax error, unexpected T_INLINE_HTML "", expecting
>> "endswitch" or "case" or "default"

There is no parse error if you use PHP snippets in such templates like
you use C preprocessor directives (i.e. always starting at the first
column); e.g. https://3v4l.org/cK0Ll.  Or see https://3v4l.org/7mKS8,
which is how I would write it, if I was using switch statements in such
templates.

Note that I'm not advocating to keep the behavior, but I also don't see
how it would be harmful.  Without an enforced CS, there can be more
confusing code anyway.

Christoph

Reply via email to