Skip to content

[PHPUnit90] Speed up AssertRegExpRector with cheap method-name gate - #796

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-perf-assert-regexp
Oct 16, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv-perf-assert-regexp

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Perf

AssertRegExpRector subscribes to every STMTS_AWARE node and, for each MethodCall/StaticCall statement, calls TestsNodeAnalyzer::isPHPUnitMethodCallNames(). That helper resolves the caller type (getType() + isInstanceOf TestCase/Assert reflection) first, and only then checks the method name.

So every method-call statement in a codebase pays full TestCase type resolution even when its name is not one of the four asserts the rule cares about.

Added a cheap name gate (isNames(), pure string compare on the call name) before the type-resolving call. Only assertSame/assertEquals/assertNotSame/assertNotEquals calls now reach the costly check. Behavior unchanged - isPHPUnitMethodCallNames still runs with the same name list right after.

@TomasVotruba
TomasVotruba merged commit e51eabb into main Oct 16, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-assert-regexp branch October 16, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant