Zend: suggest similar names for undefined function/method/class errors#22589
Open
jorgsowa wants to merge 3 commits into
Open
Zend: suggest similar names for undefined function/method/class errors#22589jorgsowa wants to merge 3 commits into
jorgsowa wants to merge 3 commits into
Conversation
TimWolla
requested changes
Jul 4, 2026
TimWolla
left a comment
Member
There was a problem hiding this comment.
Some feedback regarding the implementation.
The JIT compiler had its own hand-written stub for raising "Call to undefined function" errors that bypassed the new Levenshtein suggestion logic, since it duplicated the error message instead of reusing the interpreter's helper. Extract the shared logic into zend_undefined_function_error() and call it from both the VM helper and the JIT stub.
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.