Skip to content

[phpunit] skip variable-callable in NoAssertFuncCallInTestsRule - #311

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-variable-callable-assert
Sep 23, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
skip-variable-callable-assert

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Problem

NoAssertFuncCallInTestsRule targets the assert() language construct in test classes. But NamingHelper::getName() also resolves Variable nodes, so an invoked variable-callable named $assert was flagged too:

public function testMe(callable $assert)
{
    $assert(100); // false positive
}

Fix

Require $node->name instanceof Name before name check, so only real function/construct calls match. Variable-callables are skipped. Added a skip fixture.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 23, 2026 14:35
@TomasVotruba
TomasVotruba merged commit 5d5f18a into main Sep 23, 2026
7 of 8 checks passed
@TomasVotruba
TomasVotruba deleted the skip-variable-callable-assert branch September 23, 2026 14:36
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