You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updating the naming standard to explain the "snake_case" strategy prefix all numbers a with an underscore
=> Certainly the simplest but less satisfying solution because it kinda introduce a new naming strategy witch is not even supported by Symfony/string.
Changing the snake method strategy
=> Seems this is a BC break, this seem impossible
I would say this is not worth any BC break or deprecation for such a minor detail.
As you say both ways are used as "snake case" and for this reason I think any CS checker should also approve both as following the "use snake case" guideline (so no changes needed in the documentation). For the String component, which has to construct a snake case string, it must choose one of them and it's not worth changing existing behavior.
Symfony version(s) affected
all
Description
When looking at Symfony standard about template naming
(https://symfony.com/doc/current/templates.html#template-naming or https://symfony.com/doc/current/best_practices.html#use-snake-case-for-template-names-and-variables)
it's said:
Now, If we look at the
UnicodeString::snake()
in order to knows what a valid snake case is:https://github.com/symfony/string/blob/7.0/Tests/AbstractAsciiTestCase.php#L1063-L1077
it seems that
foo_2
is not a valid snake case and should befoo2
.But, when looking at symfony code
https://github.com/symfony/symfony/tree/7.1/src/Symfony/Bridge/Twig/Resources/views/Form
all the templates with number are in the format
foo_2
instead offoo2
and therefore are not respecting the own Symfony templates naming standard.
How to reproduce
Irrelevant
Possible Solution
I see four solutions:
Updating the naming standard to explain the "snake_case" strategy prefix all numbers a with an underscore
=> Certainly the simplest but less satisfying solution because it kinda introduce a new naming strategy witch is not even supported by Symfony/string.
Changing the
snake
method strategy=> Seems this is a BC break, this seem impossible
Allow passing a new parameters to snake method/introduce a new method related to this
snake_case_numeric
strategy=> Since [String] Introduce
underscore()
method #34781 was closed, not sure it will be preferred now (@simPod & @nicolas-grekas)Renaming the templates with numbers in a BC way.
=> Might be the best solution, it just need a little work to avoid BC break.
Additional Context
No response
The text was updated successfully, but these errors were encountered: