Skip to content

Commit c12fed9

Browse files
committed
Revert update to Doctrine ORM 3.2
Because we are not ready to release that yet
1 parent 6e06fb4 commit c12fed9

15 files changed

+1319
-1751
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
},
3838
"require": {
3939
"php": "^8.2",
40-
"doctrine/orm": "^3.2",
40+
"doctrine/orm": "^2.15",
4141
"psr/container": "^1.1 || ^2.0",
42-
"webonyx/graphql-php": "^15.12"
42+
"webonyx/graphql-php": "^15.7"
4343
},
4444
"require-dev": {
4545
"friendsofphp/php-cs-fixer": "@stable",

composer.lock

Lines changed: 1186 additions & 1593 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Cannot call method getMethods\\(\\) on ReflectionClass\\<object\\>\\|null\\.$#"
5-
count: 1
6-
path: src/Factory/AbstractFieldsConfigurationFactory.php
7-
8-
-
9-
message: "#^Parameter \\#1 \\$property of method GraphQL\\\\Doctrine\\\\Factory\\\\AbstractFactory\\:\\:isPropertyExcluded\\(\\) expects ReflectionProperty, ReflectionProperty\\|null given\\.$#"
10-
count: 1
11-
path: src/Factory/Type/FilterGroupConditionTypeFactory.php
12-
13-
-
14-
message: "#^Parameter \\#1 \\$property of method GraphQL\\\\Doctrine\\\\Factory\\\\Type\\\\FilterGroupConditionTypeFactory\\:\\:getLeafType\\(\\) expects ReflectionProperty, ReflectionProperty\\|null given\\.$#"
15-
count: 1
16-
path: src/Factory/Type/FilterGroupConditionTypeFactory.php
17-
18-
-
19-
message: "#^Parameter \\#1 \\$property of method GraphQL\\\\Doctrine\\\\Factory\\\\AbstractFactory\\:\\:isPropertyExcluded\\(\\) expects ReflectionProperty, ReflectionProperty\\|null given\\.$#"
20-
count: 1
21-
path: src/Factory/Type/SortingTypeFactory.php
22-
233
-
244
message: "#^Method GraphQL\\\\Doctrine\\\\Types\\:\\:getOperator\\(\\) should return GraphQL\\\\Doctrine\\\\Definition\\\\Operator\\\\AbstractOperator but returns GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\.$#"
255
count: 1

phpstan.neon.dist

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ parameters:
66
excludePaths:
77
- tests/Blog/Model/*
88
- tests/AttributeBlog/Model/*
9+
checkMissingIterableValueType: false
10+
checkGenericClassInNonGenericObjectType: false
911
ignoreErrors:
1012
- '~^Parameter #2 \$type of static method GraphQL\\Doctrine\\Utils::getOperatorTypeName~'
1113
- '~^Parameter #1 \$method of method GraphQL\\Doctrine\\Factory\\AbstractFieldsConfigurationFactory\:\:getMethodFullName\(\) expects ReflectionMethod, ReflectionFunctionAbstract given\.$~'
@@ -15,10 +17,6 @@ parameters:
1517
- '~^Parameter \#1 \$type of static method GraphQL\\Type\\Definition\\Type\:\:nonNull\(\) expects~'
1618
- '~^Parameter \#1 \$config of class GraphQL\\Type\\Definition\\InputObjectType constructor expects~'
1719
- '~^Parameter \#1 \$config of method GraphQL\\Type\\Definition\\InputObjectType\:\:__construct~'
18-
-
19-
identifier: missingType.iterableValue
20-
-
21-
identifier: missingType.generics
2220

2321
includes:
2422
- phpstan-baseline.neon

src/Definition/Operator/HaveOperatorType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace GraphQL\Doctrine\Definition\Operator;
66

77
use Doctrine\ORM\Mapping\ClassMetadata;
8-
use Doctrine\ORM\Mapping\OneToManyAssociationMapping;
8+
use Doctrine\ORM\Mapping\ClassMetadataInfo;
99
use Doctrine\ORM\QueryBuilder;
1010
use GraphQL\Doctrine\Factory\UniqueNameFactory;
1111
use GraphQL\Type\Definition\LeafType;
@@ -48,12 +48,12 @@ protected function getCollectionValuedDqlCondition(UniqueNameFactory $uniqueName
4848
// use `=`, and not `IN()`). So we simulate an approximation of MEMBER OF that support multiple values. But it
4949
// does **not** support composite identifiers. And that is fine because it is an official limitation of this
5050
// library anyway.
51-
if ($association instanceof OneToManyAssociationMapping) {
51+
if ($association['type'] === ClassMetadataInfo::ONE_TO_MANY) {
5252
$id = $metadata->identifier[0];
5353

54-
$otherClassName = $association->targetEntity;
54+
$otherClassName = $association['targetEntity'];
5555
$otherAlias = $uniqueNameFactory->createAliasName($otherClassName);
56-
$otherField = $association->mappedBy;
56+
$otherField = $association['mappedBy'];
5757
$otherMetadata = $queryBuilder->getEntityManager()->getClassMetadata($otherClassName);
5858
$otherId = $otherMetadata->identifier[0];
5959

src/Factory/AbstractFieldsConfigurationFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ private function findIdentityField(string $className): void
147147
{
148148
$this->metadata = $this->entityManager->getClassMetadata($className);
149149
foreach ($this->metadata->fieldMappings as $meta) {
150-
if ($meta->id ?? false) {
151-
$this->identityField = $meta->fieldName;
150+
if ($meta['id'] ?? false) {
151+
$this->identityField = $meta['fieldName'];
152152
}
153153
}
154154
}
@@ -184,7 +184,7 @@ final protected function isIdentityField(string $fieldName): bool
184184
*/
185185
private function getTargetEntity(string $fieldName): ?string
186186
{
187-
return $this->metadata->associationMappings[$fieldName]->targetEntity ?? null;
187+
return $this->metadata->associationMappings[$fieldName]['targetEntity'] ?? null;
188188
}
189189

190190
/**

src/Factory/FilteredQueryBuilderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function applyJoins(ClassMetadata $metadata, array $joins, string $alias
127127
$joinedAlias = $this->createJoin($alias, $field, $join['type']);
128128

129129
if (isset($join['joins']) || isset($join['conditions'])) {
130-
$targetClassName = $metadata->getAssociationMapping($field)->targetEntity;
130+
$targetClassName = $metadata->getAssociationMapping($field)['targetEntity'];
131131
$targetMetadata = $this->entityManager->getClassMetadata($targetClassName);
132132
$type = $this->types->getFilterGroupCondition($targetClassName);
133133
$this->applyJoinsAndFilters($targetMetadata, $joinedAlias, $type, $join['joins'] ?? [], $join['conditions'] ?? []);

src/Factory/Type/FilterGroupConditionTypeFactory.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace GraphQL\Doctrine\Factory\Type;
66

7-
use Doctrine\ORM\Mapping\FieldMapping;
87
use GraphQL\Doctrine\Attribute\Filter;
98
use GraphQL\Doctrine\Attribute\FilterGroupCondition;
109
use GraphQL\Doctrine\Definition\Operator\AbstractOperator;
@@ -61,7 +60,7 @@ public function create(string $className, string $typeName): InputObjectType
6160

6261
// Get all scalar fields
6362
foreach ($metadata->fieldMappings as $mapping) {
64-
$fieldName = $mapping->fieldName;
63+
$fieldName = $mapping['fieldName'];
6564
$property = $metadata->getReflectionProperty($fieldName);
6665

6766
// Skip exclusion specified by user
@@ -77,7 +76,7 @@ public function create(string $className, string $typeName): InputObjectType
7776

7877
// Get all collection fields
7978
foreach ($metadata->associationMappings as $mapping) {
80-
$fieldName = $mapping->fieldName;
79+
$fieldName = $mapping['fieldName'];
8180
$operators = $this->getOperators($fieldName, Type::id(), true, $metadata->isCollectionValuedAssociation($fieldName));
8281

8382
$filters[] = $this->getFieldConfiguration($typeName, $fieldName, $operators);
@@ -106,9 +105,9 @@ public function create(string $className, string $typeName): InputObjectType
106105
/**
107106
* Read the type of the filterGroupCondition, either from Doctrine mapping type, or the override via attribute.
108107
*/
109-
private function getLeafType(ReflectionProperty $property, FieldMapping $mapping): LeafType
108+
private function getLeafType(ReflectionProperty $property, array $mapping): LeafType
110109
{
111-
if ($mapping->id ?? false) {
110+
if ($mapping['id'] ?? false) {
112111
return Type::id();
113112
}
114113

@@ -128,7 +127,7 @@ private function getLeafType(ReflectionProperty $property, FieldMapping $mapping
128127
}
129128

130129
/** @var LeafType $leafType */
131-
$leafType = $this->types->get($mapping->type);
130+
$leafType = $this->types->get($mapping['type']);
132131

133132
return $leafType;
134133
}

src/Factory/Type/FilterGroupJoinTypeFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ private function getJoinsFields(string $className): array
6060
$associations = $this->entityManager->getClassMetadata($className)->associationMappings;
6161
foreach ($associations as $association) {
6262
$field = [
63-
'name' => $association->fieldName,
64-
'type' => $this->types->getJoinOn($association->targetEntity),
63+
'name' => $association['fieldName'],
64+
'type' => $this->types->getJoinOn($association['targetEntity']),
6565
];
6666

6767
$fields[] = $field;

tests/Blog/Filtering/SearchOperatorType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ private function getSearchableFields(ClassMetadata $metadata, string $alias): ar
6565
$fields = [];
6666
$textType = ['string', 'text'];
6767
foreach ($metadata->fieldMappings as $g) {
68-
if (in_array($g->type, $textType, true)) {
69-
$fields[] = $alias . '.' . $g->fieldName;
68+
if (in_array($g['type'], $textType, true)) {
69+
$fields[] = $alias . '.' . $g['fieldName'];
7070
}
7171
}
7272

tests/EntityManagerTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ trait EntityManagerTrait
1818
private function setUpEntityManager(): void
1919
{
2020
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/Blog/Model'], true);
21-
$connection = DriverManager::getConnection([
22-
'driver' => 'sqlite3',
23-
'memory' => true,
24-
]);
21+
$connection = DriverManager::getConnection(['url' => 'sqlite:///:memory:']);
2522

2623
$this->entityManager = new EntityManager($connection, $config);
2724
}

tests/TypesTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use GraphQLTests\Doctrine\Blog\Types\CustomType;
1616
use GraphQLTests\Doctrine\Blog\Types\DateTimeType;
1717
use GraphQLTests\Doctrine\Blog\Types\PostStatusType;
18-
use PHPUnit\Framework\Attributes\DataProvider;
1918
use PHPUnit\Framework\TestCase;
2019
use stdClass;
2120

@@ -158,7 +157,9 @@ public function testHas(): void
158157
self::assertTrue($this->types->has('customName'), 'should have custom registered type by its name, even if custom key was different, once type is created');
159158
}
160159

161-
#[DataProvider('provideLoadType')]
160+
/**
161+
* @dataProvider provideLoadType
162+
*/
162163
public function testLoadType(string $typeName): void
163164
{
164165
$type = $this->types->loadType($typeName, 'GraphQLTests\Doctrine\Blog\Model');

0 commit comments

Comments
 (0)