Skip to content

Add missing PHPUnit stub methods to MockedClassNameCollectingNodeVisitor#118

Merged
TomasVotruba merged 4 commits into
rectorphp:mainfrom
akankov:add-phpunit-stub-methods
Mar 16, 2026
Merged

Add missing PHPUnit stub methods to MockedClassNameCollectingNodeVisitor#118
TomasVotruba merged 4 commits into
rectorphp:mainfrom
akankov:add-phpunit-stub-methods

Conversation

@akankov
Copy link
Copy Markdown
Contributor

@akankov akankov commented Mar 16, 2026

Summary

Closes #119

MockedClassNameCollectingNodeVisitor recognizes createMock and createPartialMock but misses the equivalent stub methods from PHPUnit's TestCase:

  • createStub()
  • createStubForIntersectionOfInterfaces()
  • createConfiguredStub()

This means classes only referenced via these stub methods are not detected as mocked, which can lead to false positives when analyzing unused classes.

Changes

Added the three missing stub method names to the $mockMethodNames array in MockedClassNameCollectingNodeVisitor.

@TomasVotruba TomasVotruba requested a review from samsonasik March 16, 2026 15:36
@akankov akankov force-pushed the add-phpunit-stub-methods branch from 10bfb78 to 226325e Compare March 16, 2026 15:41
@akankov akankov force-pushed the add-phpunit-stub-methods branch from 226325e to a5b7b23 Compare March 16, 2026 15:42
@TomasVotruba TomasVotruba merged commit 044a16b into rectorphp:main Mar 16, 2026
8 checks passed
@TomasVotruba
Copy link
Copy Markdown
Member

Thanks

@akankov akankov deleted the add-phpunit-stub-methods branch March 16, 2026 17:00
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.

MockedClassNameCollectingNodeVisitor misses PHPUnit stub methods

3 participants