Skip to content

Commit 9799193

Browse files
committed
Merge branch '2.5'
2 parents 9ff7a23 + 0e61379 commit 9799193

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Allow to not declare GET item operation
66
* Add support for the Accept-Patch header
77
* Make the the `maximum_items_per_page` attribute consistent with other attributes controlling pagination
8+
* Allow to use a string instead of an array for serializer groups
89
* Test: Add an helper method to find the IRI of a resource
910
* Test: Add assertions for testing response against JSON Schema from API resource
1011
* GraphQL: Add support for multipart request so user can create custom file upload mutations (#3041)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function apply(bool $collection, QueryBuilder $queryBuilder, QueryNameGe
114114
}
115115

116116
if (!empty($context[AbstractNormalizer::GROUPS])) {
117-
$options['serializer_groups'] = $context[AbstractNormalizer::GROUPS];
117+
$options['serializer_groups'] = (array) $context[AbstractNormalizer::GROUPS];
118118
}
119119

120120
$this->joinRelations($queryBuilder, $queryNameGenerator, $resourceClass, $forceEager, $fetchPartial, $queryBuilder->getRootAliases()[0], $options, $context);

src/Bridge/NelmioApiDoc/Parser/ApiPlatformParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ private function parseResource(ResourceMetadata $resourceMetadata, string $resou
114114
$attributes = $resourceMetadata->getAttributes();
115115

116116
if (isset($attributes['normalization_context'][AbstractNormalizer::GROUPS])) {
117-
$options['serializer_groups'] = $attributes['normalization_context'][AbstractNormalizer::GROUPS];
117+
$options['serializer_groups'] = (array) $attributes['normalization_context'][AbstractNormalizer::GROUPS];
118118
}
119119

120120
if (isset($attributes['denormalization_context'][AbstractNormalizer::GROUPS])) {
121121
if (isset($options['serializer_groups'])) {
122122
$options['serializer_groups'] += $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
123123
} else {
124-
$options['serializer_groups'] = $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
124+
$options['serializer_groups'] = (array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
125125
}
126126
}
127127

src/Bridge/Symfony/Bundle/Test/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function request(string $method, string $url, array $options = []): Respo
100100
}
101101

102102
// BrowserKit doesn't support setting several headers with the same name
103-
$server['HTTP_'.strtoupper(strtr($key, '-', '_'))] = $value[0] ?? '';
103+
$server['HTTP_'.strtoupper(str_replace('-', '_', $key))] = $value[0] ?? '';
104104
}
105105

106106
if ($basic) {

src/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function buildSchema(string $resourceClass, string $format = 'json', stri
118118
$definition['externalDocs'] = ['url' => $iri];
119119
}
120120

121-
$options = isset($serializerContext[AbstractNormalizer::GROUPS]) ? ['serializer_groups' => $serializerContext[AbstractNormalizer::GROUPS]] : [];
121+
$options = isset($serializerContext[AbstractNormalizer::GROUPS]) ? ['serializer_groups' => (array) $serializerContext[AbstractNormalizer::GROUPS]] : [];
122122
foreach ($this->propertyNameCollectionFactory->create($inputOrOutputClass, $options) as $propertyName) {
123123
$propertyMetadata = $this->propertyMetadataFactory->create($inputOrOutputClass, $propertyName);
124124
if (!$propertyMetadata->isReadable() && !$propertyMetadata->isWritable()) {

src/Serializer/AbstractItemNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ protected function getFactoryOptions(array $context): array
480480

481481
if (isset($context[self::GROUPS])) {
482482
/* @see https://github.com/symfony/symfony/blob/v4.2.6/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php */
483-
$options['serializer_groups'] = $context[self::GROUPS];
483+
$options['serializer_groups'] = (array) $context[self::GROUPS];
484484
}
485485

486486
if (isset($context['collection_operation_name'])) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ public function testForceEager()
464464
$idPropertyMetadata = new PropertyMetadata();
465465
$idPropertyMetadata = $idPropertyMetadata->withIdentifier(true);
466466

467-
$propertyMetadataFactoryProphecy->create(UnknownDummy::class, 'id', ['serializer_groups' => 'foobar'])->willReturn($idPropertyMetadata)->shouldBeCalled();
468-
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relation', ['serializer_groups' => 'foobar'])->willReturn($relationPropertyMetadata)->shouldBeCalled();
467+
$propertyMetadataFactoryProphecy->create(UnknownDummy::class, 'id', ['serializer_groups' => ['foobar']])->willReturn($idPropertyMetadata)->shouldBeCalled();
468+
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relation', ['serializer_groups' => ['foobar']])->willReturn($relationPropertyMetadata)->shouldBeCalled();
469469

470470
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
471471

@@ -505,7 +505,7 @@ public function testExtraLazy()
505505
$relationPropertyMetadata = new PropertyMetadata();
506506
$relationPropertyMetadata = $relationPropertyMetadata->withReadableLink(true);
507507

508-
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relation', ['serializer_groups' => 'foobar'])->willReturn($relationPropertyMetadata)->shouldBeCalled();
508+
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relation', ['serializer_groups' => ['foobar']])->willReturn($relationPropertyMetadata)->shouldBeCalled();
509509

510510
$queryBuilderProphecy = $this->prophesize(QueryBuilder::class);
511511

tests/Swagger/Serializer/DocumentationNormalizerV2Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ public function testNormalizeWithOnlyDenormalizationGroups(): void
900900
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), $title, $description, $version);
901901

902902
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
903-
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => 'dummy'])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
903+
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => ['dummy']])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
904904
$propertyNameCollectionFactoryProphecy->create(Dummy::class, [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
905905

906906
$dummyMetadata = new ResourceMetadata(
@@ -1080,7 +1080,7 @@ public function testNormalizeWithNormalizationAndDenormalizationGroups(): void
10801080
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), $title, $description, $version);
10811081

10821082
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
1083-
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => 'dummy'])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
1083+
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => ['dummy']])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
10841084
$propertyNameCollectionFactoryProphecy->create(Dummy::class, [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
10851085

10861086
$dummyMetadata = new ResourceMetadata(

tests/Swagger/Serializer/DocumentationNormalizerV3Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ public function testNormalizeWithOnlyDenormalizationGroups(): void
10481048
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), $title, $description, $version);
10491049

10501050
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
1051-
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => 'dummy'])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
1051+
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => ['dummy']])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
10521052
$propertyNameCollectionFactoryProphecy->create(Dummy::class, [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
10531053
$propertyNameCollectionFactoryProphecy->create(Dummy::class)->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
10541054

@@ -1266,7 +1266,7 @@ public function testNormalizeWithNormalizationAndDenormalizationGroups(): void
12661266
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), $title, $description, $version);
12671267

12681268
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
1269-
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => 'dummy'])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
1269+
$propertyNameCollectionFactoryProphecy->create(Dummy::class, ['serializer_groups' => ['dummy']])->shouldBeCalledTimes(1)->willReturn(new PropertyNameCollection(['gerard']));
12701270
$propertyNameCollectionFactoryProphecy->create(Dummy::class, [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
12711271
$propertyNameCollectionFactoryProphecy->create(Dummy::class)->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
12721272

0 commit comments

Comments
 (0)