Repository navigation
Conversation
TimWolla
requested changes
Jul 4, 2026
TimWolla
left a comment
Member
There was a problem hiding this comment.
Some feedback regarding the implementation.
jorgsowa
force-pushed
the
feat/levenshtein-suggestions
branch
from
August 3, 2026 21:50
ad14e87 to
3c111b3
Compare
NickSdot
reviewed
Aug 5, 2026
| try { | ||
| test(); | ||
| } catch (Error $e) { | ||
| echo $e->getMessage(), "\n"; |
Contributor
There was a problem hiding this comment.
Suggested change
| echo $e->getMessage(), "\n"; | |
| echo $e::class, ': ', $e->getMessage(), "\n"; |
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
NickSdot
reviewed
Aug 5, 2026
Contributor
|
I like this. Added some nit comments. Context is the ongoing effort in #22799. |
jorgsowa
marked this pull request as draft
August 5, 2026 21:43
Member
|
I am in favor of this. Just mentioning that this doesn't requires a RFC imho. Improving error message is not a BC break. We only need to send emails to internals to make sure not body rejects, which you already done. However, since we are very close to the soft feature freeze. @php/release-managers-86 Do you think this qualifies as a post- soft-feature-freeze feature? |
jorgsowa
force-pushed
the
feat/levenshtein-suggestions
branch
from
September 14, 2026 18:39
160adb0 to
d8633b9
Compare
When a function, method, class, interface or trait cannot be found, append a "(did you mean X?)" hint naming the closest existing match by Levenshtein distance: Call to undefined function strlenn() (did you mean strlen?) Call to undefined method Calculator::addd() (did you mean add?) Class "ArrayObjekt" not found (did you mean ArrayObject?) Names shorter than 3 characters are not matched. The allowed distance is 1, or 2 for names of 8 or more characters. Matching is case-insensitive and the suggestion uses the declared casing. Function suggestions cover direct and dynamic calls, constant expressions and the opcache JIT. For unqualified calls in a namespace, names in the current namespace are tried first, falling back to global names, mirroring function lookup.
jorgsowa
force-pushed
the
feat/levenshtein-suggestions
branch
from
October 17, 2026 09:41
d8633b9 to
cba3e19
Compare
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
Sign up for free
to 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.
An idea that I came up with during the implementation of case-sensitive PHP. Small DX improvement over the typos and mistakes in function/classes names.
Because this covers the case of an undefined function, it shouldn't decrease the performance of a properly working application.
Adaptive threshold: names under 8 characters must be within edit distance 1 to be suggested; names 8+ characters allow distance 2. This avoids noisy suggestions for short identifiers (a 1-character edit on a 4-letter name is a big relative change) while still catching multi-typo mistakes in longer names.
We can extend it to constants, etc., if the idea is good enough.