Skip to content

[String] Fixed u()->snake(), b()->snake() and s()->snake() methods #57497

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
Jun 28, 2024

Conversation

arczinosek
Copy link
Contributor

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

[String] ByteString::snake and AbstractUnitcodeString::snake methods doesn't convert all uppercase words in the right way.

For example, string "GREAT SYMFONY" is converted to "greatsymfony" instead of "great_symfony".

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@arczinosek arczinosek changed the base branch from 7.2 to 5.4 June 22, 2024 20:20
@arczinosek
Copy link
Contributor Author

arczinosek commented Jun 22, 2024

  1. fabbot suggests me a fix with coding standards, but it's for a different part of the code. Should I apply?
  2. Because of my mistake milestone was probably incorrectly set to 7.2 instead of 5.4, sorry

@xabbuh xabbuh modified the milestones: 7.2, 5.4 Jun 22, 2024
@alexandre-daubois
Copy link
Member

You can ignore fabbot suggestion that are unrelated to your code.

I've got a remark about this change. This is a behavior update, which seems indeed like a bug fix. However, many people could rely on the current behavior and this change could definitely bring a lot of unexpected breakages wherever this is used. This would mean a lot of BC breaks are to be expected which is not permitted by patch and minor versions bugfixes are targeting. 🤔 Because of this, I'm not sure this can be accepted as-is. Curious to have the opinion of someone else.

@symfony symfony deleted a comment from carsonbot Jun 23, 2024
@nicolas-grekas
Copy link
Member

Can you amend+push again to trigger tests? Strange they didn't run.
On my side this is a legit bugfix.

The ByteString::snake and AbstractUnitcodeString::snake methods had a bug that caused incorrect string conversion results for all uppercase words separated by space or "_" character.
Ex. "GREAT SYMFONY" was converted to "greatsymfony" instead of "great_symfony"
@arczinosek
Copy link
Contributor Author

Can you amend+push again to trigger tests? Strange they didn't run. On my side this is a legit bugfix.

Done

@nicolas-grekas
Copy link
Member

Thank you @arczinosek.

@nicolas-grekas nicolas-grekas merged commit 6517957 into symfony:5.4 Jun 28, 2024
10 of 12 checks passed
This was referenced Jun 28, 2024
@VincentLanglet
Copy link
Contributor

VincentLanglet commented Jun 28, 2024

Hi, I think this introduce a bug/important change in the way snake case is generated.

Prior to this PR, symfony is great was snaked to symfony_is_great.
Now it's symfony_____is_____great.

Is it wanted @arczinosek @nicolas-grekas ?

This was referenced Jun 28, 2024
nicolas-grekas added a commit that referenced this pull request Jun 29, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[String] Normalize underscores in snake()

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #57497 (comment)
| License       | MIT

Commits
-------

0e6cd07 normalize underscores in snake()
@nicolas-grekas
Copy link
Member

@VincentLanglet see #57594

@derrabus
Copy link
Member

derrabus commented Jul 1, 2024

Another regression has been reported: #57612

@xabbuh
Copy link
Member

xabbuh commented Jul 1, 2024

see #57615

nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Jul 1, 2024
…nd s()->snake() methods (arczinosek)"

This reverts commit 6517957, reversing
changes made to 572ce41.
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"
fabpot added a commit that referenced this pull request Jul 6, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[String] test: kebab-case to snake_case

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

In Symfony 7.1.1, `kebab-case` strings casted to `snake_case` properly. The changes made in 7.1.2 broke this functionality and kept it `kebab-case`.

It would be nice to have a `kebab-case` test added to the list to clearly define the expected behavior.

Relates to: #57497, #57612, #57616

Commits
-------

a6d0f3b test: kebab-case to snake_case
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.

u('Principal SIS ID')->snake() return principal_sisid, not principal_sis_id
7 participants