Skip to content

Commit 440b80f

Browse files
authored
chore: php-cs-fixer update (#5118)
* chore: php-cs-fixer update * chore: php-cs-fixer update
1 parent b31504a commit 440b80f

File tree

18 files changed

+62
-83
lines changed

18 files changed

+62
-83
lines changed

src/Core/Bridge/Doctrine/MongoDbOdm/Extension/OrderExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Doctrine\ODM\MongoDB\Aggregation\Builder;
2020
use Doctrine\ODM\MongoDB\Aggregation\Stage\Sort;
2121
use Doctrine\Persistence\ManagerRegistry;
22-
use OutOfRangeException;
2322

2423
/**
2524
* Applies selected ordering while querying resource collection.
@@ -110,7 +109,7 @@ private function hasSortStage(Builder $aggregationBuilder): bool
110109
// If at least one stage is sort, then it has sorting
111110
return true;
112111
}
113-
} catch (OutOfRangeException $outOfRangeException) {
112+
} catch (\OutOfRangeException $outOfRangeException) {
114113
// There is no more stages on the aggregation builder
115114
$shouldStop = true;
116115
}

src/Core/Upgrade/UpgradeApiSubresourceVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use ApiPlatform\Metadata\Link;
2222
use PhpParser\Node;
2323
use PhpParser\NodeVisitorAbstract;
24-
use ReflectionClass;
2524

2625
final class UpgradeApiSubresourceVisitor extends NodeVisitorAbstract
2726
{
@@ -175,7 +174,7 @@ public function enterNode(Node $node)
175174
];
176175

177176
if (null !== $this->referenceType) {
178-
$urlGeneratorInterface = new ReflectionClass(UrlGeneratorInterface::class);
177+
$urlGeneratorInterface = new \ReflectionClass(UrlGeneratorInterface::class);
179178
$urlGeneratorConstants = array_flip($urlGeneratorInterface->getConstants());
180179
$currentUrlGeneratorConstant = $urlGeneratorConstants[$this->referenceType];
181180

src/Doctrine/Odm/Extension/OrderExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Doctrine\ODM\MongoDB\Aggregation\Builder;
2020
use Doctrine\ODM\MongoDB\Aggregation\Stage\Sort;
2121
use Doctrine\Persistence\ManagerRegistry;
22-
use OutOfRangeException;
2322

2423
/**
2524
* Applies selected ordering while querying resource collection.
@@ -101,7 +100,7 @@ private function hasSortStage(Builder $aggregationBuilder): bool
101100
// If at least one stage is sort, then it has sorting
102101
return true;
103102
}
104-
} catch (OutOfRangeException $outOfRangeException) {
103+
} catch (\OutOfRangeException $outOfRangeException) {
105104
// There is no more stages on the aggregation builder
106105
$shouldStop = true;
107106
}

src/Metadata/Extractor/ResourceExtractorTrait.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace ApiPlatform\Metadata\Extractor;
1515

1616
use ApiPlatform\Exception\InvalidArgumentException;
17-
use SimpleXMLElement;
1817
use Symfony\Component\Config\Util\XmlUtils;
1918

2019
/**
@@ -25,14 +24,14 @@
2524
trait ResourceExtractorTrait
2625
{
2726
/**
28-
* @param array|SimpleXMLElement|null $resource
29-
* @param mixed|null $default
27+
* @param array|\SimpleXMLElement|null $resource
28+
* @param mixed|null $default
3029
*
3130
* @return array|null
3231
*/
3332
private function buildArrayValue($resource, string $key, $default = null)
3433
{
35-
if (\is_object($resource) && $resource instanceof SimpleXMLElement) {
34+
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) {
3635
if (!isset($resource->{$key.'s'}->{$key})) {
3736
return $default;
3837
}
@@ -54,8 +53,8 @@ private function buildArrayValue($resource, string $key, $default = null)
5453
/**
5554
* Transforms an attribute's value in a PHP value.
5655
*
57-
* @param array|SimpleXMLElement|null $resource
58-
* @param mixed|null $default
56+
* @param array|\SimpleXMLElement|null $resource
57+
* @param mixed|null $default
5958
*
6059
* @return string|int|bool|array|null
6160
*/
@@ -73,7 +72,7 @@ private function phpize($resource, string $key, string $type, $default = null)
7372
case 'integer':
7473
return (int) $resource[$key];
7574
case 'bool':
76-
if (\is_object($resource) && $resource instanceof SimpleXMLElement) {
75+
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) {
7776
return (bool) XmlUtils::phpize($resource[$key]);
7877
}
7978

@@ -83,7 +82,7 @@ private function phpize($resource, string $key, string $type, $default = null)
8382
throw new InvalidArgumentException(sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($resource[$key])));
8483
}
8584

86-
private function buildArgs(SimpleXMLElement $resource): ?array
85+
private function buildArgs(\SimpleXMLElement $resource): ?array
8786
{
8887
if (!isset($resource->args->arg)) {
8988
return null;
@@ -97,7 +96,7 @@ private function buildArgs(SimpleXMLElement $resource): ?array
9796
return $data;
9897
}
9998

100-
private function buildValues(SimpleXMLElement $resource): array
99+
private function buildValues(\SimpleXMLElement $resource): array
101100
{
102101
$data = [];
103102
foreach ($resource->value as $value) {

src/Metadata/Operations.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
namespace ApiPlatform\Metadata;
1515

16-
use RuntimeException;
17-
1816
final class Operations implements \IteratorAggregate, \Countable
1917
{
2018
private $operations;
@@ -71,7 +69,7 @@ public function remove(string $key): self
7169
}
7270
}
7371

74-
throw new RuntimeException(sprintf('Could not remove operation "%s".', $key));
72+
throw new \RuntimeException(sprintf('Could not remove operation "%s".', $key));
7573
}
7674

7775
public function has(string $key): bool

src/Symfony/Routing/SkolemIriConverter.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use ApiPlatform\Api\UrlGeneratorInterface;
1818
use ApiPlatform\Exception\ItemNotFoundException;
1919
use ApiPlatform\Metadata\Operation;
20-
use SplObjectStorage;
2120
use Symfony\Component\Routing\RouterInterface;
2221

2322
/**
@@ -36,7 +35,7 @@ final class SkolemIriConverter implements IriConverterInterface
3635
public function __construct(RouterInterface $router)
3736
{
3837
$this->router = $router;
39-
$this->objectHashMap = new SplObjectStorage();
38+
$this->objectHashMap = new \SplObjectStorage();
4039
}
4140

4241
/**

src/Test/DoctrineMongoDbOdmTestCase.php

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
use PHPUnit\Framework\TestCase;
2222
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2323

24-
use function sys_get_temp_dir;
25-
2624
/**
2725
* Source: https://github.com/doctrine/DoctrineMongoDBBundle/blob/0174003844bc566bb4cb3b7d10c5528d1924d719/Tests/TestCase.php
2826
* Test got excluded from vendor in 4.x.

tests/Action/ExceptionActionTest.php

+21-22
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use ApiPlatform\Metadata\Operations;
2525
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2626
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
27-
use DomainException;
2827
use PHPUnit\Framework\TestCase;
2928
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
3029
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
@@ -82,7 +81,7 @@ public function testLegacyActionWithOperationExceptionToStatus(
8281
) {
8382
$this->expectDeprecation('Since api-platform/core 2.7: Use "ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface" instead of "ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface".');
8483

85-
$exception = new DomainException();
84+
$exception = new \DomainException();
8685
$flattenException = FlattenException::create($exception);
8786

8887
$serializer = $this->prophesize(SerializerInterface::class);
@@ -135,7 +134,7 @@ public function testActionWithOperationExceptionToStatus(
135134
?array $operationExceptionToStatus,
136135
int $expectedStatusCode
137136
) {
138-
$exception = new DomainException();
137+
$exception = new \DomainException();
139138
$flattenException = FlattenException::create($exception);
140139

141140
$serializer = $this->prophesize(SerializerInterface::class);
@@ -196,86 +195,86 @@ public function provideOperationExceptionToStatusCases()
196195
];
197196

198197
yield 'on global attributes' => [
199-
[DomainException::class => 100],
198+
[\DomainException::class => 100],
200199
null,
201200
null,
202201
100,
203202
];
204203

205204
yield 'on global attributes with empty resource and operation attributes' => [
206-
[DomainException::class => 100],
205+
[\DomainException::class => 100],
207206
[],
208207
[],
209208
100,
210209
];
211210

212211
yield 'on global attributes and resource attributes' => [
213-
[DomainException::class => 100],
214-
[DomainException::class => 200],
212+
[\DomainException::class => 100],
213+
[\DomainException::class => 200],
215214
null,
216215
200,
217216
];
218217

219218
yield 'on global attributes and resource attributes with empty operation attributes' => [
220-
[DomainException::class => 100],
221-
[DomainException::class => 200],
219+
[\DomainException::class => 100],
220+
[\DomainException::class => 200],
222221
[],
223222
200,
224223
];
225224

226225
yield 'on global attributes and operation attributes' => [
227-
[DomainException::class => 100],
226+
[\DomainException::class => 100],
228227
null,
229-
[DomainException::class => 300],
228+
[\DomainException::class => 300],
230229
300,
231230
];
232231

233232
yield 'on global attributes and operation attributes with empty resource attributes' => [
234-
[DomainException::class => 100],
233+
[\DomainException::class => 100],
235234
[],
236-
[DomainException::class => 300],
235+
[\DomainException::class => 300],
237236
300,
238237
];
239238

240239
yield 'on global, resource and operation attributes' => [
241-
[DomainException::class => 100],
242-
[DomainException::class => 200],
243-
[DomainException::class => 300],
240+
[\DomainException::class => 100],
241+
[\DomainException::class => 200],
242+
[\DomainException::class => 300],
244243
300,
245244
];
246245

247246
yield 'on resource attributes' => [
248247
[],
249-
[DomainException::class => 200],
248+
[\DomainException::class => 200],
250249
null,
251250
200,
252251
];
253252

254253
yield 'on resource attributes with empty operation attributes' => [
255254
[],
256-
[DomainException::class => 200],
255+
[\DomainException::class => 200],
257256
[],
258257
200,
259258
];
260259

261260
yield 'on resource and operation attributes' => [
262261
[],
263-
[DomainException::class => 200],
264-
[DomainException::class => 300],
262+
[\DomainException::class => 200],
263+
[\DomainException::class => 300],
265264
300,
266265
];
267266

268267
yield 'on operation attributes' => [
269268
[],
270269
null,
271-
[DomainException::class => 300],
270+
[\DomainException::class => 300],
272271
300,
273272
];
274273

275274
yield 'on operation attributes with empty resource attributes' => [
276275
[],
277276
[],
278-
[DomainException::class => 300],
277+
[\DomainException::class => 300],
279278
300,
280279
];
281280
}

tests/Core/Metadata/Extractor/YamlExtractorTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use ApiPlatform\Core\Metadata\Extractor\YamlExtractor;
1717
use ApiPlatform\Exception\InvalidArgumentException;
18-
use Generator;
1918

2019
/**
2120
* @author Kévin Dunglas <[email protected]>
@@ -56,7 +55,7 @@ public function testInvalidResources(string $path, string $exceptionRegex)
5655
}
5756
}
5857

59-
public function provideInvalidResources(): Generator
58+
public function provideInvalidResources(): \Generator
6059
{
6160
yield [
6261
__DIR__.'/../../../Fixtures/FileConfigurations/resourcesinvalid.yml',

tests/Doctrine/Odm/Extension/OrderExtensionTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Doctrine\ODM\MongoDB\DocumentManager;
2424
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
2525
use Doctrine\Persistence\ManagerRegistry;
26-
use OutOfRangeException;
2726
use PHPUnit\Framework\TestCase;
2827

2928
/**
@@ -39,7 +38,7 @@ public function testApplyToCollectionWithValidOrder(): void
3938
{
4039
$aggregationBuilderProphecy = $this->prophesize(Builder::class);
4140

42-
$aggregationBuilderProphecy->getStage(0)->willThrow(new OutOfRangeException('message'));
41+
$aggregationBuilderProphecy->getStage(0)->willThrow(new \OutOfRangeException('message'));
4342
$aggregationBuilderProphecy->sort(['name' => 'asc'])->shouldBeCalled();
4443

4544
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);
@@ -60,7 +59,7 @@ public function testApplyToCollectionWithWrongOrder(): void
6059
{
6160
$aggregationBuilderProphecy = $this->prophesize(Builder::class);
6261

63-
$aggregationBuilderProphecy->getStage(0)->willThrow(new OutOfRangeException('message'));
62+
$aggregationBuilderProphecy->getStage(0)->willThrow(new \OutOfRangeException('message'));
6463
$aggregationBuilderProphecy->sort(['name' => 'asc'])->shouldNotBeCalled();
6564

6665
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);
@@ -81,7 +80,7 @@ public function testApplyToCollectionWithOrderOverridden(): void
8180
{
8281
$aggregationBuilderProphecy = $this->prophesize(Builder::class);
8382

84-
$aggregationBuilderProphecy->getStage(0)->willThrow(new OutOfRangeException('message'));
83+
$aggregationBuilderProphecy->getStage(0)->willThrow(new \OutOfRangeException('message'));
8584
$aggregationBuilderProphecy->sort(['foo' => 'DESC'])->shouldBeCalled();
8685

8786
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);
@@ -102,7 +101,7 @@ public function testApplyToCollectionWithOrderOverriddenWithNoDirection(): void
102101
{
103102
$aggregationBuilderProphecy = $this->prophesize(Builder::class);
104103

105-
$aggregationBuilderProphecy->getStage(0)->willThrow(new OutOfRangeException('message'));
104+
$aggregationBuilderProphecy->getStage(0)->willThrow(new \OutOfRangeException('message'));
106105
$aggregationBuilderProphecy->sort(['foo' => 'ASC'])->shouldBeCalled();
107106
$aggregationBuilderProphecy->sort(['foo' => 'ASC', 'bar' => 'DESC'])->shouldBeCalled();
108107

@@ -130,7 +129,7 @@ public function testApplyToCollectionWithOrderOverriddenWithAssociation(): void
130129
$lookupProphecy->alias('author_lkup')->shouldBeCalled();
131130
$aggregationBuilderProphecy->lookup(Dummy::class)->shouldBeCalled()->willReturn($lookupProphecy->reveal());
132131
$aggregationBuilderProphecy->unwind('$author_lkup')->shouldBeCalled();
133-
$aggregationBuilderProphecy->getStage(0)->willThrow(new OutOfRangeException('message'));
132+
$aggregationBuilderProphecy->getStage(0)->willThrow(new \OutOfRangeException('message'));
134133
$aggregationBuilderProphecy->sort(['author_lkup.name' => 'ASC'])->shouldBeCalled();
135134

136135
$classMetadataProphecy = $this->prophesize(ClassMetadata::class);

0 commit comments

Comments
 (0)