Use levenshtein level for better Bundle matching #18799
Merged
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 on bad bundle exception, from #11210.
In this snippet, the
$shortest
wasn'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
$lev
from that match to$shortest
.Let say you have these bundles:
FoooooBundle
andFooBundle
and you request the bundleFoodBundle
.$shortest
updated, you'll got a suggestion withFoooooBundle
(first matching bundle found)$shortest
upadted, you'll got a suggestion withFooBundle
(because it has a better level thanFoooooBundle
)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?