Repository navigation
fix(resolution): case-insensitive names pass the prefilter; PHP => fn() is a bare call - #2141
Merged
Merged
Conversation
…n()` is a bare call
- The name prefilter checks a case-SENSITIVE set of known names, so in PHP,
Pascal, CFML, COBOL and VB.NET — whose identifiers ignore case — a call
written in another case (`formatprice()` for `FormatPrice`, TestBox's
`ToMatchWithCase()`) was dropped before any strategy ran. Those languages
now also check a lowercase set (built lazily, only when asked).
- `isBarePhpCall` took any `>` before a name for `->`: every call after `=>`
in a PHP array (`'total' => count($items)`, `'by' => user()->id`,
`'label' => trans('…')`) was a member call, and found a same-named method
— 166 wrong edges on BookStack (`trans` → LocaleDefinition::trans,
`new Response` → ImageStorageDisk::response, `url()`, `config()`, `count()`).
It now requires `->` / `?->` / `::`.
- A fuzzy `instantiates` never names a method.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
hasAnyPossibleMatchchecks a case-sensitive set of known names. In PHP, Pascal, CFML, COBOL and VB.NET, a call in another case (formatprice()forFormatPrice, TestBox'sToMatchWithCase()) was dropped before fuzzy matching, which is case-insensitive for exactly these languages, could run. Found while testing fix(resolution): fuzzy matching is exact-case outside case-insensitive languages #2139.=>read as a method call.isBarePhpCalltreated any>before the name as->. So in Laravel-style arrays ('total' => count($items),'by' => user()->id,'label' => trans('…')) the bare-call rule ("a bare PHP call is a function") never applied, and fuzzy picked a same-named method.Change
ReferenceResolver, case-insensitive languages also pass the prefilter throughhasAnyPossibleMatchIgnoringCase, which checks the name or any./::/->part against a lowercased copy of the known-name set. The copy is built on first use and reset with the caches.isBarePhpCallrequires->,?->or::before the name. That also makes the else-arm of$x ? a : fn()a bare call.matchFuzzy: aninstantiatesreference never names a method.Measured (edges, wasm, main vs branch)
trans()→LocaleDefinition::trans(61),new Response→ImageStorageDisk::response(55),user()→ a guard'susermethod (23),url()(16),config()(7),count()(3). Added:user()→ BookStack's ownuser()helper (23)ToMatchWithCase→toMatchWithCase,makepublic→makePublicaccept()→ a same-named method; a bare Delphi call can reach an inherited method, so this isn't ruled outTests
fuzzy-case-sensitivity.test.tsadds a PHP call in another case and a PHP=>array. Both fail on main. The full suite passes (5600).🤖 Generated with Claude Code