Skip to content

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

Open
TomasVotruba wants to merge 1 commit into
mainfrom
tv-perf-assert-regexp
Open

TomasVotruba wants to merge 1 commit 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.

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