diff --git a/config/sets/doctrine-code-quality.php b/config/sets/doctrine-code-quality.php index 4ed3dd27..18ee4d3a 100644 --- a/config/sets/doctrine-code-quality.php +++ b/config/sets/doctrine-code-quality.php @@ -4,12 +4,12 @@ use Rector\Config\RectorConfig; use Rector\Doctrine\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector; +use Rector\Doctrine\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector; use Rector\Doctrine\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector; use Rector\Doctrine\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector; use Rector\Doctrine\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector; use Rector\Doctrine\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector; use Rector\Doctrine\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector; -use Rector\Doctrine\Rector\Class_\RemoveEmptyTableAttributeRector; use Rector\Doctrine\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector; use Rector\Doctrine\Rector\Property\TypedPropertyFromColumnTypeRector; use Rector\Doctrine\Rector\Property\TypedPropertyFromDoctrineCollectionRector; diff --git a/src/Rector/Class_/RemoveEmptyTableAttributeRector.php b/rules/CodeQuality/Rector/Class_/RemoveEmptyTableAttributeRector.php similarity index 97% rename from src/Rector/Class_/RemoveEmptyTableAttributeRector.php rename to rules/CodeQuality/Rector/Class_/RemoveEmptyTableAttributeRector.php index f505828b..8f192126 100644 --- a/src/Rector/Class_/RemoveEmptyTableAttributeRector.php +++ b/rules/CodeQuality/Rector/Class_/RemoveEmptyTableAttributeRector.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Doctrine\Rector\Class_; +namespace Rector\Doctrine\CodeQuality\Rector\Class_; use PhpParser\Node; use PhpParser\Node\Stmt\Class_; diff --git a/src/Rector/Property/TypedPropertyFromColumnTypeRector.php b/src/Rector/Property/TypedPropertyFromColumnTypeRector.php index f6e3dcef..d8451c10 100644 --- a/src/Rector/Property/TypedPropertyFromColumnTypeRector.php +++ b/src/Rector/Property/TypedPropertyFromColumnTypeRector.php @@ -14,17 +14,19 @@ use Rector\Core\Php\PhpVersionProvider; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersion; +use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Doctrine\NodeManipulator\ColumnPropertyTypeResolver; use Rector\Doctrine\NodeManipulator\NullabilityColumnPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; +use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromColumnTypeRector\TypedPropertyFromColumnTypeRectorTest */ -final class TypedPropertyFromColumnTypeRector extends AbstractRector +final class TypedPropertyFromColumnTypeRector extends AbstractRector implements MinPhpVersionInterface { public function __construct( private readonly PropertyTypeDecorator $propertyTypeDecorator, @@ -120,4 +122,9 @@ public function refactor(Node $node): Property|null $this->phpDocTypeChanger->changeVarType($node, $phpDocInfo, $propertyType); return $node; } + + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::TYPED_PROPERTIES; + } } diff --git a/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php b/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php index 31eaf646..07faad44 100644 --- a/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php +++ b/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php @@ -13,16 +13,18 @@ use Rector\Core\Php\PhpVersionProvider; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersion; +use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Doctrine\NodeManipulator\ToManyRelationPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; +use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromToManyRelationTypeRector\TypedPropertyFromToManyRelationTypeRectorTest */ -final class TypedPropertyFromToManyRelationTypeRector extends AbstractRector +final class TypedPropertyFromToManyRelationTypeRector extends AbstractRector implements MinPhpVersionInterface { public function __construct( private readonly PropertyTypeDecorator $propertyTypeDecorator, @@ -118,4 +120,9 @@ public function refactor(Node $node): Property|null return $node; } + + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::TYPED_PROPERTIES; + } } diff --git a/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php b/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php index 8b5de943..4410dd20 100644 --- a/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php +++ b/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php @@ -16,16 +16,18 @@ use Rector\Core\Php\PhpVersionProvider; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersion; +use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Doctrine\NodeManipulator\ToOneRelationPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; +use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromToOneRelationTypeRector\TypedPropertyFromToOneRelationTypeRectorTest */ -final class TypedPropertyFromToOneRelationTypeRector extends AbstractRector +final class TypedPropertyFromToOneRelationTypeRector extends AbstractRector implements MinPhpVersionInterface { public function __construct( private readonly PropertyTypeDecorator $propertyTypeDecorator, @@ -101,6 +103,11 @@ public function refactor(Node $node): Property|null return $node; } + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::TYPED_PROPERTIES; + } + private function completePropertyTypeOrVarDoc( Type $propertyType, Name|ComplexType|Identifier $typeNode, diff --git a/tests/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector/config/configured_rule.php b/tests/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector/config/configured_rule.php index 017dfbc5..cf0ffb9f 100644 --- a/tests/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector/config/configured_rule.php +++ b/tests/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector/config/configured_rule.php b/tests/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector/config/configured_rule.php index 2a83a17a..7616012f 100644 --- a/tests/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector/config/configured_rule.php +++ b/tests/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php b/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php index e65a1204..b9ab8bff 100644 --- a/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php +++ b/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php @@ -1,11 +1,12 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/auto_import.php b/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/auto_import.php index d0027c84..3d0f9459 100644 --- a/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/auto_import.php +++ b/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/auto_import.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); $rectorConfig->importNames(); diff --git a/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/configured_rule.php b/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/configured_rule.php index 34550d02..4716fc9d 100644 --- a/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/configured_rule.php +++ b/tests/Rector/Class_/InitializeDefaultEntityCollectionRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector/config/configured_rule.php b/tests/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector/config/configured_rule.php index 46698dcb..8442f7ec 100644 --- a/tests/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector/config/configured_rule.php +++ b/tests/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Class_/RemoveEmptyTableAttributeRector/config/configured_rule.php b/tests/Rector/Class_/RemoveEmptyTableAttributeRector/config/configured_rule.php index cc659619..d55f98fd 100644 --- a/tests/Rector/Class_/RemoveEmptyTableAttributeRector/config/configured_rule.php +++ b/tests/Rector/Class_/RemoveEmptyTableAttributeRector/config/configured_rule.php @@ -1,11 +1,12 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector/config/configured_rule.php b/tests/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector/config/configured_rule.php index 4da2dc57..4a5e9927 100644 --- a/tests/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector/config/configured_rule.php +++ b/tests/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector/config/configured_rule.php b/tests/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector/config/configured_rule.php index 0107ad7b..7448edd9 100644 --- a/tests/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector/config/configured_rule.php +++ b/tests/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector/config/configured_rule.php @@ -1,10 +1,11 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector/config/configured_rule.php b/tests/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector/config/configured_rule.php index ffa3e8e2..a17c9e43 100644 --- a/tests/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector/config/configured_rule.php +++ b/tests/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php b/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php index df26af86..cd2d7de8 100644 --- a/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php +++ b/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector/config/configured_rule.php b/tests/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector/config/configured_rule.php index a32fe2ba..cfa0723e 100644 --- a/tests/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector/config/configured_rule.php +++ b/tests/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector/config/configured_rule.php @@ -1,10 +1,11 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector/config/configured_rule.php b/tests/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector/config/configured_rule.php index 9f0f2cd9..36c11589 100644 --- a/tests/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector/config/configured_rule.php +++ b/tests/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector/config/configured_rule.php b/tests/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector/config/configured_rule.php index 104b0064..a74d4b3e 100644 --- a/tests/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector/config/configured_rule.php +++ b/tests/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/DoctrineTargetEntityStringToClassConstantRector/config/configured_rule.php b/tests/Rector/Property/DoctrineTargetEntityStringToClassConstantRector/config/configured_rule.php index d962b92d..d24d79b2 100644 --- a/tests/Rector/Property/DoctrineTargetEntityStringToClassConstantRector/config/configured_rule.php +++ b/tests/Rector/Property/DoctrineTargetEntityStringToClassConstantRector/config/configured_rule.php @@ -1,10 +1,11 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector/config/configured_rule.php b/tests/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector/config/configured_rule.php index e1d7a004..1f7f7c63 100644 --- a/tests/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector/config/configured_rule.php +++ b/tests/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php b/tests/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php index cefd5313..4a432689 100644 --- a/tests/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php +++ b/tests/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/configured_rule.php b/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/configured_rule.php index 3be3313a..439e32f1 100644 --- a/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/configured_rule.php +++ b/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/non_typed_properties.php b/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/non_typed_properties.php index f5d0fad8..9fe2cf23 100644 --- a/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/non_typed_properties.php +++ b/tests/Rector/Property/TypedPropertyFromColumnTypeRector/config/non_typed_properties.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/TypedPropertyFromDoctrineCollectionRector/config/configured_rule.php b/tests/Rector/Property/TypedPropertyFromDoctrineCollectionRector/config/configured_rule.php index 94ce7d00..4871519d 100644 --- a/tests/Rector/Property/TypedPropertyFromDoctrineCollectionRector/config/configured_rule.php +++ b/tests/Rector/Property/TypedPropertyFromDoctrineCollectionRector/config/configured_rule.php @@ -1,10 +1,11 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/TypedPropertyFromToManyRelationTypeRector/config/configured_rule.php b/tests/Rector/Property/TypedPropertyFromToManyRelationTypeRector/config/configured_rule.php index 585b8dfe..6b670350 100644 --- a/tests/Rector/Property/TypedPropertyFromToManyRelationTypeRector/config/configured_rule.php +++ b/tests/Rector/Property/TypedPropertyFromToManyRelationTypeRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN); diff --git a/tests/Rector/Property/TypedPropertyFromToOneRelationTypeRector/config/configured_rule.php b/tests/Rector/Property/TypedPropertyFromToOneRelationTypeRector/config/configured_rule.php index 76ac1b94..362f3b10 100644 --- a/tests/Rector/Property/TypedPropertyFromToOneRelationTypeRector/config/configured_rule.php +++ b/tests/Rector/Property/TypedPropertyFromToOneRelationTypeRector/config/configured_rule.php @@ -1,12 +1,13 @@ import(ConfigList::MAIN);