Skip to content

Commit

Permalink
kick of DoctrineSetProvider (#319)
Browse files Browse the repository at this point in the history
* kick of DoctrineSetProvider

* [rector] Rector fixes

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
TomasVotruba and actions-user authored Jun 24, 2024
1 parent e5736dd commit 9deae28
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Doctrine\CodeQuality\Rector\Class_;

use PhpParser\Node\Attribute;
use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -102,13 +103,13 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node

$property = $this->methodUniqueReturnedPropertyResolver->resolve($node, $classMethod);

if ($property === null) {
if (!$property instanceof Property) {
continue;
}

$collectionObjectType = $this->getCollectionObjectTypeFromToManyAttribute($property);

if ($collectionObjectType === null) {
if (!$collectionObjectType instanceof FullyQualifiedObjectType) {
return null;
}

Expand Down Expand Up @@ -153,6 +154,6 @@ private function isDoctrineEntityClass(Class_ $class): bool
['Doctrine\ORM\Mapping\Entity', 'Doctrine\ORM\Mapping\Embeddable'],
);

return $entityAttribute !== null;
return $entityAttribute instanceof Attribute;
}
}
66 changes: 63 additions & 3 deletions src/Set/SetProvider/DoctrineSetProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use Rector\Set\Contract\SetInterface;
use Rector\Set\Contract\SetProviderInterface;
use Rector\Set\Enum\SetGroup;
use Rector\Set\ValueObject\ComposerTriggeredSet;
use Rector\Set\ValueObject\Set;

/**
* @api collected in core
Expand All @@ -19,13 +21,71 @@ final class DoctrineSetProvider implements SetProviderInterface
public function provide(): array
{
return [
new Set(SetGroup::DOCTRINE, 'Code Quality', __DIR__ . '/../../../config/sets/doctrine-code-quality.php'),
new ComposerTriggeredSet(
'doctrine',
SetGroup::DOCTRINE,
'doctrine/common',
'2.10',
'2.0',
__DIR__ . '/../../../config/sets/doctrine-common-20.php'
),
// @todo fill rest
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/collection',
'2.2',
__DIR__ . '/../../../config/sets/doctrine-collection-22.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/doctrine-bundle',
'2.10',
__DIR__ . '/../../../config/sets/doctrine-bundle-210.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/dbal',
'3.0',
__DIR__ . '/../../../config/sets/doctrine-dbal-30.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/dbal',
'4.0',
__DIR__ . '/../../../config/sets/doctrine-dbal-40.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/dbal',
'2.10',
__DIR__ . '/../../../config/sets/doctrine-dbal-210.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/dbal',
'2.11',
__DIR__ . '/../../../config/sets/doctrine-dbal-211.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/orm',
'2.5',
__DIR__ . '/../../../config/sets/doctrine-orm-25.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/orm',
'2.13',
__DIR__ . '/../../../config/sets/doctrine-orm-213.php',
),
new ComposerTriggeredSet(
SetGroup::DOCTRINE,
'doctrine/orm',
'2.14',
__DIR__ . '/../../../config/sets/doctrine-orm-214.php',
),

new Set(SetGroup::ATTRIBUTES, 'Doctrine Attributes', __DIR__ . '/../../../config/sets/attributes/doctrine.php'),
new Set(SetGroup::ATTRIBUTES, 'Doctrine Attributes', __DIR__ . '/../../../config/sets/attributes/gedmo.php'),
new Set(SetGroup::ATTRIBUTES, 'Doctrine Attributes', __DIR__ . '/../../../config/sets/attributes/mongodb.php'),
];
}
}

0 comments on commit 9deae28

Please sign in to comment.