Skip to content

Commit

Permalink
Upgrade cs-fixer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
silverbackdan committed Aug 20, 2024
1 parent e8bf438 commit 80cfca6
Show file tree
Hide file tree
Showing 80 changed files with 216 additions and 216 deletions.
18 changes: 9 additions & 9 deletions features/bootstrap/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ public function thereAreRoutes(int $count): void
for ($x = 0; $x < $count; ++$x) {
$route = new Route();
$route
->setPath(sprintf('/route-%s', $x))
->setName(sprintf('/route-%s', $x));
->setPath(\sprintf('/route-%s', $x))
->setName(\sprintf('/route-%s', $x));
$this->timestampedHelper->persistTimestampedFields($route, true);
$this->manager->persist($route);
$this->restContext->resources['route_' . $x] = $this->iriConverter->getIriFromResource($route);
Expand Down Expand Up @@ -602,7 +602,7 @@ public function iPatchPageDataWithThePropertyAndResource(string $property, strin
'PUT',
'page_data',
null,
new PyStringNode([sprintf('{ "%s": "%s" }', $property, $iri)], 0)
new PyStringNode([\sprintf('{ "%s": "%s" }', $property, $iri)], 0)
);
}

Expand Down Expand Up @@ -767,7 +767,7 @@ public function theIsAComponentInARouteWithPath(string $resource, string $path):
{
$component = $this->iriConverter->getResourceFromIri($this->restContext->resources[$resource]);
if (!$component instanceof AbstractComponent) {
throw new \RuntimeException(sprintf('The resource named `%s` is not a component', $resource));
throw new \RuntimeException(\sprintf('The resource named `%s` is not a component', $resource));
}

$page = $this->thereIsAPage('page_1');
Expand Down Expand Up @@ -870,7 +870,7 @@ public function theResourceShouldNotExist(string $name): void
try {
$iri = $this->restContext->resources[$name];
$this->iriConverter->getResourceFromIri($iri);
throw new ExpectationException(sprintf('The resource %s can still be found and has not been removed', $iri), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The resource %s can still be found and has not been removed', $iri), $this->minkContext->getSession()->getDriver());
} catch (ItemNotFoundException $exception) {
}
}
Expand All @@ -886,7 +886,7 @@ public function theRefreshTokenShouldBeExpired(): void
'user' => $this->iriConverter->getResourceFromIri($this->restContext->resources['login_user']),
]);
if (!$token->isExpired()) {
throw new ExpectationException(sprintf('The token with ID %s is not expired', $this->restContext->resources['refresh_token']), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The token with ID %s is not expired', $this->restContext->resources['refresh_token']), $this->minkContext->getSession()->getDriver());
}
}

Expand All @@ -902,7 +902,7 @@ public function allTheRefreshTokensShouldBeExpired(): void
]);
foreach ($tokens as $token) {
if (!$token->isExpired()) {
throw new ExpectationException(sprintf('The token with ID %s is not expired', $this->restContext->resources['refresh_token']), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The token with ID %s is not expired', $this->restContext->resources['refresh_token']), $this->minkContext->getSession()->getDriver());
}
}
}
Expand All @@ -917,7 +917,7 @@ public function theResourceShouldExist(string $name): void
$iri = $this->restContext->resources[$name];
$this->iriConverter->getResourceFromIri($iri);
} catch (ItemNotFoundException $exception) {
throw new ExpectationException(sprintf('The resource %s cannot be found anymore', $iri), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The resource %s cannot be found anymore', $iri), $this->minkContext->getSession()->getDriver());
}
}

Expand Down Expand Up @@ -1014,6 +1014,6 @@ public function aRefreshTokenShouldHaveBeenGenerated(int $count): void
++$nonExpiredCount;
}
}
Assert::assertLessThanOrEqual(1, $nonExpiredCount, sprintf('There should only be 1 token that is not expired. There are %d', $nonExpiredCount));
Assert::assertLessThanOrEqual(1, $nonExpiredCount, \sprintf('There should only be 1 token that is not expired. There are %d', $nonExpiredCount));
}
}
10 changes: 5 additions & 5 deletions features/bootstrap/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private function getCookieByName(string $name): Cookie
return $cookie;
}
}
throw new \Exception(sprintf('The cookie "%s" was not found in the response headers.', $name));
throw new \Exception(\sprintf('The cookie "%s" was not found in the response headers.', $name));
}

/**
Expand All @@ -210,7 +210,7 @@ public function theResponseShouldHaveACookieWithMaxAgeLessThan(string $name, int
{
$cookie = $this->getCookieByName($name);
$timeDiff = $cookie->getExpiresTime() - time();
Assert::assertLessThan($seconds, $timeDiff, sprintf('The cookie "%s" expires in "%d" seconds. Expected less than "%d" seconds', $name, $timeDiff, $seconds));
Assert::assertLessThan($seconds, $timeDiff, \sprintf('The cookie "%s" expires in "%d" seconds. Expected less than "%d" seconds', $name, $timeDiff, $seconds));
}

/**
Expand All @@ -220,7 +220,7 @@ public function theResponseShouldHaveACookieWithTheValue(string $name, ?string $
{
$cookie = $this->getCookieByName($name);
$real = $cookie->getValue();
Assert::assertEquals($value, $real, sprintf('The cookie "%s" has the value "%s". Expected "%s"', $name, $real, $value));
Assert::assertEquals($value, $real, \sprintf('The cookie "%s" has the value "%s". Expected "%s"', $name, $real, $value));
}

/**
Expand All @@ -234,7 +234,7 @@ public function theJsonNodeShouldBeEqualTo($node): void
$actual = $this->inspector->evaluate($json, $node);
$diff = (new \DateTime($text))->getTimestamp() - (new \DateTime($actual))->getTimestamp();
if ($diff < -1 || $diff > 1) {
throw new \Exception(sprintf("The node value is '%s' which is a difference of %s seconds to the cached 'now' value", json_encode($actual), $diff));
throw new \Exception(\sprintf("The node value is '%s' which is a difference of %s seconds to the cached 'now' value", json_encode($actual), $diff));
}
}

Expand Down Expand Up @@ -268,7 +268,7 @@ public function theJsonNodeShouldMatchTheRegex(string $name, string $expression)
$actual = $this->inspector->evaluate($json, $name);

if (1 !== preg_match($expression, $actual)) {
throw new \Exception(sprintf("The node value did not match '%s'. It is '%s'", $expression, json_encode($actual)));
throw new \Exception(\sprintf("The node value did not match '%s'. It is '%s'", $expression, json_encode($actual)));
}
}

Expand Down
12 changes: 6 additions & 6 deletions features/bootstrap/ProfilerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function thereShouldBeAPublishedMercureUpdatePublished(?int $count = null
{
$messageObjects = $this->getMercureMessageObjects();
if (null !== $count && \count($messageObjects) !== $count) {
throw new ExpectationException(sprintf('%d updates were published but %d were expected', \count($messageObjects), $count), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('%d updates were published but %d were expected', \count($messageObjects), $count), $this->minkContext->getSession()->getDriver());
}

return $messageObjects;
Expand Down Expand Up @@ -117,7 +117,7 @@ private function getMercureComponentGroupMessage()
return $messageAsArray;
}
}
throw new ExpectationException(sprintf('%d updates were published but no ComponentGroup was found', \count($messageObjects)), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('%d updates were published but no ComponentGroup was found', \count($messageObjects)), $this->minkContext->getSession()->getDriver());
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ public function thereShouldMercureMessagesForDraftResources(int $count)
}
}
if ($draftCount !== $count) {
throw new ExpectationException(sprintf('%d draft updates were published but %d were expected', $draftCount, $count), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('%d draft updates were published but %d were expected', $draftCount, $count), $this->minkContext->getSession()->getDriver());
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function theResourceShouldBePurgedFromTheCache(string $resourceName)
}
}
}
throw new ExpectationException(sprintf('The resource %s was not found in any xkey headers sent to be purged. IRIs that were purged were `%s`', $expectedIri, implode('`, `', $purged)), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The resource %s was not found in any xkey headers sent to be purged. IRIs that were purged were `%s`', $expectedIri, implode('`, `', $purged)), $this->minkContext->getSession()->getDriver());
}

/**
Expand Down Expand Up @@ -213,7 +213,7 @@ public function iShouldGetAnEmail(string $emailType, string $emailAddress = 'use
return $email->getSubject();
}, $messages);

Assert::assertCount(1, $messages, sprintf("%d messages were sent but only 1 was expected. Messages were sent with subjects '%s'", \count($messages), implode("', '", $subjects)));
Assert::assertCount(1, $messages, \sprintf("%d messages were sent but only 1 was expected. Messages were sent with subjects '%s'", \count($messages), implode("', '", $subjects)));
Assert::assertInstanceOf(TemplatedEmail::class, $email = $messages[0]);

/** @var TemplatedEmail $email */
Expand Down Expand Up @@ -260,7 +260,7 @@ public function iShouldGetAnEmail(string $emailType, string $emailAddress = 'use
$this->validatePasswordChanged($headers);
break;
default:
throw new \InvalidArgumentException(sprintf('The email type %s is not configured to test', $emailType));
throw new \InvalidArgumentException(\sprintf('The email type %s is not configured to test', $emailType));
}
}

