Skip to content

Commit

Permalink
feat: add entity name to entity extension
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 27, 2025
1 parent 40e9bcc commit 5939cf9
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 132 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"rector/rector": "~2.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.57",
"phpunit/phpunit": "^9.5",
"symplify/easy-coding-standard": "~11.2",
"friendsofphp/php-cs-fixer": "^3.57"
"symplify/easy-coding-standard": "~11.2"
},
"conflict": {
"rector/rector": "<2.0"
Expand Down
166 changes: 81 additions & 85 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions config/shopware-6.6.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Frosh\Rector\Rule\v67\AddEntityNameToEntityExtension;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonySetList;
Expand All @@ -16,6 +17,10 @@
LevelSetList::UP_TO_PHP_82,
]);

$rectorConfig->ruleWithConfiguration(AddEntityNameToEntityExtension::class, [
'backwardsCompatible' => true,
]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
};
8 changes: 8 additions & 0 deletions config/shopware-6.7.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

declare(strict_types=1);

use Frosh\Rector\Rule\v67\AddEntityNameToEntityExtension;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/v6.7/renaming.php');

$rectorConfig->ruleWithConfiguration(AddEntityNameToEntityExtension::class, [
'backwardsCompatible' => false,
]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
};
18 changes: 9 additions & 9 deletions config/v6.5/flysystem-v3.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
$rectorConfig->ruleWithConfiguration(
RenameClassRector::class,
[
'League\\Flysystem\\FilesystemInterface' => 'League\\Flysystem\\FilesystemOperator',
'League\\Flysystem\\AdapterInterface' => 'League\\Flysystem\\FilesystemAdapter',
'League\\Flysystem\\Memory\\MemoryAdapter' => 'League\\Flysystem\\InMemory\\InMemoryFilesystemAdapter',
'League\Flysystem\FilesystemInterface' => 'League\Flysystem\FilesystemOperator',
'League\Flysystem\AdapterInterface' => 'League\Flysystem\FilesystemAdapter',
'League\Flysystem\Memory\MemoryAdapter' => 'League\Flysystem\InMemory\InMemoryFilesystemAdapter',
],
);

$methodRenaming = [];
$classConstRenaming = [];

