Skip to content

Commit d219071

Browse files
committed
Merge 4.3
2 parents d371f65 + 8c95af6 commit d219071

7 files changed

Lines changed: 36 additions & 13 deletions

File tree

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ parameters:
8686
# Expected, due to backward compatibility
8787
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#'
8888
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'
89-
- "#Call to function method_exists\\(\\) with GraphQL\\\\Type\\\\Definition\\\\Type&GraphQL\\\\Type\\\\Definition\\\\WrappingType and 'getInnermostType' will always evaluate to true\\.#"
9089
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#"
9190
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#"
9291
- '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#'

src/GraphQl/Action/EntrypointAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function parseRequest(Request $request): array
125125
*/
126126
private function parseData(?string $query, ?string $operationName, array $variables, string $jsonContent): array
127127
{
128-
if (!\is_array($data = json_decode($jsonContent, true, 512, \JSON_ERROR_NONE))) {
128+
if (!\is_array($data = json_decode($jsonContent, true))) {
129129
throw new BadRequestHttpException('GraphQL data is not valid JSON.');
130130
}
131131

@@ -162,7 +162,7 @@ private function parseMultipartRequest(?string $query, ?string $operationName, a
162162
[$query, $operationName, $variables] = $this->parseData($query, $operationName, $variables, $operations);
163163

164164
/** @var string $map */
165-
if (!\is_array($decodedMap = json_decode($map, true, 512, \JSON_ERROR_NONE))) {
165+
if (!\is_array($decodedMap = json_decode($map, true))) {
166166
throw new BadRequestHttpException('GraphQL multipart request map is not valid JSON.');
167167
}
168168

@@ -218,7 +218,7 @@ private function applyMapToVariables(array $map, array $variables, array $files)
218218
*/
219219
private function decodeVariables(string $variables): array
220220
{
221-
if (!\is_array($decoded = json_decode($variables, true, 512, \JSON_ERROR_NONE))) {
221+
if (!\is_array($decoded = json_decode($variables, true))) {
222222
throw new BadRequestHttpException('GraphQL variables are not valid JSON.');
223223
}
224224

src/JsonApi/JsonSchema/SchemaFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ public function buildSchema(string $className, string $format = 'jsonapi', strin
259259
$properties = $this->buildDefinitionPropertiesSchema($key, $className, $format, $type, $operation, $schema, []);
260260
$properties['data']['properties']['attributes']['$ref'] = $prefix.$key;
261261

262+
$properties['data'] = [
263+
'type' => 'array',
264+
'items' => $properties['data'],
265+
];
266+
262267
$schema['description'] = "$definitionName collection.";
263268
$schema['allOf'] = [
264269
['$ref' => $prefix.(false === $operation->getPaginationEnabled() ? self::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION : self::COLLECTION_BASE_SCHEMA_NAME)],
265-
['type' => 'object', 'properties' => [
266-
'data' => [
267-
'type' => 'array',
268-
'items' => $properties['data'],
269-
],
270-
]],
270+
['type' => 'object', 'properties' => $properties],
271271
];
272272

273273
return $schema;

src/Laravel/Eloquent/Metadata/Factory/Resource/EloquentResourceCollectionMetadataFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ public function create(string $resourceClass): ResourceMetadataCollection
111111
if ($this->partialPatchValidation && $operation instanceof Patch) {
112112
$rules = $operation->getRules();
113113
if (\is_array($rules)) {
114-
$operation = $operation->withRules($this->replaceRequiredWithSometimes($rules));
114+
$stringKeyedRules = [];
115+
foreach ($rules as $field => $fieldRules) {
116+
if (\is_string($field)) {
117+
$stringKeyedRules[$field] = $fieldRules;
118+
}
119+
}
120+
$operation = $operation->withRules($this->replaceRequiredWithSometimes($stringKeyedRules));
115121
}
116122
}
117123

src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private function getProperties(string $resourceClass, ?Parameter $parameter = nu
212212
}
213213

214214
if (($filter = $this->getFilterInstance($parameter->getFilter())) && $filter instanceof PropertyAwareFilterInterface) {
215-
if (!method_exists($filter, 'getProperties')) { // @phpstan-ignore-line todo 5.x remove this check
215+
if (!method_exists($filter, 'getProperties')) { // todo 5.x remove this check
216216
trigger_deprecation('api-platform/core', 'In API Platform 5.0 "%s" will implement a method named "getProperties"', PropertyAwareFilterInterface::class);
217217
$refl = new \ReflectionClass($filter);
218218
$filterProperties = $refl->hasProperty('properties') ? $refl->getProperty('properties')->getValue($filter) : [];

src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static function getMercureMessage(int $index = 0, ?string $hubName = null
166166
public static function assertMercureUpdateMatchesJsonSchema(Update $update, array $topics, array|object|string $jsonSchema = '', bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null, string $message = ''): void
167167
{
168168
static::assertSame($topics, $update->getTopics(), $message);
169-
static::assertThat(json_decode($update->getData(), true, \JSON_THROW_ON_ERROR), new MatchesJsonSchema($jsonSchema), $message);
169+
static::assertThat(json_decode($update->getData(), true, flags: \JSON_THROW_ON_ERROR), new MatchesJsonSchema($jsonSchema), $message);
170170
static::assertSame($private, $update->isPrivate(), $message);
171171
static::assertSame($id, $update->getId(), $message);
172172
static::assertSame($type, $update->getType(), $message);

tests/Functional/OpenApiTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,24 @@ public function testHasSchemasForMultipleFormats(): void
261261
], 'description' => 'A resource used for OpenAPI tests.'], $res['components']['schemas']['Crud.jsonld']);
262262
}
263263

264+
public function testJsonApiCollectionSchemaDocumentsIncludedResources(): void
265+
{
266+
$response = self::createClient()->request('GET', '/docs', [
267+
'headers' => ['Accept' => 'application/vnd.openapi+json'],
268+
]);
269+
270+
$this->assertResponseIsSuccessful();
271+
$json = $response->toArray();
272+
$schema = $json['paths']['/dummies']['get']['responses']['200']['content']['application/vnd.api+json']['schema'];
273+
$properties = $schema['allOf'][1]['properties'];
274+
275+
$this->assertArrayHasKey('included', $properties);
276+
$this->assertSame('array', $properties['included']['type']);
277+
$this->assertTrue($properties['included']['readOnly']);
278+
$this->assertArrayHasKey('anyOf', $properties['included']['items']);
279+
$this->assertNotEmpty($properties['included']['items']['anyOf']);
280+
}
281+
264282
public function testRetrieveTheOpenApiDocumentation(): void
265283
{
266284
$response = self::createClient()->request('GET', '/docs', ['headers' => ['accept' => 'application/vnd.openapi+json']]);

0 commit comments

Comments
 (0)