From 7d961f05f67f0a8e4ab3c3a874efdae992dfb7d8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 31 Jul 2026 19:44:47 +0200 Subject: [PATCH 1/5] Bind annotation to attribute pairs to phpunit/phpunit >=10.0 via ruleWithConfigurationComposerVersionBound() --- composer.json | 2 +- config/sets/annotations-to-attributes.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index b8fb816d..bf1a2d35 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^13.2", "rector/jack": "^1.0", - "rector/rector-src": "dev-main", + "rector/rector-src": "dev-rule-with-configuration-composer-version-bound as dev-main", "rector/swiss-knife": "^2.4", "symplify/easy-coding-standard": "^13.2", "symplify/phpstan-extensions": "^12.0", diff --git a/config/sets/annotations-to-attributes.php b/config/sets/annotations-to-attributes.php index a5b81221..0f74f4bb 100644 --- a/config/sets/annotations-to-attributes.php +++ b/config/sets/annotations-to-attributes.php @@ -56,8 +56,9 @@ new AnnotationWithValueToAttribute('testdox', 'PHPUnit\Framework\Attributes\TestDox'), ]); - $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ - // @see https://github.com/sebastianbergmann/phpunit/issues/4502 + // all these attributes were added in PHPUnit 10.0 + // @see https://github.com/sebastianbergmann/phpunit/issues/4502 + $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationToAttributeRector::class, [ new AnnotationToAttribute('after', 'PHPUnit\Framework\Attributes\After'), new AnnotationToAttribute('afterClass', 'PHPUnit\Framework\Attributes\AfterClass'), new AnnotationToAttribute('before', 'PHPUnit\Framework\Attributes\Before'), @@ -78,5 +79,5 @@ ), new AnnotationToAttribute('small', 'PHPUnit\Framework\Attributes\Small'), new AnnotationToAttribute('test', 'PHPUnit\Framework\Attributes\Test'), - ]); + ], 'phpunit/phpunit', '>=10.0'); }; From 71aa50516f24de0e23f1d36501f0b07a27262dae Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 31 Jul 2026 20:44:44 +0200 Subject: [PATCH 2/5] Use rector-src dev-main, feature merged --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf1a2d35..b8fb816d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^13.2", "rector/jack": "^1.0", - "rector/rector-src": "dev-rule-with-configuration-composer-version-bound as dev-main", + "rector/rector-src": "dev-main", "rector/swiss-knife": "^2.4", "symplify/easy-coding-standard": "^13.2", "symplify/phpstan-extensions": "^12.0", From 1cec8154a4067a308614884a8b7931bdbee41056 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 31 Jul 2026 20:47:31 +0200 Subject: [PATCH 3/5] Cover all convertible PHPUnit annotations, bind each to the version range its attribute exists in --- config/sets/annotations-to-attributes.php | 21 +++++++++- .../backup_static_properties_fixture.php.inc | 41 +++++++++++++++++++ ...skip_run_class_in_separate_process.php.inc | 13 ++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc create mode 100644 tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc diff --git a/config/sets/annotations-to-attributes.php b/config/sets/annotations-to-attributes.php index 0f74f4bb..0ccc362f 100644 --- a/config/sets/annotations-to-attributes.php +++ b/config/sets/annotations-to-attributes.php @@ -35,7 +35,8 @@ DependsAnnotationWithValueToAttributeRector::class, ]); - $rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [ + // all these attributes were added in PHPUnit 10.0 + $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationWithValueToAttributeRector::class, [ new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\Framework\Attributes\BackupGlobals', [ 'enabled' => true, 'disabled' => false, @@ -44,6 +45,14 @@ 'enabled' => true, 'disabled' => false, ]), + new AnnotationWithValueToAttribute('backupStaticProperties', 'PHPUnit\Framework\Attributes\BackupStaticProperties', [ + 'enabled' => true, + 'disabled' => false, + ]), + new AnnotationWithValueToAttribute( + 'excludeGlobalVariableFromBackup', + 'PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup' + ), new AnnotationWithValueToAttribute('preserveGlobalState', 'PHPUnit\Framework\Attributes\PreserveGlobalState', [ 'enabled' => true, 'disabled' => false, @@ -54,7 +63,7 @@ new AnnotationWithValueToAttribute('uses', 'PHPUnit\Framework\Attributes\UsesClass', [], true), new AnnotationWithValueToAttribute('testDox', 'PHPUnit\Framework\Attributes\TestDox'), new AnnotationWithValueToAttribute('testdox', 'PHPUnit\Framework\Attributes\TestDox'), - ]); + ], 'phpunit/phpunit', '>=10.0'); // all these attributes were added in PHPUnit 10.0 // @see https://github.com/sebastianbergmann/phpunit/issues/4502 @@ -80,4 +89,12 @@ new AnnotationToAttribute('small', 'PHPUnit\Framework\Attributes\Small'), new AnnotationToAttribute('test', 'PHPUnit\Framework\Attributes\Test'), ], 'phpunit/phpunit', '>=10.0'); + + // the RunClassInSeparateProcess attribute was added in PHPUnit 10.0 and removed in PHPUnit 13.0 + $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationToAttributeRector::class, [ + new AnnotationToAttribute( + 'runClassInSeparateProcess', + 'PHPUnit\Framework\Attributes\RunClassInSeparateProcess' + ), + ], 'phpunit/phpunit', '>=10.0 <13.0'); }; diff --git a/tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc b/tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc new file mode 100644 index 00000000..dc0b3123 --- /dev/null +++ b/tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc @@ -0,0 +1,41 @@ + +----- + diff --git a/tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc b/tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc new file mode 100644 index 00000000..70ac5621 --- /dev/null +++ b/tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc @@ -0,0 +1,13 @@ + Date: Fri, 31 Jul 2026 20:50:24 +0200 Subject: [PATCH 4/5] Move composer version bound pairs to own composer-based set, keep annotations-to-attributes untouched --- config/sets/annotations-to-attributes.php | 28 +++---------- config/sets/composer-based.php | 40 +++++++++++++++++++ src/Set/PHPUnitSetList.php | 2 + tests/ComposerBased/ComposerBasedTest.php | 28 +++++++++++++ .../Fixture/backup_static_properties.php.inc} | 0 ...skip_run_class_in_separate_process.php.inc | 0 tests/ComposerBased/config/composer_based.php | 10 +++++ 7 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 config/sets/composer-based.php create mode 100644 tests/ComposerBased/ComposerBasedTest.php rename tests/{AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc => ComposerBased/Fixture/backup_static_properties.php.inc} (100%) rename tests/{AnnotationsToAttributes => ComposerBased}/Fixture/skip_run_class_in_separate_process.php.inc (100%) create mode 100644 tests/ComposerBased/config/composer_based.php diff --git a/config/sets/annotations-to-attributes.php b/config/sets/annotations-to-attributes.php index 0ccc362f..a5b81221 100644 --- a/config/sets/annotations-to-attributes.php +++ b/config/sets/annotations-to-attributes.php @@ -35,8 +35,7 @@ DependsAnnotationWithValueToAttributeRector::class, ]); - // all these attributes were added in PHPUnit 10.0 - $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationWithValueToAttributeRector::class, [ + $rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [ new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\Framework\Attributes\BackupGlobals', [ 'enabled' => true, 'disabled' => false, @@ -45,14 +44,6 @@ 'enabled' => true, 'disabled' => false, ]), - new AnnotationWithValueToAttribute('backupStaticProperties', 'PHPUnit\Framework\Attributes\BackupStaticProperties', [ - 'enabled' => true, - 'disabled' => false, - ]), - new AnnotationWithValueToAttribute( - 'excludeGlobalVariableFromBackup', - 'PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup' - ), new AnnotationWithValueToAttribute('preserveGlobalState', 'PHPUnit\Framework\Attributes\PreserveGlobalState', [ 'enabled' => true, 'disabled' => false, @@ -63,11 +54,10 @@ new AnnotationWithValueToAttribute('uses', 'PHPUnit\Framework\Attributes\UsesClass', [], true), new AnnotationWithValueToAttribute('testDox', 'PHPUnit\Framework\Attributes\TestDox'), new AnnotationWithValueToAttribute('testdox', 'PHPUnit\Framework\Attributes\TestDox'), - ], 'phpunit/phpunit', '>=10.0'); + ]); - // all these attributes were added in PHPUnit 10.0 - // @see https://github.com/sebastianbergmann/phpunit/issues/4502 - $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationToAttributeRector::class, [ + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ + // @see https://github.com/sebastianbergmann/phpunit/issues/4502 new AnnotationToAttribute('after', 'PHPUnit\Framework\Attributes\After'), new AnnotationToAttribute('afterClass', 'PHPUnit\Framework\Attributes\AfterClass'), new AnnotationToAttribute('before', 'PHPUnit\Framework\Attributes\Before'), @@ -88,13 +78,5 @@ ), new AnnotationToAttribute('small', 'PHPUnit\Framework\Attributes\Small'), new AnnotationToAttribute('test', 'PHPUnit\Framework\Attributes\Test'), - ], 'phpunit/phpunit', '>=10.0'); - - // the RunClassInSeparateProcess attribute was added in PHPUnit 10.0 and removed in PHPUnit 13.0 - $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationToAttributeRector::class, [ - new AnnotationToAttribute( - 'runClassInSeparateProcess', - 'PHPUnit\Framework\Attributes\RunClassInSeparateProcess' - ), - ], 'phpunit/phpunit', '>=10.0 <13.0'); + ]); }; diff --git a/config/sets/composer-based.php b/config/sets/composer-based.php new file mode 100644 index 00000000..cbe97f12 --- /dev/null +++ b/config/sets/composer-based.php @@ -0,0 +1,40 @@ +ruleWithConfigurationComposerVersionBound(AnnotationWithValueToAttributeRector::class, [ + // the PHPUnit 10 spelling of the "backupStaticAttributes" annotation + new AnnotationWithValueToAttribute( + 'backupStaticProperties', + 'PHPUnit\Framework\Attributes\BackupStaticProperties', + [ + 'enabled' => true, + 'disabled' => false, + ] + ), + new AnnotationWithValueToAttribute( + 'excludeGlobalVariableFromBackup', + 'PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup' + ), + ], 'phpunit/phpunit', '>=10.0'); + + // the RunClassInSeparateProcess attribute was added in PHPUnit 10.0 and removed in PHPUnit 13.0 + $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationToAttributeRector::class, [ + new AnnotationToAttribute( + 'runClassInSeparateProcess', + 'PHPUnit\Framework\Attributes\RunClassInSeparateProcess' + ), + ], 'phpunit/phpunit', '>=10.0 <13.0'); +}; diff --git a/src/Set/PHPUnitSetList.php b/src/Set/PHPUnitSetList.php index b1d64ead..f24a9952 100644 --- a/src/Set/PHPUnitSetList.php +++ b/src/Set/PHPUnitSetList.php @@ -36,4 +36,6 @@ final class PHPUnitSetList public const string PHPUNIT_NARROW_ASSERTS = __DIR__ . '/../../config/sets/phpunit-narrow-asserts.php'; public const string ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/annotations-to-attributes.php'; + + public const string COMPOSER_BASED = __DIR__ . '/../../config/sets/composer-based.php'; } diff --git a/tests/ComposerBased/ComposerBasedTest.php b/tests/ComposerBased/ComposerBasedTest.php new file mode 100644 index 00000000..eec4477d --- /dev/null +++ b/tests/ComposerBased/ComposerBasedTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/composer_based.php'; + } +} diff --git a/tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc b/tests/ComposerBased/Fixture/backup_static_properties.php.inc similarity index 100% rename from tests/AnnotationsToAttributes/Fixture/backup_static_properties_fixture.php.inc rename to tests/ComposerBased/Fixture/backup_static_properties.php.inc diff --git a/tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc b/tests/ComposerBased/Fixture/skip_run_class_in_separate_process.php.inc similarity index 100% rename from tests/AnnotationsToAttributes/Fixture/skip_run_class_in_separate_process.php.inc rename to tests/ComposerBased/Fixture/skip_run_class_in_separate_process.php.inc diff --git a/tests/ComposerBased/config/composer_based.php b/tests/ComposerBased/config/composer_based.php new file mode 100644 index 00000000..5522a760 --- /dev/null +++ b/tests/ComposerBased/config/composer_based.php @@ -0,0 +1,10 @@ +sets([PHPUnitSetList::COMPOSER_BASED]); +}; From 7787aa14249736a30bb103b3818c4310ba9005fd Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 31 Jul 2026 20:54:51 +0200 Subject: [PATCH 5/5] Decorate annotation to attribute rules with composer constraint, register them in composer-based set --- config/sets/composer-based.php | 17 +++++++++++++++++ .../DataProviderAnnotationToAttributeRector.php | 9 ++++++++- ...endsAnnotationWithValueToAttributeRector.php | 9 ++++++++- .../TestWithAnnotationToAttributeRector.php | 9 ++++++++- .../AnnotationWithValueToAttributeRector.php | 9 ++++++++- ...versAnnotationWithValueToAttributeRector.php | 9 ++++++++- ...iresAnnotationWithValueToAttributeRector.php | 9 ++++++++- .../TicketAnnotationToAttributeRector.php | 9 ++++++++- 8 files changed, 73 insertions(+), 7 deletions(-) diff --git a/config/sets/composer-based.php b/config/sets/composer-based.php index cbe97f12..6f9ea7f0 100644 --- a/config/sets/composer-based.php +++ b/config/sets/composer-based.php @@ -6,6 +6,12 @@ use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\RequiresAnnotationWithValueToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\TicketAnnotationToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector; +use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector; use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute; /** @@ -13,6 +19,17 @@ * as not every attribute exists in every PHPUnit version. */ return static function (RectorConfig $rectorConfig): void { + // each of these rules declares the "phpunit/phpunit" version its attributes were added in, + // @see ComposerPackageConstraintInterface + $rectorConfig->rules([ + TicketAnnotationToAttributeRector::class, + TestWithAnnotationToAttributeRector::class, + DataProviderAnnotationToAttributeRector::class, + CoversAnnotationWithValueToAttributeRector::class, + RequiresAnnotationWithValueToAttributeRector::class, + DependsAnnotationWithValueToAttributeRector::class, + ]); + // both attributes were added in PHPUnit 10.0 $rectorConfig->ruleWithConfigurationComposerVersionBound(AnnotationWithValueToAttributeRector::class, [ // the PHPUnit 10 spelling of the "backupStaticAttributes" annotation diff --git a/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php index 735c4e58..51d8a6e5 100644 --- a/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php @@ -22,14 +22,16 @@ use Rector\Rector\AbstractRector; use Rector\Reflection\ReflectionResolver; use Rector\ValueObject\PhpVersion; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector\DataProviderAnnotationToAttributeRectorTest */ -final class DataProviderAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class DataProviderAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { public function __construct( private readonly TestsNodeAnalyzer $testsNodeAnalyzer, @@ -84,6 +86,11 @@ public function getNodeTypes(): array return [ClassMethod::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { /** diff --git a/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php index 547f7a4a..8d2e6a7c 100644 --- a/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php @@ -18,14 +18,16 @@ use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector\DependsAnnotationWithValueToAttributeRectorTest */ -final class DependsAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class DependsAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { private const string DEPENDS_ATTRIBUTE = 'PHPUnit\Framework\Attributes\Depends'; @@ -85,6 +87,11 @@ public function getNodeTypes(): array return [Class_::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES; diff --git a/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php index 763cfda7..3751915d 100644 --- a/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php @@ -18,7 +18,9 @@ use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -28,7 +30,7 @@ * * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector\TestWithAnnotationToAttributeRectorTest */ -final class TestWithAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class TestWithAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { private const string TEST_WITH_ATTRIBUTE = 'PHPUnit\Framework\Attributes\TestWith'; @@ -148,6 +150,11 @@ public function refactor(Node $node): ?Node return $node; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES; diff --git a/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php index f206d943..66c7ac5b 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php @@ -19,7 +19,9 @@ use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -27,7 +29,7 @@ /** * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector\AnnotationWithValueToAttributeRectorTest */ -final class AnnotationWithValueToAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface +final class AnnotationWithValueToAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface, ComposerPackageConstraintInterface { /** * @var AnnotationWithValueToAttribute[] @@ -89,6 +91,11 @@ public function getNodeTypes(): array return [Class_::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES; diff --git a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php index aa1cd15f..d4ad0ed0 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php @@ -19,14 +19,16 @@ use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector\CoversAnnotationWithValueToAttributeRectorTest */ -final class CoversAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class CoversAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { private const string COVERS_FUNCTION_ATTRIBUTE = 'PHPUnit\Framework\Attributes\CoversFunction'; @@ -94,6 +96,11 @@ public function getNodeTypes(): array return [Class_::class, ClassMethod::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES; diff --git a/rules/AnnotationsToAttributes/Rector/Class_/RequiresAnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/RequiresAnnotationWithValueToAttributeRector.php index 402517f3..7d081e31 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/RequiresAnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/RequiresAnnotationWithValueToAttributeRector.php @@ -17,14 +17,16 @@ use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\RequiresAnnotationWithValueToAttributeRector\RequiresAnnotationWithValueToAttributeRectorTest */ -final class RequiresAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class RequiresAnnotationWithValueToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { public function __construct( private readonly PhpDocTagRemover $phpDocTagRemover, @@ -84,6 +86,11 @@ public function getNodeTypes(): array return [Class_::class, ClassMethod::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES; diff --git a/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php index 2e18c3ae..b978b9ad 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php @@ -22,7 +22,9 @@ use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -31,7 +33,7 @@ * * @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\TicketAnnotationToAttributeRector\TicketAnnotationToAttributeRectorTest */ -final class TicketAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface +final class TicketAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface, ComposerPackageConstraintInterface { private const string TICKET_CLASS = 'PHPUnit\Framework\Attributes\Ticket'; @@ -81,6 +83,11 @@ public function getNodeTypes(): array return [Class_::class, ClassMethod::class]; } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + return new ComposerPackageConstraint('phpunit/phpunit', '>=10.0'); + } + public function provideMinPhpVersion(): int { return PhpVersionFeature::ATTRIBUTES;