Skip to content

fix(tokenizer): stop reading keyword arguments and members named function as declarations - #388

Merged
roxblnfk merged 1 commit into
1.xfrom
fix/tokenizer-named-function-arg
Oct 13, 2026
Merged

roxblnfk merged 1 commit into
1.xfrom
fix/tokenizer-named-function-arg

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

What was changed

  • A named argument function: no longer registers a phantom function or method: $this->run(function: 1); if (...) used to add a method if to the enclosing class.
  • A method named function is now found instead of being taken for a closure.
  • A closure with a comment before its parameter list (function /* … */ ()) is no longer registered under the comment's text.

Why?

TokenizedFile reads a function's name as the token before the next (, so any function token that does not declare anything picked up an unrelated name. Found while estimating executable lines for coverage, where class: and function: arguments trip the same kind of scan.

Checklist

  • Tested
    • Unit tests added
    • Full suite (without benches) passes locally

@roxblnfk
roxblnfk requested a review from a team as a code owner October 13, 2026 06:24
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@roxblnfk
roxblnfk force-pushed the fix/tokenizer-named-function-arg branch 6 times, most recently from e6290fe to 0f38e10 Compare October 13, 2026 16:53
…ction` as declarations

The name of a function was read from the token before the next `(`, so any `function` token that declares nothing borrowed a name from later code: a named argument `f(function: $x)` followed by `if (` became a method `if`, and a constant, enum case or trait alias named `function`, or a grouped `use function` import, produced methods and functions that do not exist. A method named `function` was taken for a closure and left out. A declaration is now recognized only as `function`, an optional `&`, a name spelled as a PHP label and `(`, with comments allowed in between, and never right after `::`, where `Foo::function and ($x)` would otherwise declare `and`.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk force-pushed the fix/tokenizer-named-function-arg branch 2 times, most recently from 0f38e10 to 55df58d Compare October 13, 2026 17:00
@roxblnfk
roxblnfk merged commit ea0d82f into 1.x Oct 13, 2026
54 of 62 checks passed
@roxblnfk
roxblnfk deleted the fix/tokenizer-named-function-arg branch October 13, 2026 17:11
@roxblnfk roxblnfk mentioned this pull request Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant