Skip to content

Commit 7f20c98

Browse files
chore: update api-platform to 4.0.3 (#454)
1 parent 2af5c1f commit 7f20c98

25 files changed

+296
-280
lines changed

api/composer.lock

+173-171
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/config/packages/api_platform.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
api_platform:
22
title: API Platform's demo
3-
version: 4.0.2
3+
version: 4.0.3
44
description: |
55
This is a demo application of the [API Platform](https://api-platform.com) framework.
66
[Its source code](https://github.com/api-platform/demo) includes various examples, check it out!

api/src/Command/BooksImportCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
private readonly SerializerInterface $serializer,
2828
private readonly DecoderInterface $decoder,
2929
private readonly HttpClientInterface $client,
30-
private readonly LoggerInterface $logger
30+
private readonly LoggerInterface $logger,
3131
) {
3232
parent::__construct();
3333
}

api/src/Doctrine/Orm/Extension/BookmarkQueryCollectionExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
3131
}
3232

3333
$queryBuilder
34-
->andWhere(sprintf('%s.user = :user', $queryBuilder->getRootAliases()[0]))
34+
->andWhere(\sprintf('%s.user = :user', $queryBuilder->getRootAliases()[0]))
3535
->setParameter('user', $user)
3636
;
3737
}

api/src/Doctrine/Orm/Filter/NameFilter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
4747
$parameterName = $queryNameGenerator->generateParameterName("name{$key}");
4848
$queryBuilder->setParameter($parameterName, "%{$value}%");
4949
$expressions[] = $queryBuilder->expr()->orX(
50-
$queryBuilder->expr()->like(sprintf('%s.firstName', $alias), ":{$parameterName}"),
51-
$queryBuilder->expr()->like(sprintf('%s.lastName', $alias), ":{$parameterName}")
50+
$queryBuilder->expr()->like(\sprintf('%s.firstName', $alias), ":{$parameterName}"),
51+
$queryBuilder->expr()->like(\sprintf('%s.lastName', $alias), ":{$parameterName}")
5252
);
5353
}
5454
$queryBuilder->andWhere($queryBuilder->expr()->andX(...$expressions));
@@ -72,7 +72,7 @@ protected function normalizeValues($value, string $property): ?array
7272

7373
if (empty($values)) {
7474
$this->getLogger()->notice('Invalid filter ignored', [
75-
'exception' => new \InvalidArgumentException(sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)),
75+
'exception' => new \InvalidArgumentException(\sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)),
7676
]);
7777

7878
return null;

api/src/Entity/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ public function getName(): ?string
118118
return null;
119119
}
120120

121-
return trim(sprintf('%s %s', $this->firstName, $this->lastName));
121+
return trim(\sprintf('%s %s', $this->firstName, $this->lastName));
122122
}
123123
}

api/src/Security/Core/UserProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function refreshUser(UserInterface $user): UserInterface
2424
{
2525
$manager = $this->registry->getManagerForClass($user::class);
2626
if (!$manager) {
27-
throw new UnsupportedUserException(sprintf('User class "%s" not supported.', $user::class));
27+
throw new UnsupportedUserException(\sprintf('User class "%s" not supported.', $user::class));
2828
}
2929

3030
$manager->refresh($user);

api/src/Security/Http/AccessToken/Oidc/OidcDiscoveryTokenHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getUserBadgeFrom(string $accessToken): UserBadge
8787

8888
$claims = json_decode($jws->getPayload(), true);
8989
if (empty($claims[$this->claim])) {
90-
throw new MissingClaimException(sprintf('"%s" claim not found.', $this->claim));
90+
throw new MissingClaimException(\sprintf('"%s" claim not found.', $this->claim));
9191
}
9292

9393
// UserLoader argument can be overridden by a UserProvider on AccessTokenAuthenticator::authenticate

api/src/Security/Http/Protection/ResourceResourceHandler.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function create(object $resource, UserInterface $owner, array $context =
4141
$this->securityAuthorizationClient->request('POST', $this->getResourceRegistrationEndpoint(), [
4242
'auth_bearer' => $this->getPAT(),
4343
'json' => [
44-
'name' => sprintf('%s_%s', $shortName, $resource->getId()->__toString()),
45-
'displayName' => sprintf('%s #%s', $operation->getShortName(), $resource->getId()->__toString()),
44+
'name' => \sprintf('%s_%s', $shortName, $resource->getId()->__toString()),
45+
'displayName' => \sprintf('%s #%s', $operation->getShortName(), $resource->getId()->__toString()),
4646
'uris' => [$resourceIri],
47-
'type' => sprintf('urn:%s:resources:%s', $this->oidcClientId, $shortName),
47+
'type' => \sprintf('urn:%s:resources:%s', $this->oidcClientId, $shortName),
4848
'owner' => $owner->getUserIdentifier(),
4949
],
5050
]);
@@ -75,7 +75,7 @@ public function delete(object $resource, UserInterface $owner, array $context =
7575
'max' => 1,
7676
'uri' => $resourceIri,
7777
'owner' => $owner->getUserIdentifier(),
78-
'type' => sprintf('urn:%s:resources:%s', $this->oidcClientId, $shortName),
78+
'type' => \sprintf('urn:%s:resources:%s', $this->oidcClientId, $shortName),
7979
],
8080
]
8181
);
@@ -85,7 +85,7 @@ public function delete(object $resource, UserInterface $owner, array $context =
8585
// delete corresponding resource_set on OIDC server
8686
$this->securityAuthorizationClient->request(
8787
'DELETE',
88-
sprintf('%s/%s', $this->getResourceRegistrationEndpoint(), $resourceSet['_id']),
88+
\sprintf('%s/%s', $this->getResourceRegistrationEndpoint(), $resourceSet['_id']),
8989
[
9090
'auth_bearer' => $this->getPAT(),
9191
]

api/src/Security/Voter/OidcRoleVoter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function supports(string $attribute, mixed $subject): bool
3636
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
3737
{
3838
if (!empty($subject)) {
39-
throw new \InvalidArgumentException(sprintf('Invalid subject type, expected empty string or "null", got "%s".', get_debug_type($subject)));
39+
throw new \InvalidArgumentException(\sprintf('Invalid subject type, expected empty string or "null", got "%s".', get_debug_type($subject)));
4040
}
4141

4242
// ensure user is authenticated

api/src/Security/Voter/OidcTokenIntrospectRoleVoter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function supports(string $attribute, mixed $subject): bool
4343
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
4444
{
4545
if (!empty($subject)) {
46-
throw new \InvalidArgumentException(sprintf('Invalid subject type, expected empty string or "null", got "%s".', get_debug_type($subject)));
46+
throw new \InvalidArgumentException(\sprintf('Invalid subject type, expected empty string or "null", got "%s".', get_debug_type($subject)));
4747
}
4848

4949
// ensure user is authenticated

api/src/Security/Voter/OidcTokenPermissionVoter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter
4747
}
4848

4949
if (!\is_string($subject)) {
50-
throw new \InvalidArgumentException(sprintf('Invalid subject type, expected "string" or "object", got "%s".', get_debug_type($subject)));
50+
throw new \InvalidArgumentException(\sprintf('Invalid subject type, expected "string" or "object", got "%s".', get_debug_type($subject)));
5151
}
5252

5353
// ensure user is authenticated
@@ -69,7 +69,7 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter
6969
'response_mode' => 'decision',
7070
'permission_resource_format' => 'uri',
7171
'permission_resource_matching_uri' => true,
72-
'permission' => sprintf('%s', $subject),
72+
'permission' => \sprintf('%s', $subject),
7373
],
7474
]);
7575

api/src/Serializer/BookNormalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class BookNormalizer implements NormalizerInterface, NormalizerAwareInterf
2121
*/
2222
public function __construct(
2323
#[Autowire(service: ReviewRepository::class)]
24-
private ObjectRepository $repository
24+
private ObjectRepository $repository,
2525
) {
2626
}
2727

api/src/Serializer/IriTransformerNormalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class IriTransformerNormalizer implements NormalizerInterface, NormalizerA
2020

2121
public function __construct(
2222
private readonly IriConverterInterface $iriConverter,
23-
private readonly OperationMetadataFactoryInterface $operationMetadataFactory
23+
private readonly OperationMetadataFactoryInterface $operationMetadataFactory,
2424
) {
2525
}
2626

api/src/State/Processor/BookPersistProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
#[Autowire(service: PersistProcessor::class)]
2626
private ProcessorInterface $persistProcessor,
2727
private HttpClientInterface $client,
28-
private DecoderInterface $decoder
28+
private DecoderInterface $decoder,
2929
) {
3030
}
3131

api/src/State/Processor/BookmarkPersistProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
#[Autowire(service: PersistProcessor::class)]
2525
private ProcessorInterface $persistProcessor,
2626
private Security $security,
27-
private ClockInterface $clock
27+
private ClockInterface $clock,
2828
) {
2929
}
3030

api/src/Validator/UniqueUserBookValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class UniqueUserBookValidator extends ConstraintValidator
2222
public function __construct(
2323
private readonly Security $security,
2424
private readonly ManagerRegistry $registry,
25-
private readonly PropertyAccessorInterface $propertyAccessor
25+
private readonly PropertyAccessorInterface $propertyAccessor,
2626
) {
2727
}
2828

@@ -47,7 +47,7 @@ public function validate($value, Constraint $constraint): void
4747
$className = ClassUtils::getRealClass($value::class);
4848
$manager = $this->registry->getManagerForClass($className);
4949
if (!$manager) {
50-
throw new ValidatorException(sprintf('"%s" is not a valid entity.', $className));
50+
throw new ValidatorException(\sprintf('"%s" is not a valid entity.', $className));
5151
}
5252

5353
if ($manager->getRepository($className)->findOneBy(['user' => $user, 'book' => $book])) {

api/symfony.lock

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
"api-platform/schema-generator": {
33
"version": "v4.0.0"
44
},
5+
"api-platform/symfony": {
6+
"version": "4.0",
7+
"recipe": {
8+
"repo": "github.com/symfony/recipes",
9+
"branch": "main",
10+
"version": "4.0",
11+
"ref": "e9952e9f393c2d048f10a78f272cd35e807d972b"
12+
},
13+
"files": [
14+
"config/packages/api_platform.yaml",
15+
"config/routes/api_platform.yaml",
16+
"src/ApiResource/.gitignore"
17+
]
18+
},
519
"composer/pcre": {
620
"version": "1.0.0"
721
},

api/tests/Api/Admin/BookTest.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function asNonAdminUserICannotGetACollectionOfBooks(int $expectedCode, st
5454
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
5555
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
5656
self::assertJsonContains([
57-
'@type' => 'hydra:Error',
58-
'hydra:title' => 'An error occurred',
59-
'hydra:description' => $hydraDescription,
57+
'@type' => 'Error',
58+
'title' => 'An error occurred',
59+
'description' => $hydraDescription,
6060
]);
6161
}
6262

@@ -196,9 +196,9 @@ public function asNonAdminUserICannotGetABook(int $expectedCode, string $hydraDe
196196
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
197197
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
198198
self::assertJsonContains([
199-
'@type' => 'hydra:Error',
200-
'hydra:title' => 'An error occurred',
201-
'hydra:description' => $hydraDescription,
199+
'@type' => 'Error',
200+
'title' => 'An error occurred',
201+
'description' => $hydraDescription,
202202
]);
203203
}
204204

@@ -254,9 +254,9 @@ public function asNonAdminUserICannotCreateABook(int $expectedCode, string $hydr
254254
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
255255
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
256256
self::assertJsonContains([
257-
'@type' => 'hydra:Error',
258-
'hydra:title' => 'An error occurred',
259-
'hydra:description' => $hydraDescription,
257+
'@type' => 'Error',
258+
'title' => 'An error occurred',
259+
'description' => $hydraDescription,
260260
]);
261261
}
262262

@@ -290,7 +290,7 @@ public static function getInvalidDataOnCreate(): iterable
290290
Response::HTTP_UNPROCESSABLE_ENTITY,
291291
[
292292
'@type' => 'ConstraintViolationList',
293-
'hydra:title' => 'An error occurred',
293+
'title' => 'An error occurred',
294294
'violations' => [
295295
[
296296
'propertyPath' => 'book',
@@ -316,8 +316,8 @@ public static function getInvalidData(): iterable
316316
Response::HTTP_UNPROCESSABLE_ENTITY,
317317
[
318318
'@type' => 'ConstraintViolationList',
319-
'hydra:title' => 'An error occurred',
320-
'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.',
319+
'title' => 'An error occurred',
320+
'description' => 'condition: This value should be of type ' . BookCondition::class . '.',
321321
'violations' => [
322322
[
323323
'propertyPath' => 'condition',
@@ -334,8 +334,8 @@ public static function getInvalidData(): iterable
334334
Response::HTTP_UNPROCESSABLE_ENTITY,
335335
[
336336
'@type' => 'ConstraintViolationList',
337-
'hydra:title' => 'An error occurred',
338-
'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.',
337+
'title' => 'An error occurred',
338+
'description' => 'condition: This value should be of type ' . BookCondition::class . '.',
339339
'violations' => [
340340
[
341341
'propertyPath' => 'condition',
@@ -352,7 +352,7 @@ public static function getInvalidData(): iterable
352352
Response::HTTP_UNPROCESSABLE_ENTITY,
353353
[
354354
'@type' => 'ConstraintViolationList',
355-
'hydra:title' => 'An error occurred',
355+
'title' => 'An error occurred',
356356
'violations' => [
357357
[
358358
'propertyPath' => 'book',
@@ -442,9 +442,9 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra
442442
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
443443
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
444444
self::assertJsonContains([
445-
'@type' => 'hydra:Error',
446-
'hydra:title' => 'An error occurred',
447-
'hydra:description' => $hydraDescription,
445+
'@type' => 'Error',
446+
'title' => 'An error occurred',
447+
'description' => $hydraDescription,
448448
]);
449449
}
450450

@@ -570,9 +570,9 @@ public function asNonAdminUserICannotDeleteABook(int $expectedCode, string $hydr
570570
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
571571
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
572572
self::assertJsonContains([
573-
'@type' => 'hydra:Error',
574-
'hydra:title' => 'An error occurred',
575-
'hydra:description' => $hydraDescription,
573+
'@type' => 'Error',
574+
'title' => 'An error occurred',
575+
'description' => $hydraDescription,
576576
]);
577577
}
578578

api/tests/Api/Admin/ReviewTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function asNonAdminUserICannotGetACollectionOfReviews(int $expectedCode,
5555
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
5656
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
5757
self::assertJsonContains([
58-
'@type' => 'hydra:Error',
59-
'hydra:title' => 'An error occurred',
60-
'hydra:description' => $hydraDescription,
58+
'@type' => 'Error',
59+
'title' => 'An error occurred',
60+
'description' => $hydraDescription,
6161
]);
6262
}
6363

@@ -163,9 +163,9 @@ public function asNonAdminUserICannotGetAReview(int $expectedCode, string $hydra
163163
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
164164
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
165165
self::assertJsonContains([
166-
'@type' => 'hydra:Error',
167-
'hydra:title' => 'An error occurred',
168-
'hydra:description' => $hydraDescription,
166+
'@type' => 'Error',
167+
'title' => 'An error occurred',
168+
'description' => $hydraDescription,
169169
]);
170170
}
171171

@@ -227,9 +227,9 @@ public function asNonAdminUserICannotUpdateAReview(int $expectedCode, string $hy
227227
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
228228
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
229229
self::assertJsonContains([
230-
'@type' => 'hydra:Error',
231-
'hydra:title' => 'An error occurred',
232-
'hydra:description' => $hydraDescription,
230+
'@type' => 'Error',
231+
'title' => 'An error occurred',
232+
'description' => $hydraDescription,
233233
]);
234234
}
235235

@@ -334,9 +334,9 @@ public function asNonAdminUserICannotDeleteAReview(int $expectedCode, string $hy
334334
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
335335
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
336336
self::assertJsonContains([
337-
'@type' => 'hydra:Error',
338-
'hydra:title' => 'An error occurred',
339-
'hydra:description' => $hydraDescription,
337+
'@type' => 'Error',
338+
'title' => 'An error occurred',
339+
'description' => $hydraDescription,
340340
]);
341341
}
342342

0 commit comments

Comments
 (0)