Expand Down
12 changes: 6 additions & 6 deletions features/bootstrap/PublishableContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function thereIsADraftFor(string $publishedComponent, ?string $publishDat
{
$component = $this->iriConverter->getResourceFromIri($this->restContext->resources[$publishedComponent]);
if (!$component instanceof DummyPublishableComponent) {
throw new \RuntimeException(sprintf('The resource named `%s` is not a DummyPublishableComponent', $publishedComponent));
throw new \RuntimeException(\sprintf('The resource named `%s` is not a DummyPublishableComponent', $publishedComponent));
}
$publishAt = $publishDate ? (new \DateTime($publishDate))->format('Y-m-d H:i:s') : null;
$draft = $this->thereIsAPublishableResource($publishAt, false, true);
Expand Down Expand Up @@ -222,7 +222,7 @@ public function thereIsACustomPublishableResource(?string $publishDate = null, b
$flush && $this->manager->flush();

$this->resources[] = $resource;
$componentKey = sprintf('publishable_%s', $isPublished ? 'published' : 'draft');
$componentKey = \sprintf('publishable_%s', $isPublished ? 'published' : 'draft');
$this->restContext->resources[$componentKey] = $this->iriConverter->getIriFromResource($resource);

return $resource;
Expand Down Expand Up @@ -262,7 +262,7 @@ static function (DummyPublishableComponent $component) {
$expectedTotal = \count($draftResources) + \count($this->publishedResourcesWithoutDrafts);

if ($expectedTotal !== ($receivedTotal = \count($items))) {
throw new ExpectationException(sprintf('Expected %d resources but received %d', $expectedTotal, $receivedTotal), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('Expected %d resources but received %d', $expectedTotal, $receivedTotal), $this->minkContext->getSession()->getDriver());
}

$expectedPublishedResourceIds = $this->getResourceIds($this->publishedResourcesWithoutDrafts);
Expand Down Expand Up @@ -293,7 +293,7 @@ static function (DummyPublishableComponent $component) {

$expectedTotal = \count($publishedResources);

Assert::assertEquals($expectedTotal, $receivedTotal = \count($items), sprintf('Expected %d resources but received %d', $expectedTotal, $receivedTotal));
Assert::assertEquals($expectedTotal, $receivedTotal = \count($items), \sprintf('Expected %d resources but received %d', $expectedTotal, $receivedTotal));

foreach ($items as $item) {
Assert::assertEquals('is_published', $item['reference'], 'Received an unexpected item in the response: ' . json_encode($item, \JSON_THROW_ON_ERROR, 512));
Expand All @@ -319,7 +319,7 @@ public function theResponseShouldIncludeThePublishedResourcesOnlyWithoutTheDraft
public function theComponentPositionShouldHaveTheComponent(string $reference)
{
$response = $this->jsonContext->getJsonAsArray();
Assert::assertEquals($this->restContext->resources[$reference], $response['component'], sprintf('The component position was expected to have the component %s but %s was returned', $this->restContext->resources[$reference], $response['component']));
Assert::assertEquals($this->restContext->resources[$reference], $response['component'], \sprintf('The component position was expected to have the component %s but %s was returned', $this->restContext->resources[$reference], $response['component']));
}

/**
Expand All @@ -334,7 +334,7 @@ private function createPublishableComponent(?\DateTime $publishedAt, bool $force
$this->manager->persist($resource);
$this->resources[] = $resource;

$componentKey = sprintf('publishable_%s', $isPublished ? 'published' : 'draft');
$componentKey = \sprintf('publishable_%s', $isPublished ? 'published' : 'draft');
$this->restContext->resources[$componentKey] = $this->iriConverter->getIriFromResource($resource);

return $resource;
Expand Down
4 changes: 2 additions & 2 deletions features/bootstrap/RestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function iSendARequestToWithData($method, $url, TableNode $tableNode): vo
public function iAddHeaderEqualToTheResource($name, $resource)
{
if (!isset($this->resources[$resource])) {
throw new ExpectationException(sprintf("The resource with name $resource has not been defined. (Components that exist are `%s`)", implode('`, `', array_keys($this->resources))), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf("The resource with name $resource has not been defined. (Components that exist are `%s`)", implode('`, `', array_keys($this->resources))), $this->minkContext->getSession()->getDriver());
}
$value = $this->resources[$resource];
$this->restContext->iAddHeaderEqualTo($name, $value);
Expand All @@ -163,7 +163,7 @@ public function iAddHeaderEqualToTheResource($name, $resource)
public function iSendARequestToTheResourceWithBody(string $method, string $resource, ?string $postfix = null, ?PyStringNode $body = null)
{
if (!isset($this->resources[$resource])) {
throw new ExpectationException(sprintf("The resource with name $resource has not been defined. (Components that exist are `%s`)", implode('`, `', array_keys($this->resources))), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf("The resource with name $resource has not been defined. (Components that exist are `%s`)", implode('`, `', array_keys($this->resources))), $this->minkContext->getSession()->getDriver());
}
$endpoint = $this->resources[$resource] . ($postfix ?: '');

Expand Down
2 changes: 1 addition & 1 deletion features/bootstrap/UploadsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function getUploadableResourceByName(string $name)
/* @var UploadableTrait $item */
return $this->iriConverter->getResourceFromIri($iri);
} catch (ItemNotFoundException $exception) {
throw new ExpectationException(sprintf('The resource %s cannot be found anymore', $iri), $this->minkContext->getSession()->getDriver());
throw new ExpectationException(\sprintf('The resource %s cannot be found anymore', $iri), $this->minkContext->getSession()->getDriver());
}
}
}
2 changes: 1 addition & 1 deletion src/Action/Uploadable/DownloadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DownloadAction
public function __invoke(object $data, string $property, Request $request, UploadableAttributeReader $annotationReader, UploadableFileManager $uploadableFileManager)
{
if (!$annotationReader->isConfigured($data)) {
throw new InvalidArgumentException(sprintf('%s is not an uploadable resource. It should not be configured to use %s.', $data::class, __CLASS__));
throw new InvalidArgumentException(\sprintf('%s is not an uploadable resource. It should not be configured to use %s.', $data::class, __CLASS__));
}

return $uploadableFileManager->getFileResponse($data, $property, $request->query->getBoolean('download', false));
Expand Down
2 changes: 1 addition & 1 deletion src/Action/Uploadable/UploadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __invoke(?object $data, Request $request, UploadableFileManager
$contentType = explode(';', $contentType)[0];
$formats = ['multipart/form-data'];
if (!\in_array(strtolower($contentType), $formats, true)) {
throw new UnsupportedMediaTypeHttpException(sprintf('The content-type "%s" is not supported. Supported MIME type is "%s".', $contentType, implode('", "', $formats)));
throw new UnsupportedMediaTypeHttpException(\sprintf('The content-type "%s" is not supported. Supported MIME type is "%s".', $contentType, implode('", "', $formats)));
}

$resourceClass = $request->attributes->get('_api_resource_class');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public function create(string $resourceClass): ResourceMetadataCollection
foreach ($resourceMetadata as $resourceMetadatum) {
$resourceShortName = $resourceMetadatum->getShortName();
if (!$resourceShortName) {
throw new \RuntimeException(sprintf('Could not find short name from resource metadata for %s', $resourceClass));
throw new \RuntimeException(\sprintf('Could not find short name from resource metadata for %s', $resourceClass));
}

$pathSegmentName = $this->pathSegmentNameGenerator->getSegmentName($resourceShortName);
$usagePath = sprintf('/%s/{id}/usage', $pathSegmentName);
$usagePath = \sprintf('/%s/{id}/usage', $pathSegmentName);

$operations = $resourceMetadatum->getOperations();
if ($operations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
HttpOperation::METHOD_POST !== $operation->getMethod()
&& !$operation instanceof CollectionOperationInterface
&& !$operation->getSecurity()) {
$operation = $operation->withSecurity(sprintf("is_granted('%s', object)", AbstractRoutableVoter::READ_ROUTABLE));
$operation = $operation->withSecurity(\sprintf("is_granted('%s', object)", AbstractRoutableVoter::READ_ROUTABLE));
}
$newOperations[$i] = $operation;
}
Expand Down
Loading

0 comments on commit 80cfca6

Please sign in to comment.