-
-
Notifications
You must be signed in to change notification settings - Fork 152
added the grapheme_levenshtein polyfill (closes #555) #558
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
base: 1.x
Are you sure you want to change the base?
Conversation
|
|
||
| \define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX); | ||
| \define('SYMFONY_GRAPHEME_CLUSTER_RX', | ||
| (false !== @preg_match('/\X/u', "a")) |
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.
This change looks suspicious to me. We were explicitly checking the PCRE version because older versions of PCRE also have a broken implementation of \X (there is even an open discussion mentioning that we might need to increase the bound from which we use the native feature)
| */ | ||
| public static function grapheme_levenshtein($string1, $string2, $insertion_cost = 1, $replacement_cost = 1, $deletion_cost = 1) | ||
| { | ||
| // Cast (PHP does this) |
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.
use native parameter types, so that PHP actually does it.
| if (\extension_loaded('intl') && !function_exists('grapheme_levenshtein')) { | ||
| function grapheme_levenshtein($string1, $string2, $insertion_cost = 1, $replacement_cost = 1, $deletion_cost = 1) | ||
| { | ||
| return Grapheme::grapheme_levenshtein($string1, $string2, $insertion_cost, $replacement_cost, $deletion_cost); |
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.
The implementation must be duplicated in the Php85 package if we want to provide it here, not call the other package.
|
|
||
| use Symfony\Polyfill\Intl\Grapheme\Grapheme; | ||
|
|
||
| return [ |
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.
this file does not make sense. It does not provide a phpt test, and we use PHPUnit tests anyway.
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 just wanted to make test file I'll look more deeper in this implementation
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.
the file you added is not a test file at all. It is not testing anything.
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.
This PR implements the grapheme_levenshtein() function for:
Includes:
✔ Function implementation
✔ ICU-compatible segmentation
✔ Test file: tests/Intl/Grapheme/grapheme_levenshtein.phpt