Skip to content

Commit b3cae36

Browse files
authored
Merge pull request #848 from meyerbaptiste/remove_deadcode
Remove dead code to fix SensioLabs Insight
2 parents 16dd932 + 9d9e553 commit b3cae36

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
1515
use ApiPlatform\Core\Exception\RuntimeException;
1616
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
17-
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
1817
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
1918
use Doctrine\ORM\Mapping\ClassMetadataInfo;
2019
use Doctrine\ORM\QueryBuilder;
@@ -29,16 +28,14 @@
2928
*/
3029
final class EagerLoadingExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
3130
{
32-
private $propertyNameCollectionFactory;
3331
private $propertyMetadataFactory;
3432
private $resourceMetadataFactory;
3533
private $maxJoins;
3634
private $forceEager;
3735

38-
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, int $maxJoins = 30, bool $forceEager = true)
36+
public function __construct(PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, int $maxJoins = 30, bool $forceEager = true)
3937
{
4038
$this->propertyMetadataFactory = $propertyMetadataFactory;
41-
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
4239
$this->resourceMetadataFactory = $resourceMetadataFactory;
4340
$this->maxJoins = $maxJoins;
4441
$this->forceEager = $forceEager;

src/Bridge/Symfony/Bundle/Resources/config/doctrine_orm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
<!-- Doctrine Query extensions -->
8989

9090
<service id="api_platform.doctrine.orm.query_extension.eager_loading" class="ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension" public="false">
91-
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
9291
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
9392
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
9493
<argument>%api_platform.eager_loading.max_joins%</argument>

tests/Bridge/Doctrine/Orm/Extension/EagerLoadingExtensionTest.php

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension;
1515
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;
1616
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
17-
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
1817
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
1918
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
2019
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
@@ -37,8 +36,6 @@ public function testApplyToCollection()
3736
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
3837
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
3938

40-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
41-
4239
$relationPropertyMetadata = new PropertyMetadata();
4340
$relationPropertyMetadata = $relationPropertyMetadata->withReadableLink(true);
4441

@@ -64,7 +61,7 @@ public function testApplyToCollection()
6461
$queryBuilderProphecy->innerJoin('o.relatedDummy2', 'a11')->shouldBeCalled(1);
6562
$queryBuilderProphecy->getEntityManager()->shouldBeCalled(2)->willReturn($emProphecy->reveal());
6663

67-
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
64+
$eagerExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
6865
$eagerExtensionTest->applyToCollection($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class);
6966
}
7067

@@ -73,8 +70,6 @@ public function testApplyToItem()
7370
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
7471
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
7572

76-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
77-
7873
$relationPropertyMetadata = new PropertyMetadata();
7974
$relationPropertyMetadata = $relationPropertyMetadata->withReadableLink(true);
8075

@@ -116,7 +111,7 @@ public function testApplyToItem()
116111
$queryBuilderProphecy->leftJoin('o.relatedDummy4', 'a11233')->shouldBeCalled(1);
117112
$queryBuilderProphecy->getEntityManager()->shouldBeCalled(2)->willReturn($emProphecy->reveal());
118113

119-
$orderExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
114+
$orderExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
120115
$orderExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class, []);
121116
}
122117

@@ -125,8 +120,6 @@ public function testCreateItemWithOperationName()
125120
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
126121
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
127122

128-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
129-
130123
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
131124
$propertyMetadataFactoryProphecy->create(Dummy::class, 'foo', ['item_operation_name' => 'item_operation'])->shouldBeCalled()->willReturn(new PropertyMetadata());
132125

@@ -141,7 +134,7 @@ public function testCreateItemWithOperationName()
141134
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
142135
$queryBuilderProphecy->getEntityManager()->shouldBeCalled()->willReturn($emProphecy);
143136

144-
$orderExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
137+
$orderExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
145138
$orderExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class, [], 'item_operation');
146139
}
147140

@@ -150,8 +143,6 @@ public function testCreateCollectionWithOperationName()
150143
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
151144
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
152145

153-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
154-
155146
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
156147
$propertyMetadataFactoryProphecy->create(Dummy::class, 'foo', ['collection_operation_name' => 'collection_operation'])->shouldBeCalled()->willReturn(new PropertyMetadata());
157148

@@ -166,7 +157,7 @@ public function testCreateCollectionWithOperationName()
166157
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
167158
$queryBuilderProphecy->getEntityManager()->shouldBeCalled()->willReturn($emProphecy);
168159

169-
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
160+
$eagerExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
170161
$eagerExtensionTest->applyToCollection($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class, 'collection_operation');
171162
}
172163

@@ -177,8 +168,6 @@ public function testDenormalizeItemWithCorrectResourceClass()
177168
$resourceMetadataFactoryProphecy->create(RelatedDummy::class)->willReturn(new ResourceMetadata())->shouldBeCalled();
178169
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata())->shouldBeCalled();
179170

180-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
181-
182171
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
183172

184173
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);
@@ -190,7 +179,7 @@ public function testDenormalizeItemWithCorrectResourceClass()
190179
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
191180
$queryBuilderProphecy->getEntityManager()->shouldBeCalled()->willReturn($emProphecy);
192181

193-
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
182+
$eagerExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
194183
$eagerExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), RelatedDummy::class, ['id' => 1], 'item_operation', ['resource_class' => Dummy::class]);
195184
}
196185

@@ -201,8 +190,6 @@ public function testDenormalizeItemWithExistingGroups()
201190
$resourceMetadataFactoryProphecy->create(RelatedDummy::class)->willReturn(new ResourceMetadata())->shouldBeCalled();
202191
$resourceMetadataFactoryProphecy->create(Dummy::class)->shouldNotBeCalled();
203192

204-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
205-
206193
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
207194

208195
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);
@@ -214,7 +201,7 @@ public function testDenormalizeItemWithExistingGroups()
214201
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
215202
$queryBuilderProphecy->getEntityManager()->shouldBeCalled()->willReturn($emProphecy);
216203

217-
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
204+
$eagerExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
218205
$eagerExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), RelatedDummy::class, ['id' => 1], 'item_operation', ['groups' => 'some_groups']);
219206
}
220207

@@ -227,8 +214,6 @@ public function testMaxDepthReached()
227214
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
228215
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
229216

230-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
231-
232217
$relationPropertyMetadata = new PropertyMetadata();
233218
$relationPropertyMetadata = $relationPropertyMetadata->withReadableLink(true);
234219

@@ -257,7 +242,7 @@ public function testMaxDepthReached()
257242
$queryBuilderProphecy->getEntityManager()->willReturn($emProphecy->reveal());
258243
$queryBuilderProphecy->innerJoin(Argument::type('string'), Argument::type('string'))->shouldBeCalled();
259244

260-
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
245+
$eagerExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false);
261246
$eagerExtensionTest->applyToCollection($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class);
262247
}
263248

@@ -266,8 +251,6 @@ public function testForceEager()
266251
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
267252
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata());
268253

269-
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
270-
271254
$relationPropertyMetadata = new PropertyMetadata();
272255
$relationPropertyMetadata = $relationPropertyMetadata->withReadableLink(true);
273256

@@ -290,7 +273,7 @@ public function testForceEager()
290273
$queryBuilderProphecy->innerJoin('o.relation', 'a0')->shouldBeCalled(1);
291274
$queryBuilderProphecy->getEntityManager()->shouldBeCalled(2)->willReturn($emProphecy->reveal());
292275

293-
$orderExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, true);
276+
$orderExtensionTest = new EagerLoadingExtension($propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, true);
294277
$orderExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), Dummy::class, []);
295278
}
296279
}

0 commit comments

Comments
 (0)