Skip to content

[String] CamelCase/SnakeCase on uppercase word #47423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

mpiot
Copy link
Contributor

@mpiot mpiot commented Aug 29, 2022

Q A
Branch? 6.1
Bug fix? yes
New feature? no
Deprecations? ~
Tickets Fix #47421
License MIT
Doc PR

The behavior of ->snake() method from String component has changed in 6.1.4, now, using u('SYMFONY')->snake() return s_ymfony instead of symfony (#47185).

After, some investigations, it seams the ->camel() behavior is not exactly the expected one: u('SYMFONY')->camel() return sYMFONY instead of SYMFONY.

This PR give theses behaviors:

  • CamelCase:

    • '' => ''
    • x_y => xY
    • xu_yo => xuYo
    • symfony_is_great => symfonyIsGreat
    • symfony_5_is_great => symfony5IsGreat
    • Symfony is great => symfonyIsGreat
    • Symfony is a great framework => symfonyIsAGreatFramework
    • *Symfony* is GREAT!! => symfonyIsGREAT
    • SYMFONY => SYMFONY
  • SnakeCase:

    • '' => ''
    • x_y => x_y
    • X_Y => x_y
    • xu_yo => xu_yo
    • symfonyIsGreat => symfony_is_great
    • symfony5IsGreat => symfony5_is_great
    • symfony5isGreat => symfony5is_great
    • Symfony is great => symfony_is_great
    • symfonyIsAGreatFramework => symfony_is_a_great_framework
    • symfonyIsGREAT => symfony_is_great
    • symfonyIsREALLYGreat => symfony_is_really_great
    • SYMFONY => symfony

@carsonbot carsonbot added this to the 6.2 milestone Aug 29, 2022
@mpiot mpiot force-pushed the string-camel-snake branch 3 times, most recently from 5fac902 to f9129e6 Compare August 29, 2022 10:52
@xabbuh
Copy link
Member

xabbuh commented Aug 31, 2022

This affects Symfony 5.4 too, doesn't it?

@mpiot
Copy link
Contributor Author

mpiot commented Aug 31, 2022

@xabbuh oh yes #47185 has been merged in 5.4 branch.

@xabbuh xabbuh modified the milestones: 6.2, 5.4 Aug 31, 2022
@fabpot
Copy link
Member

fabpot commented Sep 1, 2022

Thank you @mpiot.

@fabpot fabpot merged commit c61dfca into symfony:5.4 Sep 1, 2022
@mpiot mpiot deleted the string-camel-snake branch September 1, 2022 04:47
@fabpot fabpot mentioned this pull request Sep 30, 2022
This was referenced Sep 30, 2022
fabpot added a commit that referenced this pull request Jul 1, 2024
…>snake() methods" (nicolas-grekas)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[String] Revert "Fixed u()->snake(), b()->snake() and s()->snake() methods"

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

This PR reverts #57497 for BC reasons, but keeps the test cases we added in the process. Those test cases allowed to spot a real issue where the ascii and unicode implementations didn't agree on the resulting camel case for `SYMFONY IS GREAT`. Both implementations now result in `SYMFONYISGREAT` (likely introduced in #47423).

Commits
-------

6397c38 [String] Revert "Fixed u()->snake(), b()->snake() and s()->snake() methods"
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.

[String] Snakecase breaked
5 participants