-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
snake_case() not working with lowercase words #15497
Comments
That seems to be correct due to the ctype_lower part. |
Is there any reason why it checks that a string is not lowercase? Maybe for some other use in the framework? Personally, I wouldn't like to have to call ucfirst() or ucwords() to convert to snake case. Makes more sense it just works for all strings. |
@bradbird1990: In your case I would just run this:
Since |
This is incorrect. the ctype_lower() call simply skips any work if all the characters in the string are lowercase ( meaning that it's by definition already "snaked" ). Spaces, digits, or anything else will call the meat of the method.
It seems like unexpected results to return "snaked" words only if those words or letters start with uppercase and to explicitly ignore a space followed by an letter, a use case which is omitted in the tests for the method.
As a temporary workaround under normal circumstances, one can wrap the argument in ucwords(), but this seems like a patch rather than a fix.
|
Added PR targetting [5.5] #18764 |
I think snake_case() is still not working correctly; found it was last fixed here #9535.
Would fix this issue myself but don't know regex.
I expect "hello world" or "Hello World" to convert to "hello_world" regardless of if I use uppercase or lowercase. In fact, I think "HELLO WORLD" should also convert to "hello_world."
Currently it's only working if I use capitals for first letters in a sentence.
The text was updated successfully, but these errors were encountered: