Skip to content

Conversation

antten
Copy link
Contributor

@antten antten commented Jul 20, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #57782
License MIT

The current implementation of the snake method is based on the camel method, which does not work correctly with uppercase strings. The camel method doesn't handle parts of the string in uppercase, which I believe is the correct behavior.

For example:

'Symfony is GREAT' => 'symfonyIsGREAT'
'SYMFONY IS GREAT' => 'SYMFONYISGREAT'

The first example seems correct to me, but this behavior may cause unexpected results in the second example.

To fix the issue, I chose not to base the snake method on the camel method.

My proposal may also fix issues #57612 and #57464, and I hope it does not break anything.

antten added 2 commits July 20, 2024 18:26
Better management of uppercase string and removal of special end-of-line characters.
Better management of uppercase string and removal of special end-of-line characters.
@antten antten force-pushed the fix/string-snake-57782 branch from c10a2ed to 88bcc3a Compare July 20, 2024 17:48
@nicolas-grekas
Copy link
Member

We've already tried to fix those methods and that ended up creating regressions.
If we want another snake/camel-casing logic, these should live under a different method name.
I'm 👎 for this as a bugfix, but open to discussing this as a new feature.

@nicolas-grekas
Copy link
Member

Closing as explained, thanks for submitting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants