diff --git a/src/contracts/Factory/IbexaRectorConfigFactory.php b/src/contracts/Factory/IbexaRectorConfigFactory.php index 0e601d7..ef6b656 100644 --- a/src/contracts/Factory/IbexaRectorConfigFactory.php +++ b/src/contracts/Factory/IbexaRectorConfigFactory.php @@ -41,7 +41,7 @@ public function createConfig(): RectorConfigBuilder ->withSets( array_merge( [ - IbexaSetList::IBEXA_50->value, + IbexaSetList::IBEXA_60->value, SymfonySetList::SYMFONY_50, SymfonySetList::SYMFONY_50_TYPES, SymfonySetList::SYMFONY_51, diff --git a/src/contracts/Sets/IbexaSetList.php b/src/contracts/Sets/IbexaSetList.php index a42257f..134036a 100644 --- a/src/contracts/Sets/IbexaSetList.php +++ b/src/contracts/Sets/IbexaSetList.php @@ -12,4 +12,5 @@ enum IbexaSetList: string { case IBEXA_46 = __DIR__ . '/ibexa-46.php'; case IBEXA_50 = __DIR__ . '/ibexa-50.php'; + case IBEXA_60 = __DIR__ . '/ibexa-60.php'; } diff --git a/src/contracts/Sets/ibexa-60.php b/src/contracts/Sets/ibexa-60.php new file mode 100644 index 0000000..0cec005 --- /dev/null +++ b/src/contracts/Sets/ibexa-60.php @@ -0,0 +1,324 @@ +ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\\Bundle\\Core\\ApiLoader\\RepositoryConfigurationProvider' => 'Ibexa\\Contracts\\Core\\Container\\ApiLoader\\RepositoryConfigurationProviderInterface', + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassConstFetchRector::class, + [ + new RenameClassConstFetch( + 'Ibexa\Bundle\SystemInfo\SystemInfo\Collector\IbexaSystemInfoCollector', + 'CONTENT_PACKAGES', + 'HEADLESS_PACKAGES' + ), + new RenameClassConstFetch( + 'Ibexa\Bundle\SystemInfo\SystemInfo\Collector\IbexaSystemInfoCollector', + 'ENTERPRISE_PACKAGES', + 'HEADLESS_PACKAGES' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenamePropertyRector::class, + [ + new RenameProperty( + 'Ibexa\Bundle\SystemInfo\SystemInfo\Value\IbexaSystemInfo', + 'stability', + 'lowestStability', + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameMethodRector::class, + [ + new MethodCallRename( + 'Ibexa\Contracts\Rest\Output\Generator', + 'generateMediaType', + 'generateMediaTypeWithVendor' + ), + new MethodCallRename( + 'Ibexa\Rest\Output\FieldTypeSerializer', + 'serializeFieldValue', + 'serializeContentFieldValue' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RemoveArgumentFromMethodCallRector::class, + [ + 'class_name' => 'Ibexa\Rest\Output\FieldTypeSerializer', + 'method_name' => 'serializeContentFieldValue', + 'argument_index_to_remove' => 1, + 'more_than' => 2, + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassConstFetchRector::class, + [ + new RenameClassAndConstFetch( + 'Ibexa\Bundle\FieldTypePage\DependencyInjection\Compiler\BlockDefinitionConfigurationCompilerPass', + 'EXTENSION_CONFIG_KEY', + 'Ibexa\Bundle\FieldTypePage\DependencyInjection\IbexaFieldTypePageExtension', + 'EXTENSION_NAME' + ), + new RenameClassAndConstFetch( + 'Ibexa\Bundle\FieldTypePage\DependencyInjection\Compiler\AbstractConfigurationAwareCompilerPass', + 'EXTENSION_CONFIG_KEY', + 'Ibexa\Bundle\FieldTypePage\DependencyInjection\IbexaFieldTypePageExtension', + 'EXTENSION_NAME' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + PropertyToGetterRector::class, + [ + 'Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest' => [ + 'scheme' => 'getScheme', + 'host' => 'getHost', + 'port' => 'getPort', + 'pathinfo' => 'getPathInfo', + 'queryParams' => 'getQueryParams', + 'languages' => 'getLanguages', + 'headers' => 'getHeaders', + ], + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\Cart\Money\MoneyFactory' => 'Ibexa\ProductCatalog\Money\IntlMoneyFactory', + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassConstFetchRector::class, + [ + new RenameClassAndConstFetch( + 'Ibexa\Bundle\SiteFactory\DependencyInjection\Configuration', + 'TREE_ROOT', + 'Ibexa\Bundle\SiteFactory\DependencyInjection\IbexaSiteFactoryExtension', + 'EXTENSION_NAME' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\\Bundle\\Shipping\\Form\\Type\\RegionChoiceType' => 'Ibexa\\Bundle\\ProductCatalog\\Form\\Type\\RegionChoiceType', + 'Ibexa\\Contracts\\Shipping\\Iterator\\BatchIteratorAdapter\\RegionFetchAdapter' => 'Ibexa\\Contracts\\ProductCatalog\\Iterator\\BatchIteratorAdapter\\RegionFetchAdapter', + ], + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassConstFetchRector::class, + [ + new RenameClassAndConstFetch( + 'Ibexa\Bundle\FormBuilder\DependencyInjection\Configuration', + 'TREE_ROOT', + 'Ibexa\Bundle\FormBuilder\DependencyInjection\IbexaFormBuilderExtension', + 'EXTENSION_NAME' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassConstFetchRector::class, + [ + new RenameClassAndConstFetch( + 'Ibexa\Migration\ValueObject\ContentType\Matcher', + 'CONTENT_TYPE_IDENTIFIER', + 'Ibexa\Migration\StepExecutor\ContentType\IdentifierFinder', + 'CONTENT_TYPE_IDENTIFIER' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\\Solr\\Gateway\\UpdateSerializer' => 'Ibexa\\Solr\\Gateway\\UpdateSerializer\\XmlUpdateSerializer', + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\\Solr\\Query\\Content\\CriterionVisitor\\Field' => 'Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\Field', + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenamePropertyRector::class, + [ + new RenameProperty( + 'Ibexa\Contracts\Core\Repository\Values\Content\Trash\SearchResult', + 'count', + 'totalCount', + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenamePropertyRector::class, + [ + new RenameProperty( + 'Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult', + 'spellSuggestion', + 'spellcheck', + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\Bundle\Core\Imagine\VariationPathGenerator' => 'Ibexa\Contracts\Core\Variation\VariationPathGenerator', + ] + ); + + $rectorConfig->ruleWithConfiguration( + RenameClassRector::class, + [ + 'Ibexa\Bundle\Messenger\Stamp\DeduplicateStamp' => 'Symfony\Component\Messenger\Stamp\DeduplicateStamp', + 'Ibexa\Contracts\Messenger\Stamp\DeduplicateStamp' => 'Symfony\Component\Messenger\Stamp\DeduplicateStamp', + ] + ); + + $rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [ + 'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType' => [ + 'isContainer' => 'isContainer', + ], + ]); + + $rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [ + 'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft' => [ + 'isContainer' => 'isContainer', + ], + ]); + + $rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [ + 'Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft' => [ + 'isContainer' => 'isContainer', + ], + ]); + + $rectorConfig->ruleWithConfiguration( + ConstToEnumValueRector::class, + [ + 'Ibexa\Contracts\Core\Repository\Values\Content\Relation' => [ + 'enumClass' => 'Ibexa\Contracts\Core\Repository\Values\Content\RelationType', + 'constants' => [ + 'COMMON' => 'COMMON', + 'EMBED' => 'EMBED', + 'LINK' => 'LINK', + 'FIELD' => 'FIELD', + 'ASSET' => 'ASSET', + ], + ], + ] + ); + + $rectorConfig->ruleWithConfiguration( + AddReturnTypeFromPhpDocRule::class, + [ + new MethodReturnTypeConfiguration( + 'Ibexa\Contracts\Rest\Input\Parser', + 'parse' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + AddReturnTypeFromParentMethodRule::class, + [ + new MethodReturnTypeConfiguration( + 'Ibexa\Contracts\Rest\Input\Parser', + 'parse' + ), + ] + ); + + $rectorConfig->ruleWithConfiguration( + ChangeArgumentTypeRector::class, + [ + new ChangeArgumentTypeConfiguration( + 'Ibexa\\Migration\\Generator\\StepBuilder\\StepFactoryInterface', + 'create', + 0, + 'Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject', + ), + new ChangeArgumentTypeConfiguration( + 'Ibexa\\Migration\\Generator\\StepBuilder\\AbstractStepFactory', + 'prepareLogMessage', + 0, + 'Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject', + ), + new ChangeArgumentTypeConfiguration( + 'Ibexa\\Migration\\StepExecutor\\ReferenceDefinition\\ResolverInterface', + 'resolve', + 1, + 'Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject' + ), + new ChangeArgumentTypeConfiguration( + 'Ibexa\\Migration\\Generator\\StepBuilder\\StepBuilderInterface', + 'build', + 0, + 'Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject' + ), + + new ChangeArgumentTypeConfiguration( + 'Ibexa\\Contracts\\Core\\Limitation\\Type', + 'evaluate', + 2, + 'Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject' + ), + ] + ); + + $rectorConfig->skip( + [ + // skip removing `createView` method call from `Form` objects, per SF 7 recommendation + SimplifyFormRenderingRector::class, + ] + ); +}; diff --git a/tests/contracts/IbexaRectorConfigFactoryTest.php b/tests/contracts/IbexaRectorConfigFactoryTest.php index 2010b2e..3016408 100644 --- a/tests/contracts/IbexaRectorConfigFactoryTest.php +++ b/tests/contracts/IbexaRectorConfigFactoryTest.php @@ -40,7 +40,7 @@ public static function getSetsForIbexaConfigFactory(): iterable { $expectedSetList = [ // SYMFONY_53 adds this extra set - IbexaSetList::IBEXA_50->value, + IbexaSetList::IBEXA_60->value, SymfonySetList::SYMFONY_50, SymfonySetList::SYMFONY_50_TYPES, SymfonySetList::SYMFONY_51, diff --git a/tests/lib/Sets/Ibexa60/Fixture/cart_money_factory.php.inc b/tests/lib/Sets/Ibexa60/Fixture/cart_money_factory.php.inc new file mode 100644 index 0000000..c46d257 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/cart_money_factory.php.inc @@ -0,0 +1,43 @@ +moneyFactory = $moneyFactory; + } + + public function fooBar(MoneyFactory $moneyFactory): void + { + } +} + +?> +----- +moneyFactory = $moneyFactory; + } + + public function fooBar(IntlMoneyFactory $moneyFactory): void + { + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_draft_is_container.php.inc b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_draft_is_container.php.inc new file mode 100644 index 0000000..cb0b5d7 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_draft_is_container.php.inc @@ -0,0 +1,31 @@ +isContainer]; + } +} + +?> +----- +isContainer()]; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_is_container.php.inc b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_is_container.php.inc new file mode 100644 index 0000000..9460d6c --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_content_type_is_container.php.inc @@ -0,0 +1,31 @@ +isContainer]; + } +} + +?> +----- +isContainer()]; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_contracts_content_type_draft_is_container.php.inc b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_contracts_content_type_draft_is_container.php.inc new file mode 100644 index 0000000..c9c06c4 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/change_property_to_method_contracts_content_type_draft_is_container.php.inc @@ -0,0 +1,31 @@ +isContainer]; + } +} + +?> +----- +isContainer()]; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/fieldtype_page_const.php.inc b/tests/lib/Sets/Ibexa60/Fixture/fieldtype_page_const.php.inc new file mode 100644 index 0000000..db0197c --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/fieldtype_page_const.php.inc @@ -0,0 +1,38 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_class_contracts_deduplicate_stamp.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_class_contracts_deduplicate_stamp.php.inc new file mode 100644 index 0000000..c224fdb --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_class_contracts_deduplicate_stamp.php.inc @@ -0,0 +1,31 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_class_deduplicate_stamp.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_class_deduplicate_stamp.php.inc new file mode 100644 index 0000000..c55110f --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_class_deduplicate_stamp.php.inc @@ -0,0 +1,31 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_class_update_serializer.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_class_update_serializer.php.inc new file mode 100644 index 0000000..9ec7d5c --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_class_update_serializer.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_const_content_type_identifier.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_const_content_type_identifier.php.inc new file mode 100644 index 0000000..f771e07 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_const_content_type_identifier.php.inc @@ -0,0 +1,32 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_const_tree_root.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_const_tree_root.php.inc new file mode 100644 index 0000000..f14cf03 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_const_tree_root.php.inc @@ -0,0 +1,32 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_field_namespace_content_to_common.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_field_namespace_content_to_common.php.inc new file mode 100644 index 0000000..a7c47de --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_field_namespace_content_to_common.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_count.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_count.php.inc new file mode 100644 index 0000000..894eeb9 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_count.php.inc @@ -0,0 +1,31 @@ +count; + } +} + +?> +----- +totalCount; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_spell_suggestion.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_spell_suggestion.php.inc new file mode 100644 index 0000000..1452770 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_property_searchresult_spell_suggestion.php.inc @@ -0,0 +1,31 @@ +spellSuggestion]; + } +} + +?> +----- +spellcheck]; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_relation_const_class.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_relation_const_class.php.inc new file mode 100644 index 0000000..77095f4 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_relation_const_class.php.inc @@ -0,0 +1,32 @@ + +----- +value; + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/rename_variation_interface.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rename_variation_interface.php.inc new file mode 100644 index 0000000..8117606 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rename_variation_interface.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rest_parser.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rest_parser.php.inc new file mode 100644 index 0000000..4d44874 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rest_parser.php.inc @@ -0,0 +1,79 @@ + + +----- + + diff --git a/tests/lib/Sets/Ibexa60/Fixture/rest_rename.php.inc b/tests/lib/Sets/Ibexa60/Fixture/rest_rename.php.inc new file mode 100644 index 0000000..160abb2 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/rest_rename.php.inc @@ -0,0 +1,61 @@ +generateMediaType('name', 'type'); + } + + public function fieldTypeSerializer(): void + { + $serializer = new FieldTypeSerializer(); + + $generator = new Generator(); + $contentType = new ContentType(); + $field = new Field(); + + return $serializer->serializeFieldValue($generator, $contentType, $field); + } +} + +?> +----- +generateMediaTypeWithVendor('name', 'type'); + } + + public function fieldTypeSerializer(): void + { + $serializer = new FieldTypeSerializer(); + + $generator = new Generator(); + $contentType = new ContentType(); + $field = new Field(); + + return $serializer->serializeContentFieldValue($generator, $field); + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/simplified_request_properties.php.inc b/tests/lib/Sets/Ibexa60/Fixture/simplified_request_properties.php.inc new file mode 100644 index 0000000..280efb3 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/simplified_request_properties.php.inc @@ -0,0 +1,21 @@ +pathinfo; + +?> +----- +getPathInfo(); + +?> diff --git a/tests/lib/Sets/Ibexa60/Fixture/some_class.php.inc b/tests/lib/Sets/Ibexa60/Fixture/some_class.php.inc new file mode 100644 index 0000000..eb1453e --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Fixture/some_class.php.inc @@ -0,0 +1,39 @@ +bar(RepositoryConfigurationProvider::class); + } + + public function bar(string $class): RepositoryConfigurationProvider + { + return new $class(); + } +} + +?> +----- +bar(RepositoryConfigurationProviderInterface::class); + } + + public function bar(string $class): RepositoryConfigurationProviderInterface + { + return new $class(); + } +} + +?> diff --git a/tests/lib/Sets/Ibexa60/Ibexa60Test.php b/tests/lib/Sets/Ibexa60/Ibexa60Test.php new file mode 100644 index 0000000..d944ca4 --- /dev/null +++ b/tests/lib/Sets/Ibexa60/Ibexa60Test.php @@ -0,0 +1,19 @@ +sets([IbexaSetList::IBEXA_60->value]); + $rectorConfig->importNames(); +};