Skip to content

Cap removed-API rules at upper version bound - #798

Merged
TomasVotruba merged 1 commit into
mainfrom
cap-removed-phpunit-api-rules
Oct 11, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
cap-removed-phpunit-api-rules

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Several version-bound rules migrate off a PHPUnit API that was hard-removed in a known major. Past removal + 2 majors the legacy source can no longer exist in runnable code, so keeping these rules active on every file is cost with no value. Matches the existing upper-bound pattern already used on ExplicitPhpErrorApiRector and TestListenerToHooksRector.

Adds an upper bound to each, using removal major + 2:

Rule constraint source API removed in
GetMockRector phpunit/phpunit >=5.4 <8.0 getMock() removed 6.0
DelegateExceptionArgumentsRector phpunit/phpunit >=5.2 <8.0 setExpectedException() removed 6.0
ExceptionAnnotationRector phpunit/phpunit >=5.2 <11.0 @ExpectedException removed 9.0
AssertEqualsParameterToSpecificMethodsTypeRector phpunit/phpunit >=7.5 <11.0 assertEquals() optional params removed 9.0
SpecificAssertContainsRector phpunit/phpunit >=7.5 <11.0 assertContains() string haystack removed 9.0
SpecificAssertContainsWithoutIdentityRector phpunit/phpunit >=9.0 <11.0 assertContains() extra params removed 9.0
SpecificAssertInternalTypeRector phpunit/phpunit >=7.5 <11.0 assertInternalType() removed 9.0
WithConsecutiveRector phpunit/phpunit >=10.0 <12.0 withConsecutive() removed 10.0

Removal majors verified against the PHPUnit ChangeLog-6.0 / 9.0 / 10.0 Removed sections.

Each rule gets a test composer.json stub pinning phpunit inside the capped range plus a provideComposerJsonFilePath() override, so the rules stay active under test.

Left uncapped (no source API removal, modernization only): GetMockBuilderGetMockToCreateMockRector, AssertRegExpRector, RemoveDataProviderTestPrefixRector, AddDoesNotPerformAssertionToNonAssertingTestRector.

@TomasVotruba
TomasVotruba merged commit 29c5512 into main Oct 11, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the cap-removed-phpunit-api-rules branch October 11, 2026 17:29
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