-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.5] Sync Str with Stringy 3.0.1 #18974
Conversation
src/Illuminate/Support/Str.php
Outdated
{ | ||
$languageSpecific = static::languageSpecificCharsArray($language); | ||
|
||
if ($languageSpecific !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!is_null() seems more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed 👍
@taylorotwell it's WIP, and lacks of additional actions like https://github.com/danielstjules/Stringy/blob/master/src/Stringy.php#L1863 |
@iwex I've done that I just simplified the function https://github.com/laravel/framework/pull/18974/files#diff-d19e1b0b8c742f268aabdbf1595bcfbdR614 The behavior is the same You might have confused it with the other Edit The only reason i set the flag to WIP actually was to see if som1 could come up with an approach to get the locale directly from the config instead of passing it as a parameter, however I think we can't do that... |
@fernandobandeira thanks for explanation :) Stringy has really messy method |
* | ||
* Note: Adapted from Stringy\Stringy. | ||
* | ||
* @see https://github.com/danielstjules/Stringy/blob/3.0.1/LICENSE.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this link to the licence intentional, or should this link to the source file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied it from the other method that graham created, I guess it's intentional to show that we can freely use this code on our project. But we could also link to the source file...
This PR intends to sync our core Str class with the behavior provided by Stringy library.
There's a few things that we should consider:
@
was removed from the library so it no longers changes toat
, the library manually changes@
to-
when generating the slug, I kept the previous behavior and moved it to the slug function, this way we can override the array in the future without caring about this and we also don't change the current behavior.The library now uses locale's to replace characters according to the specific language. This also fixes some issues we had in the past of incorrect behavior, for example:
ü
previously was being replaced byue
now it is replaced byu
and is replaced byue
just when using thede
locale.