Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Use levenshtein level for better Bundle matching#18799
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Member
javiereguiluz commentedMay 17, 2016
I'd say this is a bug because the variable wasn't updated in the loop. I'm 👍 for the change/fix. Thanks@j0k3r. |
Member
stof commentedMay 17, 2016
👍 |
Member
fabpot commentedMay 17, 2016
Thank you@j0k3r. |
fabpot added a commit that referenced this pull requestMay 17, 2016
This PR was merged into the 2.7 branch.Discussion----------Use levenshtein level for better Bundle matching| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets || License | MIT| Doc PR |_I've targetted 2.7 branch since this was introduced in the 2.6 version but the 2.6 isn't maintain anymore._**TL;DR:** I found unused code in bad bundle exception when Symfony try to find the best bundle to fix the typo. Should we remove that code (and got a potential lower matching bundle name) or keep it and make it work?-----I've noticed that a part of the code wasn't used when determining which bundle typo was written on _bad bundle exception_, from#11210.```php$alternative = null;$shortest = null;foreach ($bundleNames as $bundleName) { // if there's a partial match, return it immediately if (false !== strpos($bundleName, $nonExistentBundleName)) { return $bundleName; } $lev = levenshtein($nonExistentBundleName, $bundleName); if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) { $alternative = $bundleName; }}```In this snippet, the `$shortest` wasn't update in the `foreach`. Reading the code, I guess it was supposed to add an even better accuracy when multiple bundle matche the typo'd bundle name.Which mean when an alternative is found, we have to assign the level `$lev` from that match to `$shortest`.```phpif ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) { $alternative = $bundleName; $shortest = $lev;}```Let say you have these bundles: `FoooooBundle` and `FooBundle` and you request the bundle `FoodBundle`.- Without `$shortest` updated, you'll got a suggestion with `FoooooBundle` (first matching bundle found)- With `$shortest` upadted, you'll got a suggestion with `FooBundle` (because it has a better level than `FoooooBundle`)This isn't a _bug fix_ since this is only supposed to help developper but not the final user.**Question is**: should we keep that level comparison or just remove it?Commits-------ac7f74e Use levenshtein level for better Bundle matching
Merged
This was referencedJun 6, 2016
Merged
Merged
Merged
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've targetted 2.7 branch since this was introduced in the 2.6 version but the 2.6 isn't maintain anymore.
TL;DR: I found unused code in bad bundle exception when Symfony try to find the best bundle to fix the typo. Should we remove that code (and got a potential lower matching bundle name) or keep it and make it work?
I've noticed that a part of the code wasn't used when determining which bundle typo was written onbad bundle exception, from#11210.
In this snippet, the
$shortestwasn't update in theforeach. Reading the code, I guess it was supposed to add an even better accuracy when multiple bundle matche the typo'd bundle name.Which mean when an alternative is found, we have to assign the level
$levfrom that match to$shortest.Let say you have these bundles:
FoooooBundleandFooBundleand you request the bundleFoodBundle.$shortestupdated, you'll got a suggestion withFoooooBundle(first matching bundle found)$shortestupadted, you'll got a suggestion withFooBundle(because it has a better level thanFoooooBundle)This isn't abug fix since this is only supposed to help developper but not the final user.
Question is: should we keep that level comparison or just remove it?