Closed donaldinou closed 5 years ago
@donaldinou Thanks for the report. Would you like provide PR with the hotfix and unit tests?
@donaldinou I've investigated it, and I think it is invalid. For example:
TheseAre_SOME_CamelCASEDWords
These_Are_SOME_Camel_C_ASEDrds
These_Are_SOME_Camel_CASED_Words
Please note that $replacement
array is different for both cases, and from my quick tests, changing pattern and replacement for non-unicode as shown below, works the same:
if (StringUtils::hasPcreUnicodeSupport()) {
$pattern = ['#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#', '#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#'];
$replacement = [$this->separator . '\1', $this->separator . '\1'];
} else {
$pattern = ['#(?<=(?:[A-Z]))([A-Z][a-z])#', '#(?<=(?:[a-z0-9]))([A-Z])#']; // removed one part
$replacement = [$this->separator . '\1', $this->separator . '\1']; // the same as in the if statement now
}
If you are experiencing an issue, please provide a failing test case, and then we will try to resolve it somehow. Thanks!
But it just that the regexp is not the same between unicode or not. The result should be the same if there is unicode activated or not. 3 months ago it was not.
Test TheseAre_SOME_CamelCASEDWords
For both unicode and not. Differents result (3 months ago no one works like you want)
@donaldinou
3 months ago it was not.
There was no any change in that file for last 3 year...
If you can provide failing test case, please open another issue. Thanks!
On the CamelCaseToSeparator class, the regexp is not the same if the unicode support is on or not (Actually the unicode is wrong). The result is that it will produce unexpected result if we're using unicode support.
As you can see an uppercase bracket is missing.([A-Z+])
so it, should be