$filesystemClasses = [
'League\\Flysystem\\FilesystemOperator',
'League\\Flysystem\\Filesystem',
'League\\Flysystem\\FilesystemInterface',
'League\\Flysystem\\FilesystemAdapter',
'League\Flysystem\FilesystemOperator',
'League\Flysystem\Filesystem',
'League\Flysystem\FilesystemInterface',
'League\Flysystem\FilesystemAdapter',
];
foreach ($filesystemClasses as $class) {
$methodRenaming += [
Expand All @@ -49,8 +49,8 @@
new MethodCallRename($class, 'getVisibility', 'visibility'),
];

$classConstRenaming[] = new RenameClassAndConstFetch($class, 'VISIBILITY_PUBLIC', 'League\\Flysystem\\Visibility', 'PUBLIC');
$classConstRenaming[] = new RenameClassAndConstFetch($class, 'VISIBILITY_PRIVATE', 'League\\Flysystem\\Visibility', 'PRIVATE');
$classConstRenaming[] = new RenameClassAndConstFetch($class, 'VISIBILITY_PUBLIC', 'League\Flysystem\Visibility', 'PUBLIC');
$classConstRenaming[] = new RenameClassAndConstFetch($class, 'VISIBILITY_PRIVATE', 'League\Flysystem\Visibility', 'PRIVATE');
}

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, $methodRenaming);
Expand Down
32 changes: 16 additions & 16 deletions config/v6.5/renaming.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$rectorConfig->ruleWithConfiguration(
RenameMethodRector::class,
[
new MethodCallRename('Shopware\\Core\\Framework\\Adapter\\Twig\\EntityTemplateLoader', 'clearInternalCache', 'reset'),
new MethodCallRename('Shopware\Core\Framework\Adapter\Twig\EntityTemplateLoader', 'clearInternalCache', 'reset'),
new MethodCallRename('Shopware\Core\Content\ImportExport\Processing\Mapping\Mapping', 'getDefault', 'getDefaultValue'),
new MethodCallRename('Shopware\Core\Content\ImportExport\Processing\Mapping\Mapping', 'getMappedDefault', 'getDefaultValue'),
],
Expand All @@ -35,33 +35,33 @@
$rectorConfig->ruleWithConfiguration(
RenameClassRector::class,
[
'Shopware\\Core\\Framework\\Adapter\\Asset\\ThemeAssetPackage' => 'Shopware\\Storefront\\Theme\\ThemeAssetPackage',
'Maltyxx\\ImagesGenerator\\ImagesGeneratorProvider' => 'bheller\\ImagesGenerator\\ImagesGeneratorProvider',
'Shopware\\Core\\Framework\\Event\\BusinessEventInterface' => 'Shopware\\Core\\Framework\\Event\\FlowEventAware',
'Shopware\\Core\\Framework\\Event\\MailActionInterface' => 'Shopware\\Core\\Framework\\Event\\MailAware',
'Shopware\\Core\\Framework\\Log\\LogAwareBusinessEventInterface' => 'Shopware\\Core\\Framework\\Log\\LogAware',
'Shopware\\Storefront\\Event\\ProductExportContentTypeEvent' => 'Shopware\\Core\\Content\\ProductExport\\Event\\ProductExportContentTypeEvent',
'Shopware\\Storefront\\Page\\Product\\Review\\MatrixElement' => 'Shopware\\Core\\Content\\Product\\SalesChannel\\Review\\MatrixElement',
'Shopware\\Storefront\\Page\\Product\\Review\\RatingMatrix' => 'Shopware\\Core\\Content\\Product\\SalesChannel\\Review\\RatingMatrix',
'Shopware\\Storefront\\Page\\Address\\Listing\\AddressListingCriteriaEvent' => 'Shopware\\Core\\Checkout\\Customer\\Event\\AddressListingCriteriaEvent',
'Shopware\\Administration\\Service\\AdminOrderCartService' => 'Shopware\\Core\\Checkout\\Cart\\ApiOrderCartService',
'Shopware\\Core\\System\\User\\Service\\UserProvisioner' => 'Shopware\\Core\\Maintenance\\User\\Service\\UserProvisioner',
'Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepositoryInterface' => 'Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository',
'Shopware\\Core\\System\\SalesChannel\\Entity\\SalesChannelRepositoryInterface' => 'Shopware\\Core\\System\\SalesChannel\\Entity\\SalesChannelRepository',
'Shopware\Core\Framework\Adapter\Asset\ThemeAssetPackage' => 'Shopware\Storefront\Theme\ThemeAssetPackage',
'Maltyxx\ImagesGenerator\ImagesGeneratorProvider' => 'bheller\ImagesGenerator\ImagesGeneratorProvider',
'Shopware\Core\Framework\Event\BusinessEventInterface' => 'Shopware\Core\Framework\Event\FlowEventAware',
'Shopware\Core\Framework\Event\MailActionInterface' => 'Shopware\Core\Framework\Event\MailAware',
'Shopware\Core\Framework\Log\LogAwareBusinessEventInterface' => 'Shopware\Core\Framework\Log\LogAware',
'Shopware\Storefront\Event\ProductExportContentTypeEvent' => 'Shopware\Core\Content\ProductExport\Event\ProductExportContentTypeEvent',
'Shopware\Storefront\Page\Product\Review\MatrixElement' => 'Shopware\Core\Content\Product\SalesChannel\Review\MatrixElement',
'Shopware\Storefront\Page\Product\Review\RatingMatrix' => 'Shopware\Core\Content\Product\SalesChannel\Review\RatingMatrix',
'Shopware\Storefront\Page\Address\Listing\AddressListingCriteriaEvent' => 'Shopware\Core\Checkout\Customer\Event\AddressListingCriteriaEvent',
'Shopware\Administration\Service\AdminOrderCartService' => 'Shopware\Core\Checkout\Cart\ApiOrderCartService',
'Shopware\Core\System\User\Service\UserProvisioner' => 'Shopware\Core\Maintenance\User\Service\UserProvisioner',
'Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface' => 'Shopware\Core\Framework\DataAbstractionLayer\EntityRepository',
'Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface' => 'Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository',
],
);

$rectorConfig->ruleWithConfiguration(
RemoveMethodCallParamRector::class,
[
new RemoveMethodCallParam('Shopware\\Core\\Checkout\\Cart\\Tax\\Struct\\CalculatedTaxCollection', 'merge', 1),
new RemoveMethodCallParam('Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection', 'merge', 1),
],
);

$rectorConfig->ruleWithConfiguration(
RemoveArgumentFromClassConstructRector::class,
[
new RemoveArgumentFromClassConstruct('Shopware\\Core\\Checkout\\Customer\\Exception\\DuplicateWishlistProductException', 0),
new RemoveArgumentFromClassConstruct('Shopware\Core\Checkout\Customer\Exception\DuplicateWishlistProductException', 0),
new RemoveArgumentFromClassConstruct('Shopware\Core\Content\Newsletter\Exception\LanguageOfNewsletterDeleteException', 0),
new RemoveArgumentFromClassConstruct('Shopware\Core\Content\Product\Events\ProductIndexerEvent', 1),
new RemoveArgumentFromClassConstruct('Shopware\Core\Content\Product\Events\ProductIndexerEvent', 2),
Expand Down
8 changes: 4 additions & 4 deletions config/v6.5/typehints.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
new AddParamTypeDeclaration('Shopware\Core\Content\LandingPage\DataAbstractionLayer\LandingPageIndexer', 'iterate', 0, new ArrayType(new StringType(), new StringType())),
new AddParamTypeDeclaration('Shopware\Core\Content\ProductStream\DataAbstractionLayer\ProductStreamIndexer', 'iterate', 0, new ArrayType(new StringType(), new StringType())),
new AddParamTypeDeclaration('Shopware\Core\Content\Rule\DataAbstractionLayer\RuleIndexer', 'iterate', 0, new ArrayType(new StringType(), new StringType())),
new AddParamTypeDeclaration('Shopware\\Storefront\\Page\\Product\\Review\\ReviewLoaderResult', 'setMatrix', 0, new ObjectType('Shopware\Core\Content\Product\SalesChannel\Review\RatingMatrix')),
new AddParamTypeDeclaration('Shopware\Storefront\Page\Product\Review\ReviewLoaderResult', 'setMatrix', 0, new ObjectType('Shopware\Core\Content\Product\SalesChannel\Review\RatingMatrix')),
],
);

$rectorConfig->ruleWithConfiguration(
AddReturnTypeDeclarationRector::class,
[
new AddReturnTypeDeclaration('Shopware\\Core\\Framework\\Adapter\\Twig\\TemplateIterator', 'getIterator', new ObjectType('Traversable')),
new AddReturnTypeDeclaration('Shopware\Core\Framework\Adapter\Twig\TemplateIterator', 'getIterator', new ObjectType('Traversable')),
new AddReturnTypeDeclaration('Shopware\Core\Content\Cms\DataResolver\CriteriaCollection', 'getIterator', new ObjectType('Traversable')),
new AddReturnTypeDeclaration('Shopware\\Core\\Checkout\\Cart\\CartBehavior', 'hasPermission', new BooleanType()),
new AddReturnTypeDeclaration('Shopware\\Storefront\\Page\\Product\\Review\\ReviewLoaderResult', 'getMatrix', new ObjectType('Shopware\Core\Content\Product\SalesChannel\Review\RatingMatrix')),
new AddReturnTypeDeclaration('Shopware\Core\Checkout\Cart\CartBehavior', 'hasPermission', new BooleanType()),
new AddReturnTypeDeclaration('Shopware\Storefront\Page\Product\Review\ReviewLoaderResult', 'getMatrix', new ObjectType('Shopware\Core\Content\Product\SalesChannel\Review\RatingMatrix')),
],
);

Expand Down
14 changes: 7 additions & 7 deletions config/v6.6/renaming.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
$rectorConfig->ruleWithConfiguration(
RenameClassRector::class,
[
'Shopware\\Core\\Framework\\DataAbstractionLayer\\Event\\BeforeDeleteEvent' => 'Shopware\\Core\\Framework\\DataAbstractionLayer\\Event\\EntityDeleteEvent',
'Shopware\Core\Framework\DataAbstractionLayer\Event\BeforeDeleteEvent' => 'Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeleteEvent',
],
);

$rectorConfig->ruleWithConfiguration(
RenameClassConstFetchRector::class,
[
new RenameClassAndConstFetch('Shopware\\Core\\Checkout\\Cart', 'CHECKOUT_ORDER_PLACED', 'Shopware\\Core\\Framework\\Event\\BusinessEvents', 'CHECKOUT_ORDER_PLACED'),
new RenameClassAndConstFetch('Shopware\\Elasticsearch\\Product\\ElasticsearchProductDefinition', 'KEYWORD_FIELD', 'Shopware\\Elasticsearch\\Framework\\AbstractElasticsearchDefinition', 'KEYWORD_FIELD'),
new RenameClassAndConstFetch('Shopware\\Elasticsearch\\Product\\ElasticsearchProductDefinition', 'BOOLEAN_FIELD', 'Shopware\\Elasticsearch\\Framework\\AbstractElasticsearchDefinition', 'BOOLEAN_FIELD'),
new RenameClassAndConstFetch('Shopware\\Elasticsearch\\Product\\ElasticsearchProductDefinition', 'FLOAT_FIELD', 'Shopware\\Elasticsearch\\Framework\\AbstractElasticsearchDefinition', 'FLOAT_FIELD'),
new RenameClassAndConstFetch('Shopware\\Elasticsearch\\Product\\ElasticsearchProductDefinition', 'INT_FIELD', 'Shopware\\Elasticsearch\\Framework\\AbstractElasticsearchDefinition', 'INT_FIELD'),
new RenameClassAndConstFetch('Shopware\\Elasticsearch\\Product\\ElasticsearchProductDefinition', 'SEARCH_FIELD', 'Shopware\\Elasticsearch\\Framework\\AbstractElasticsearchDefinition', 'SEARCH_FIELD'),
new RenameClassAndConstFetch('Shopware\Core\Checkout\Cart', 'CHECKOUT_ORDER_PLACED', 'Shopware\Core\Framework\Event\BusinessEvents', 'CHECKOUT_ORDER_PLACED'),
new RenameClassAndConstFetch('Shopware\Elasticsearch\Product\ElasticsearchProductDefinition', 'KEYWORD_FIELD', 'Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition', 'KEYWORD_FIELD'),
new RenameClassAndConstFetch('Shopware\Elasticsearch\Product\ElasticsearchProductDefinition', 'BOOLEAN_FIELD', 'Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition', 'BOOLEAN_FIELD'),
new RenameClassAndConstFetch('Shopware\Elasticsearch\Product\ElasticsearchProductDefinition', 'FLOAT_FIELD', 'Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition', 'FLOAT_FIELD'),
new RenameClassAndConstFetch('Shopware\Elasticsearch\Product\ElasticsearchProductDefinition', 'INT_FIELD', 'Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition', 'INT_FIELD'),
new RenameClassAndConstFetch('Shopware\Elasticsearch\Product\ElasticsearchProductDefinition', 'SEARCH_FIELD', 'Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition', 'SEARCH_FIELD'),
],
);
};
16 changes: 8 additions & 8 deletions config/v6.7/renaming.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
$rectorConfig->ruleWithConfiguration(
RenameClassConstFetchRector::class,
[
new RenameClassAndConstFetch('Shopware\\Core\\Content\\MailTemplate\\Subscriber\\MailSendSubscriberConfig', 'MAIL_CONFIG_EXTENSION', 'Shopware\\Core\\Content\\Flow\\Dispatching\\Action\\SendMailAction', 'MAIL_CONFIG_EXTENSION'),
new RenameClassAndConstFetch('Shopware\\Core\\Content\\MailTemplate\\Subscriber\\MailSendSubscriberConfig', 'ACTION_NAME', 'Shopware\\Core\\Content\\Flow\\Dispatching\\Action\\SendMailAction', 'ACTION_NAME'),
new RenameClassAndConstFetch('Shopware\Core\Content\MailTemplate\Subscriber\MailSendSubscriberConfig', 'MAIL_CONFIG_EXTENSION', 'Shopware\Core\Content\Flow\Dispatching\Action\SendMailAction', 'MAIL_CONFIG_EXTENSION'),
new RenameClassAndConstFetch('Shopware\Core\Content\MailTemplate\Subscriber\MailSendSubscriberConfig', 'ACTION_NAME', 'Shopware\Core\Content\Flow\Dispatching\Action\SendMailAction', 'ACTION_NAME'),

new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'STATE_LOGGED_IN', 'Shopware\\Core\\Framework\\Adapter\\Cache\\CacheStateSubscriber', 'STATE_LOGGED_IN'),
new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'STATE_CART_FILLED', 'Shopware\\Core\\Framework\\Adapter\\Cache\\CacheStateSubscriber', 'STATE_CART_FILLED'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'STATE_LOGGED_IN', 'Shopware\Core\Framework\Adapter\Cache\CacheStateSubscriber', 'STATE_LOGGED_IN'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'STATE_CART_FILLED', 'Shopware\Core\Framework\Adapter\Cache\CacheStateSubscriber', 'STATE_CART_FILLED'),

new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'CURRENCY_COOKIE', 'Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\HttpCacheKeyGenerator', 'CURRENCY_COOKIE'),
new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'CONTEXT_CACHE_COOKIE', 'Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\HttpCacheKeyGenerator', 'CONTEXT_CACHE_COOKIE'),
new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'SYSTEM_STATE_COOKIE', 'Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\HttpCacheKeyGenerator', 'SYSTEM_STATE_COOKIE'),
new RenameClassAndConstFetch('Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\CacheResponseSubscriber', 'INVALIDATION_STATES_HEADER', 'Shopware\\Core\\Framework\\Adapter\\Cache\\Http\\HttpCacheKeyGenerator', 'INVALIDATION_STATES_HEADER'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'CURRENCY_COOKIE', 'Shopware\Core\Framework\Adapter\Cache\Http\HttpCacheKeyGenerator', 'CURRENCY_COOKIE'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'CONTEXT_CACHE_COOKIE', 'Shopware\Core\Framework\Adapter\Cache\Http\HttpCacheKeyGenerator', 'CONTEXT_CACHE_COOKIE'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'SYSTEM_STATE_COOKIE', 'Shopware\Core\Framework\Adapter\Cache\Http\HttpCacheKeyGenerator', 'SYSTEM_STATE_COOKIE'),
new RenameClassAndConstFetch('Shopware\Core\Framework\Adapter\Cache\Http\CacheResponseSubscriber', 'INVALIDATION_STATES_HEADER', 'Shopware\Core\Framework\Adapter\Cache\Http\HttpCacheKeyGenerator', 'INVALIDATION_STATES_HEADER'),
],
);
};
2 changes: 1 addition & 1 deletion src/Rule/v65/AddBanAllToReverseProxyRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node)
{
if (!$this->isObjectType($node, new ObjectType('Shopware\\Storefront\\Framework\\Cache\\ReverseProxy\\AbstractReverseProxyGateway'))) {
if (!$this->isObjectType($node, new ObjectType('Shopware\Storefront\Framework\Cache\ReverseProxy\AbstractReverseProxyGateway'))) {
return null;
}

Expand Down
Loading

0 comments on commit 5939cf9

Please sign in to comment.