diff --git a/features/bootstrap/DoctrineContext.php b/features/bootstrap/DoctrineContext.php index bec5fad2..954db586 100644 --- a/features/bootstrap/DoctrineContext.php +++ b/features/bootstrap/DoctrineContext.php @@ -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); @@ -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) ); } @@ -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'); @@ -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) { } } @@ -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()); } } @@ -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()); } } } @@ -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()); } } @@ -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)); } } diff --git a/features/bootstrap/JsonContext.php b/features/bootstrap/JsonContext.php index e06bdc93..6d9b1534 100644 --- a/features/bootstrap/JsonContext.php +++ b/features/bootstrap/JsonContext.php @@ -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)); } /** @@ -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)); } /** @@ -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)); } /** @@ -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)); } } @@ -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))); } } diff --git a/features/bootstrap/ProfilerContext.php b/features/bootstrap/ProfilerContext.php index ae14780b..c07cdf33 100644 --- a/features/bootstrap/ProfilerContext.php +++ b/features/bootstrap/ProfilerContext.php @@ -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; @@ -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()); } /** @@ -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()); } } @@ -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()); } /** @@ -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 */ @@ -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)); } } diff --git a/features/bootstrap/PublishableContext.php b/features/bootstrap/PublishableContext.php index 4be97248..d0c18627 100644 --- a/features/bootstrap/PublishableContext.php +++ b/features/bootstrap/PublishableContext.php @@ -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); @@ -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; @@ -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); @@ -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)); @@ -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'])); } /** @@ -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; diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index d9f818d2..2197c728 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -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); @@ -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 ?: ''); diff --git a/features/bootstrap/UploadsContext.php b/features/bootstrap/UploadsContext.php index 225841c4..973d12fe 100644 --- a/features/bootstrap/UploadsContext.php +++ b/features/bootstrap/UploadsContext.php @@ -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()); } } } diff --git a/src/Action/Uploadable/DownloadAction.php b/src/Action/Uploadable/DownloadAction.php index e9caa2b2..8c637080 100644 --- a/src/Action/Uploadable/DownloadAction.php +++ b/src/Action/Uploadable/DownloadAction.php @@ -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)); diff --git a/src/Action/Uploadable/UploadAction.php b/src/Action/Uploadable/UploadAction.php index 4a74bdb5..5babb08b 100644 --- a/src/Action/Uploadable/UploadAction.php +++ b/src/Action/Uploadable/UploadAction.php @@ -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'); diff --git a/src/ApiPlatform/Metadata/Resource/ComponentResourceMetadataFactory.php b/src/ApiPlatform/Metadata/Resource/ComponentResourceMetadataFactory.php index 6483fb44..21df5f92 100644 --- a/src/ApiPlatform/Metadata/Resource/ComponentResourceMetadataFactory.php +++ b/src/ApiPlatform/Metadata/Resource/ComponentResourceMetadataFactory.php @@ -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) { diff --git a/src/ApiPlatform/Metadata/Resource/RoutableResourceMetadataCollectionFactory.php b/src/ApiPlatform/Metadata/Resource/RoutableResourceMetadataCollectionFactory.php index 429e7b52..1428963e 100644 --- a/src/ApiPlatform/Metadata/Resource/RoutableResourceMetadataCollectionFactory.php +++ b/src/ApiPlatform/Metadata/Resource/RoutableResourceMetadataCollectionFactory.php @@ -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; } diff --git a/src/ApiPlatform/Metadata/Resource/UploadableResourceMetadataCollectionFactory.php b/src/ApiPlatform/Metadata/Resource/UploadableResourceMetadataCollectionFactory.php index 5a13a570..ebd60e85 100644 --- a/src/ApiPlatform/Metadata/Resource/UploadableResourceMetadataCollectionFactory.php +++ b/src/ApiPlatform/Metadata/Resource/UploadableResourceMetadataCollectionFactory.php @@ -96,7 +96,7 @@ public function create(string $resourceClass): ResourceMetadataCollection #[Pure] private static function generateOperationName(Operation $operation): string { - return sprintf( + return \sprintf( '_api_%s_%s%s', $operation->getUriTemplate(), strtolower($operation->getMethod()), @@ -128,7 +128,7 @@ private static function configurePostOperation(Operation $postOperation, array $ #[Pure] private static function generatePostOperation(Post $defaultOperation, array $openApiRequestMultipartProperties, string $pathSegmentName): Operation { - $path = sprintf('/%s/upload', $pathSegmentName); + $path = \sprintf('/%s/upload', $pathSegmentName); $newPost = $defaultOperation ->withUriTemplate($path) ->withShortName($defaultOperation->getShortName()) @@ -140,7 +140,7 @@ private static function generatePostOperation(Post $defaultOperation, array $ope #[Pure] private static function generateUploadItemOperation(Get $getOperation, array $openApiRequestMultipartProperties, string $pathSegmentName): Operation { - $path = sprintf('/%s/{id}/upload', $pathSegmentName); + $path = \sprintf('/%s/{id}/upload', $pathSegmentName); $newUploadPost = $getOperation ->withUriTemplate($path) ->withMethod(HttpOperation::METHOD_POST) @@ -153,7 +153,7 @@ private static function generateUploadItemOperation(Get $getOperation, array $op #[Pure] private static function generateDownloadItemOperation(Get $getOperation, string $pathSegmentName): Operation { - $downloadPath = sprintf('/%s/{id}/download/{property}', $pathSegmentName); + $downloadPath = \sprintf('/%s/{id}/download/{property}', $pathSegmentName); return $getOperation ->withUriTemplate($downloadPath) diff --git a/src/AttributeReader/AttributeReader.php b/src/AttributeReader/AttributeReader.php index 4434fe71..1fac9337 100644 --- a/src/AttributeReader/AttributeReader.php +++ b/src/AttributeReader/AttributeReader.php @@ -48,14 +48,14 @@ public function isConfigured(object|string $class): bool private function resolveClassName(object|string|null $class): string { - $error = sprintf('$class passed to %s must be a valid class FQN or object.', __CLASS__); + $error = \sprintf('$class passed to %s must be a valid class FQN or object.', __CLASS__); if (null === $class) { throw new InvalidArgumentException($error . ' It is null.'); } if (\is_string($class)) { if (!class_exists($class)) { - throw new InvalidArgumentException(sprintf('%s %s is not a class.', $error, $class)); + throw new InvalidArgumentException(\sprintf('%s %s is not a class.', $error, $class)); } return $class; @@ -103,7 +103,7 @@ private function findAttributeConfiguration($class, string $annotationClass): ar if (!\count($attributes)) { $attributes = $this->getConfigurationFromTraits($reflection, $annotationClass); if (!\count($attributes)) { - throw new InvalidArgumentException(sprintf('%s does not have %s annotation', \is_object($class) ? $class::class : $class, $annotationClass)); + throw new InvalidArgumentException(\sprintf('%s does not have %s annotation', \is_object($class) ? $class::class : $class, $annotationClass)); } } } diff --git a/src/AttributeReader/PublishableAttributeReader.php b/src/AttributeReader/PublishableAttributeReader.php index 10ad799a..608e19a6 100644 --- a/src/AttributeReader/PublishableAttributeReader.php +++ b/src/AttributeReader/PublishableAttributeReader.php @@ -27,7 +27,7 @@ public function getConfiguration(object|string $class): Publishable { $publishable = $this->getClassAttributeConfiguration($class, Publishable::class); if (!$publishable instanceof Publishable) { - throw new \LogicException(sprintf('getClassAnnotationConfiguration should return the type %s', Publishable::class)); + throw new \LogicException(\sprintf('getClassAnnotationConfiguration should return the type %s', Publishable::class)); } return $publishable; diff --git a/src/AttributeReader/TimestampedAttributeReader.php b/src/AttributeReader/TimestampedAttributeReader.php index a38c48e4..2084df8f 100644 --- a/src/AttributeReader/TimestampedAttributeReader.php +++ b/src/AttributeReader/TimestampedAttributeReader.php @@ -24,7 +24,7 @@ public function getConfiguration(object|string $class): Timestamped { $timestamped = $this->getClassAttributeConfiguration($class, Timestamped::class); if (!$timestamped instanceof Timestamped) { - throw new \LogicException(sprintf('getClassAnnotationConfiguration should return the type %s', Timestamped::class)); + throw new \LogicException(\sprintf('getClassAnnotationConfiguration should return the type %s', Timestamped::class)); } return $timestamped; diff --git a/src/AttributeReader/UploadableAttributeReader.php b/src/AttributeReader/UploadableAttributeReader.php index 12c1f7eb..9810b443 100644 --- a/src/AttributeReader/UploadableAttributeReader.php +++ b/src/AttributeReader/UploadableAttributeReader.php @@ -40,14 +40,14 @@ public function isConfigured(object|string $class): bool if (!$isConfigured || $this->imagineBundleEnabled || !is_a($class, ImagineFiltersInterface::class)) { return $isConfigured; } - throw new BadMethodCallException(sprintf('LiipImagineBundle is not enabled/installed so you should not configure Imagine filters on %s', \is_string($class) ? $class : $class::class)); + throw new BadMethodCallException(\sprintf('LiipImagineBundle is not enabled/installed so you should not configure Imagine filters on %s', \is_string($class) ? $class : $class::class)); } public function getConfiguration(object|string $class): Uploadable { $uploadable = $this->getClassAttributeConfiguration($class, Uploadable::class); if (!$uploadable instanceof Uploadable) { - throw new \LogicException(sprintf('getClassAnnotationConfiguration should return the type %s', Uploadable::class)); + throw new \LogicException(\sprintf('getClassAnnotationConfiguration should return the type %s', Uploadable::class)); } return $uploadable; @@ -68,13 +68,13 @@ public function getPropertyConfiguration(\ReflectionProperty $property): Uploada { $attributes = $property->getAttributes(UploadableField::class); if (!\count($attributes)) { - throw new InvalidArgumentException(sprintf('%s::%s does not have %s annotation', $property->getDeclaringClass()->getName(), $property->getName(), UploadableField::class)); + throw new InvalidArgumentException(\sprintf('%s::%s does not have %s annotation', $property->getDeclaringClass()->getName(), $property->getName(), UploadableField::class)); } /** @var UploadableField $attribute */ $attribute = $attributes[0]->newInstance(); if (!$this->imagineBundleEnabled && null !== $attribute->imagineFilters && \count($attribute->imagineFilters)) { - throw new BadMethodCallException(sprintf('LiipImagineBundle is not enabled/installed so you should not configure Imagine filters on %s::$%s', $property->class, $property->getName())); + throw new BadMethodCallException(\sprintf('LiipImagineBundle is not enabled/installed so you should not configure Imagine filters on %s::$%s', $property->class, $property->getName())); } return $attribute; @@ -86,7 +86,7 @@ public function getPropertyConfiguration(\ReflectionProperty $property): Uploada public function getConfiguredProperties(object|string $data, bool $skipUploadableCheck = false): \Generator { if (!$skipUploadableCheck && !$this->isConfigured($data)) { - throw new UnsupportedAnnotationException(sprintf('Cannot get field configuration for %s: is it not configured as Uploadable', \is_string($data) ? $data : $data::class)); + throw new UnsupportedAnnotationException(\sprintf('Cannot get field configuration for %s: is it not configured as Uploadable', \is_string($data) ? $data : $data::class)); } $found = false; @@ -100,7 +100,7 @@ public function getConfiguredProperties(object|string $data, bool $skipUploadabl } } if (!$found) { - throw new UnsupportedAnnotationException(sprintf('No field configurations on your Uploadable component %s.', \is_string($data) ? $data : $data::class)); + throw new UnsupportedAnnotationException(\sprintf('No field configurations on your Uploadable component %s.', \is_string($data) ? $data : $data::class)); } } } diff --git a/src/Command/RefreshTokensExpireCommand.php b/src/Command/RefreshTokensExpireCommand.php index 699cea98..508aa2b4 100644 --- a/src/Command/RefreshTokensExpireCommand.php +++ b/src/Command/RefreshTokensExpireCommand.php @@ -66,10 +66,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($username = (string) $input->getArgument('username')) { $user = $this->repository->findOneBy([$input->getOption('field') => $username]); if (!$user) { - throw new EntityNotFoundException(sprintf('User with username "%s" not found.', $username)); + throw new EntityNotFoundException(\sprintf('User with username "%s" not found.', $username)); } $this->storage->expireAll($user); - $output->writeln(sprintf('RefreshTokens for user %s successfully expired.', $username)); + $output->writeln(\sprintf('RefreshTokens for user %s successfully expired.', $username)); } else { $this->storage->expireAll(null); $output->writeln('RefreshTokens for all users successfully expired.'); diff --git a/src/Command/UserCreateCommand.php b/src/Command/UserCreateCommand.php index 993c11af..c3b140af 100644 --- a/src/Command/UserCreateCommand.php +++ b/src/Command/UserCreateCommand.php @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->userFactory->create($username, $password, $email, $inactive, $superAdmin, $admin, $overwrite); - $output->writeln(sprintf('Created user: %s', $username)); + $output->writeln(\sprintf('Created user: %s', $username)); return 0; } diff --git a/src/DependencyInjection/CompilerPass/FlysystemCompilerPass.php b/src/DependencyInjection/CompilerPass/FlysystemCompilerPass.php index b95d4bdf..a00032fb 100644 --- a/src/DependencyInjection/CompilerPass/FlysystemCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/FlysystemCompilerPass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container): void $attributes['alias'], $attributes['config'] ?? [], ]); - $serviceName = sprintf('api_components.filesystem.%s', $attributes['alias']); + $serviceName = \sprintf('api_components.filesystem.%s', $attributes['alias']); $container ->setDefinition($serviceName, $definition) ->addTag(FilesystemProvider::FILESYSTEM_TAG, ['alias' => $attributes['alias']]); diff --git a/src/DependencyInjection/SilverbackApiComponentsExtension.php b/src/DependencyInjection/SilverbackApiComponentsExtension.php index 6c97f0f6..a0f4c4eb 100644 --- a/src/DependencyInjection/SilverbackApiComponentsExtension.php +++ b/src/DependencyInjection/SilverbackApiComponentsExtension.php @@ -114,7 +114,7 @@ public function load(array $configs, ContainerBuilder $container): void $definition->setArgument('$cookieProvider', $cookieProvider); $definition = $container->getDefinition('silverback.security.jwt_manager'); - $definition->setArgument('$userProvider', new Reference(sprintf('security.user.provider.concrete.%s', $config['refresh_token']['database_user_provider']))); + $definition->setArgument('$userProvider', new Reference(\sprintf('security.user.provider.concrete.%s', $config['refresh_token']['database_user_provider']))); $definition->setArgument('$storage', new Reference($config['refresh_token']['handler_id'])); $definition = $container->getDefinition(PublishableStatusChecker::class); @@ -275,8 +275,8 @@ private function prependDoctrineConfiguration(ContainerBuilder $container): void private function appendMappingPaths(&$mappingPaths, $srcBase, $name): void { $configBasePath = $srcBase . '/Resources/config/api_platform'; - $mappingPaths[] = sprintf('%s/%s/resource.xml', $configBasePath, $name); - $propertiesPath = sprintf('%s/%s/properties.xml', $configBasePath, $name); + $mappingPaths[] = \sprintf('%s/%s/resource.xml', $configBasePath, $name); + $propertiesPath = \sprintf('%s/%s/properties.xml', $configBasePath, $name); if (file_exists($propertiesPath)) { $mappingPaths[] = $propertiesPath; } @@ -300,7 +300,7 @@ private function prependApiPlatformConfig(ContainerBuilder $container, array $co 'api_platform', [ 'title' => $websiteName, - 'description' => sprintf('API for %s', $websiteName), + 'description' => \sprintf('API for %s', $websiteName), 'defaults' => [ 'pagination_client_items_per_page' => true, 'pagination_maximum_items_per_page' => 100, diff --git a/src/EventListener/Api/FormApiEventListener.php b/src/EventListener/Api/FormApiEventListener.php index ae1d653e..00b63ac7 100644 --- a/src/EventListener/Api/FormApiEventListener.php +++ b/src/EventListener/Api/FormApiEventListener.php @@ -41,7 +41,7 @@ public function __construct( FormViewFactory $formViewFactory ) { if (!$serializer instanceof DecoderInterface) { - throw new \InvalidArgumentException(sprintf('$serializer must be also be an instance of %s', DecoderInterface::class)); + throw new \InvalidArgumentException(\sprintf('$serializer must be also be an instance of %s', DecoderInterface::class)); } $this->formSubmitHelper = $formSubmitHelper; $this->serializeFormatResolver = $serializeFormatResolver; diff --git a/src/EventListener/Api/RouteEventListener.php b/src/EventListener/Api/RouteEventListener.php index 039d22b7..cfff476c 100644 --- a/src/EventListener/Api/RouteEventListener.php +++ b/src/EventListener/Api/RouteEventListener.php @@ -66,7 +66,7 @@ public function onPostWrite(ViewEvent $event): void } $entityManager = $this->registry->getManagerForClass($className = Route::class); if (!$entityManager) { - throw new InvalidArgumentException(sprintf('Could not find entity manager for %s', $className)); + throw new InvalidArgumentException(\sprintf('Could not find entity manager for %s', $className)); } // create a redirect from the old route diff --git a/src/EventListener/Form/EntityPersistFormListener.php b/src/EventListener/Form/EntityPersistFormListener.php index 9a19841b..a8f6547e 100644 --- a/src/EventListener/Form/EntityPersistFormListener.php +++ b/src/EventListener/Form/EntityPersistFormListener.php @@ -59,7 +59,7 @@ public function init( UserDataProcessor $userDataProcessor ): void { if (!$normalizer instanceof DenormalizerInterface) { - throw new InvalidArgumentException(sprintf('$normalizer must also implement %s', DenormalizerInterface::class)); + throw new InvalidArgumentException(\sprintf('$normalizer must also implement %s', DenormalizerInterface::class)); } $this->initRegistry($registry); $this->timestampedAnnotationReader = $timestampedAnnotationReader; @@ -86,7 +86,7 @@ public function __invoke(FormSuccessEvent $event): void $entityManager = $this->registry->getManagerForClass($this->dataClass); if (!$entityManager) { - throw new InvalidArgumentException(sprintf('Could not find entity manager for %s', $this->dataClass)); + throw new InvalidArgumentException(\sprintf('Could not find entity manager for %s', $this->dataClass)); } if ($data instanceof AbstractUser) { diff --git a/src/Factory/Uploadable/ApiUrlGenerator.php b/src/Factory/Uploadable/ApiUrlGenerator.php index 54dbd92c..dc1130a2 100644 --- a/src/Factory/Uploadable/ApiUrlGenerator.php +++ b/src/Factory/Uploadable/ApiUrlGenerator.php @@ -29,6 +29,6 @@ public function generateUrl(object $object, string $fileProperty, Filesystem $fi $resourceId = $this->iriConverter->getIriFromResource($object); $converter = new CamelCaseToSnakeCaseNameConverter(); - return $this->urlHelper->getAbsoluteUrl(sprintf('%s/download/%s', $resourceId, $converter->normalize($fileProperty))); + return $this->urlHelper->getAbsoluteUrl(\sprintf('%s/download/%s', $resourceId, $converter->normalize($fileProperty))); } } diff --git a/src/Factory/Uploadable/MediaObjectFactory.php b/src/Factory/Uploadable/MediaObjectFactory.php index 355e1341..15f6b048 100644 --- a/src/Factory/Uploadable/MediaObjectFactory.php +++ b/src/Factory/Uploadable/MediaObjectFactory.php @@ -90,7 +90,7 @@ public function createMediaObjects(object $object): ?ArrayCollection } if (!$urlGenerator instanceof UploadableUrlGeneratorInterface) { - throw new InvalidArgumentException(sprintf('The url generator provided must implement %s', UploadableUrlGeneratorInterface::class)); + throw new InvalidArgumentException(\sprintf('The url generator provided must implement %s', UploadableUrlGeneratorInterface::class)); } $contentUrl = $urlGenerator->generateUrl($object, $fileProperty, $filesystem, $path); diff --git a/src/Factory/User/Mailer/AbstractUserEmailFactory.php b/src/Factory/User/Mailer/AbstractUserEmailFactory.php index 6d3dbffb..403da902 100644 --- a/src/Factory/User/Mailer/AbstractUserEmailFactory.php +++ b/src/Factory/User/Mailer/AbstractUserEmailFactory.php @@ -122,7 +122,7 @@ protected function createEmailMessage(array $context = []): ?TemplatedEmail $event = new UserEmailMessageEvent(static::class, $email); $this->eventDispatcher->dispatch($event); - $email->getHeaders()->addTextHeader('X-Message-ID', sprintf('%s-%s', static::MESSAGE_ID_PREFIX, TokenGenerator::generateToken())); + $email->getHeaders()->addTextHeader('X-Message-ID', \sprintf('%s-%s', static::MESSAGE_ID_PREFIX, TokenGenerator::generateToken())); return $event->getEmail(); } @@ -155,7 +155,7 @@ private function getTokenPath(): string $this->defaultRedirectPath; if (null === $path) { - throw new UnexpectedValueException(sprintf('The querystring key `%s` could not be found in the request to generate a token URL', $this->redirectPathQueryKey)); + throw new UnexpectedValueException(\sprintf('The querystring key `%s` could not be found in the request to generate a token URL', $this->redirectPathQueryKey)); } return $path; @@ -178,7 +178,7 @@ private function validateContext(array $context): void $contextKeys = static::getContextKeys(); $keys = array_keys($context); if (\count($differences = array_diff($contextKeys, $keys))) { - throw new InvalidArgumentException(sprintf('You have not specified required context key(s) for the user email factory factory `%s` (expected: `%s`)', static::class, implode('`, `', $differences))); + throw new InvalidArgumentException(\sprintf('You have not specified required context key(s) for the user email factory factory `%s` (expected: `%s`)', static::class, implode('`, `', $differences))); } } diff --git a/src/Filter/OrSearchFilter.php b/src/Filter/OrSearchFilter.php index def3f507..4defdac7 100644 --- a/src/Filter/OrSearchFilter.php +++ b/src/Filter/OrSearchFilter.php @@ -123,7 +123,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB if (!$this->hasValidValues($values, $this->getDoctrineFieldType($property, $resourceClass))) { $this->logger->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)), + 'exception' => new InvalidArgumentException(\sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)), ]); return; @@ -147,7 +147,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB if (!$this->hasValidValues($values, $doctrineTypeField)) { $this->logger->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)), + 'exception' => new InvalidArgumentException(\sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)), ]); return; @@ -177,7 +177,7 @@ protected function createWrapCase(bool $caseSensitive): \Closure return $expr; } - return sprintf('LOWER(%s)', $expr); + return \sprintf('LOWER(%s)', $expr); }; } @@ -191,12 +191,12 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild if (\is_array($value)) { foreach ($value as $i => $v) { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' = ' . $wrapCase(':%s'), $alias, $field, $valueParameter . $i)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' = ' . $wrapCase(':%s'), $alias, $field, $valueParameter . $i)) ->setParameter($valueParameter . $i, $v); } } else { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' = ' . $wrapCase(':%s'), $alias, $field, $valueParameter)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' = ' . $wrapCase(':%s'), $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } break; @@ -204,12 +204,12 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild if (\is_array($value)) { foreach ($value as $i => $v) { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s, \'%%\')'), $alias, $field, $valueParameter . $i)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s, \'%%\')'), $alias, $field, $valueParameter . $i)) ->setParameter($valueParameter . $i, $v); } } else { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s, \'%%\')'), $alias, $field, $valueParameter)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s, \'%%\')'), $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } break; @@ -217,12 +217,12 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild if (\is_array($value)) { foreach ($value as $i => $v) { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(:%s, \'%%\')'), $alias, $field, $valueParameter . $i)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(:%s, \'%%\')'), $alias, $field, $valueParameter . $i)) ->setParameter($valueParameter . $i, $v); } } else { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(:%s, \'%%\')'), $alias, $field, $valueParameter)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(:%s, \'%%\')'), $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } break; @@ -230,12 +230,12 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild if (\is_array($value)) { foreach ($value as $i => $v) { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s)'), $alias, $field, $valueParameter . $i)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s)'), $alias, $field, $valueParameter . $i)) ->setParameter($valueParameter . $i, $v); } } else { $queryBuilder - ->orWhere(sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s)'), $alias, $field, $valueParameter)) + ->orWhere(\sprintf($wrapCase('%s.%s') . ' LIKE ' . $wrapCase('CONCAT(\'%%\', :%s)'), $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } break; @@ -243,17 +243,17 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild if (\is_array($value)) { foreach ($value as $i => $v) { $queryBuilder - ->orWhere(sprintf($wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(:%3$s, \'%%\')') . ' OR ' . $wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(\'%% \', :%3$s, \'%%\')'), $alias, $field, $valueParameter . $i)) + ->orWhere(\sprintf($wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(:%3$s, \'%%\')') . ' OR ' . $wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(\'%% \', :%3$s, \'%%\')'), $alias, $field, $valueParameter . $i)) ->setParameter($valueParameter . $i, $v); } } else { $queryBuilder - ->orWhere(sprintf($wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(:%3$s, \'%%\')') . ' OR ' . $wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(\'%% \', :%3$s, \'%%\')'), $alias, $field, $valueParameter)) + ->orWhere(\sprintf($wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(:%3$s, \'%%\')') . ' OR ' . $wrapCase('%1$s.%2$s') . ' LIKE ' . $wrapCase('CONCAT(\'%% \', :%3$s, \'%%\')'), $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } break; default: - throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy)); + throw new InvalidArgumentException(\sprintf('strategy %s does not exist.', $strategy)); } } } diff --git a/src/Form/Type/User/ChangePasswordType.php b/src/Form/Type/User/ChangePasswordType.php index 2d103024..8d4867b8 100644 --- a/src/Form/Type/User/ChangePasswordType.php +++ b/src/Form/Type/User/ChangePasswordType.php @@ -37,7 +37,7 @@ class ChangePasswordType extends AbstractType public function __construct(Security $security, UserRepositoryInterface $userRepository, string $userClass) { if (!is_subclass_of($userClass, AbstractUser::class)) { - throw new InvalidArgumentException(sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $userClass, __CLASS__, AbstractUser::class)); + throw new InvalidArgumentException(\sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $userClass, __CLASS__, AbstractUser::class)); } $this->security = $security; $this->userRepository = $userRepository; diff --git a/src/Form/Type/User/NewEmailAddressType.php b/src/Form/Type/User/NewEmailAddressType.php index b42ac1d5..6beaa18e 100644 --- a/src/Form/Type/User/NewEmailAddressType.php +++ b/src/Form/Type/User/NewEmailAddressType.php @@ -34,7 +34,7 @@ class NewEmailAddressType extends AbstractType public function __construct(Security $security, UserRepositoryInterface $userRepository, string $userClass) { if (!is_subclass_of($userClass, AbstractUser::class)) { - throw new InvalidArgumentException(sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); + throw new InvalidArgumentException(\sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); } $this->security = $security; $this->userRepository = $userRepository; @@ -45,11 +45,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void { $data = $this->security->getUser(); if (!$data instanceof AbstractUser) { - throw new InvalidArgumentException(sprintf('The logged in user must be an instance of %s to use the form %s', AbstractUser::class, __CLASS__)); + throw new InvalidArgumentException(\sprintf('The logged in user must be an instance of %s to use the form %s', AbstractUser::class, __CLASS__)); } $help = null; if ($data instanceof AbstractUser && $data->getNewEmailAddress()) { - $help = sprintf('You have requested to change your email to `%s`. Please check your inbox to validate this email address.', $data->getNewEmailAddress()); + $help = \sprintf('You have requested to change your email to `%s`. Please check your inbox to validate this email address.', $data->getNewEmailAddress()); } $builder ->add( diff --git a/src/Form/Type/User/PasswordUpdateType.php b/src/Form/Type/User/PasswordUpdateType.php index 46ef617f..de36cb45 100644 --- a/src/Form/Type/User/PasswordUpdateType.php +++ b/src/Form/Type/User/PasswordUpdateType.php @@ -39,7 +39,7 @@ public function __construct( private readonly string $userClass, ) { if (!is_subclass_of($this->userClass, AbstractUser::class)) { - throw new InvalidArgumentException(sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); + throw new InvalidArgumentException(\sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); } } diff --git a/src/Form/Type/User/UserRegisterType.php b/src/Form/Type/User/UserRegisterType.php index f74a86d8..849455ee 100644 --- a/src/Form/Type/User/UserRegisterType.php +++ b/src/Form/Type/User/UserRegisterType.php @@ -35,7 +35,7 @@ public function __construct(string $userClass) { $this->userClass = $userClass; if (!is_subclass_of($this->userClass, AbstractUser::class)) { - throw new InvalidArgumentException(sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); + throw new InvalidArgumentException(\sprintf('The user class `%s` provided to the form `%s` must extend `%s`', $this->userClass, __CLASS__, AbstractUser::class)); } } diff --git a/src/Helper/Form/FormCachePurger.php b/src/Helper/Form/FormCachePurger.php index 50a74a8e..c28175aa 100644 --- a/src/Helper/Form/FormCachePurger.php +++ b/src/Helper/Form/FormCachePurger.php @@ -43,7 +43,7 @@ public function clear($cacheDir = null): void /** @var Form[] $forms */ $forms = $repo->findAll(); } catch (\Exception $exception) { - $this->dispatcher->dispatch(new CommandLogEvent(sprintf('Could not clear form cache: %s', $exception->getMessage()))); + $this->dispatcher->dispatch(new CommandLogEvent(\sprintf('Could not clear form cache: %s', $exception->getMessage()))); return; } @@ -65,7 +65,7 @@ private function updateFormTimestamp(Form $form): void $dateTime = new \DateTime(); $timestamp = filemtime($reflector->getFileName()); - $this->dispatcher->dispatch(new CommandLogEvent(sprintf('Checking timestamp for %s', $formClass))); + $this->dispatcher->dispatch(new CommandLogEvent(\sprintf('Checking timestamp for %s', $formClass))); if (!$form->modifiedAt || $timestamp !== $form->modifiedAt->getTimestamp()) { $dateTime->setTimestamp($timestamp); diff --git a/src/Helper/Form/FormSubmitHelper.php b/src/Helper/Form/FormSubmitHelper.php index 8f73d33b..3e5cbe16 100644 --- a/src/Helper/Form/FormSubmitHelper.php +++ b/src/Helper/Form/FormSubmitHelper.php @@ -68,7 +68,7 @@ public function handleSuccess(Form $form) private function getRootData(FormInterface $form, $content): array { if (!isset($content[$form->getName()])) { - throw new UnprocessableEntityHttpException(sprintf('Form object key could not be found. Expected: %s: { "input_name": "input_value" }', $form->getName())); + throw new UnprocessableEntityHttpException(\sprintf('Form object key could not be found. Expected: %s: { "input_name": "input_value" }', $form->getName())); } return $content[$form->getName()]; diff --git a/src/Helper/Publishable/PublishableStatusChecker.php b/src/Helper/Publishable/PublishableStatusChecker.php index c24eae78..3aee6342 100644 --- a/src/Helper/Publishable/PublishableStatusChecker.php +++ b/src/Helper/Publishable/PublishableStatusChecker.php @@ -56,7 +56,7 @@ public function isGranted($class): bool public function isActivePublishedAt(object $object): bool { if (!$this->attributeReader->isConfigured($object)) { - throw new \InvalidArgumentException(sprintf('Object of class %s does not implement publishable configuration.', $object::class)); + throw new \InvalidArgumentException(\sprintf('Object of class %s does not implement publishable configuration.', $object::class)); } $value = $this->getClassMetadata($object)->getFieldValue($object, $this->attributeReader->getConfiguration($object)->fieldName); @@ -67,7 +67,7 @@ public function isActivePublishedAt(object $object): bool public function hasPublicationDate(object $object): bool { if (!$this->attributeReader->isConfigured($object)) { - throw new \InvalidArgumentException(sprintf('Object of class %s does not implement publishable configuration.', $object::class)); + throw new \InvalidArgumentException(\sprintf('Object of class %s does not implement publishable configuration.', $object::class)); } return null !== $this->getClassMetadata($object)->getFieldValue($object, $this->attributeReader->getConfiguration($object)->fieldName); diff --git a/src/Helper/RefererUrlResolver.php b/src/Helper/RefererUrlResolver.php index b7466248..e1ab0674 100644 --- a/src/Helper/RefererUrlResolver.php +++ b/src/Helper/RefererUrlResolver.php @@ -70,11 +70,11 @@ private function getUrlPrefix(string $url, string $headerName): string ] = array_merge($defaults, parse_url($url) ?: []); if (null === $host) { - throw new UnparseableRequestHeaderException(sprintf('Could not extract `host` while parsing the `%s` header', $headerName)); + throw new UnparseableRequestHeaderException(\sprintf('Could not extract `host` while parsing the `%s` header', $headerName)); } if (null === $scheme) { - throw new UnparseableRequestHeaderException(sprintf('Could not extract `scheme` while parsing the `%s` header', $headerName)); + throw new UnparseableRequestHeaderException(\sprintf('Could not extract `scheme` while parsing the `%s` header', $headerName)); } $url = $scheme . '://' . $host; diff --git a/src/Helper/Route/RouteGenerator.php b/src/Helper/Route/RouteGenerator.php index 0287493e..19a8b0c9 100644 --- a/src/Helper/Route/RouteGenerator.php +++ b/src/Helper/Route/RouteGenerator.php @@ -61,7 +61,7 @@ public function create(RoutableInterface $object, ?Route $route = null): Route { $entityManager = $this->registry->getManagerForClass($className = $object::class); if (!$entityManager) { - throw new InvalidArgumentException(sprintf('Could not find entity manager for %s', $className)); + throw new InvalidArgumentException(\sprintf('Could not find entity manager for %s', $className)); } $uow = $entityManager->getUnitOfWork(); /** @var RoutableInterface $originalPage */ @@ -110,8 +110,8 @@ private function resolveConflicts(string $name, string $path): array $conflictCounter = 0; while ($this->conflictExists($name, $path, $conflicts)) { ++$conflictCounter; - $name = sprintf('%s-%d', $baseName, $conflictCounter); - $path = sprintf('%s-%d', $basePath, $conflictCounter); + $name = \sprintf('%s-%d', $baseName, $conflictCounter); + $path = \sprintf('%s-%d', $basePath, $conflictCounter); } return [$name, $path]; diff --git a/src/Helper/Uploadable/UploadableFileManager.php b/src/Helper/Uploadable/UploadableFileManager.php index 076ad975..492ee461 100644 --- a/src/Helper/Uploadable/UploadableFileManager.php +++ b/src/Helper/Uploadable/UploadableFileManager.php @@ -200,7 +200,7 @@ public function getFileResponse(object $object, string $property, bool $forceDow throw new NotFoundHttpException($exception->getMessage()); } if (!$this->annotationReader->isFieldConfigured($reflectionProperty)) { - throw new NotFoundHttpException(sprintf('field configuration not found for %s', $property)); + throw new NotFoundHttpException(\sprintf('field configuration not found for %s', $property)); } $propertyConfiguration = $this->annotationReader->getPropertyConfiguration($reflectionProperty); @@ -257,10 +257,10 @@ private function copyFilepath(object $object, UploadableField $fieldConfiguratio $basename = $pathInfo['filename']; $extension = $pathInfo['extension'] ?? null; if (!empty($extension)) { - $extension = sprintf('.%s', $extension); + $extension = \sprintf('.%s', $extension); } $num = 1; - while ($filesystem->fileExists($newFilepath = sprintf('%s_%d%s', $basename, $num, $extension))) { + while ($filesystem->fileExists($newFilepath = \sprintf('%s_%d%s', $basename, $num, $extension))) { ++$num; } $filesystem->copy($currentFilepath, $newFilepath); diff --git a/src/Helper/User/UserDataProcessor.php b/src/Helper/User/UserDataProcessor.php index 9aff2149..ad80506e 100644 --- a/src/Helper/User/UserDataProcessor.php +++ b/src/Helper/User/UserDataProcessor.php @@ -50,7 +50,7 @@ public function updatePasswordConfirmationToken(string $usernameQuery): ?Abstrac $username = $user->getUsername(); if (!$username) { - throw new UnexpectedValueException(sprintf('The entity %s should have a username set to send a password reset email.', AbstractUser::class)); + throw new UnexpectedValueException(\sprintf('The entity %s should have a username set to send a password reset email.', AbstractUser::class)); } $user->setNewPasswordConfirmationToken($this->passwordHasher->hashPassword($user, $token = TokenGenerator::generateToken())); $user->plainNewPasswordConfirmationToken = $token; diff --git a/src/Imagine/FlysystemCacheResolver.php b/src/Imagine/FlysystemCacheResolver.php index 015a4afa..05a3f540 100644 --- a/src/Imagine/FlysystemCacheResolver.php +++ b/src/Imagine/FlysystemCacheResolver.php @@ -45,7 +45,7 @@ public function isStored($path, $filter): bool public function resolve($path, $filter): string { - return sprintf('%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/')); + return \sprintf('%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/')); } public function store(BinaryInterface $binary, $path, $filter): void diff --git a/src/Imagine/FlysystemDataLoader.php b/src/Imagine/FlysystemDataLoader.php index 4c8dde3d..612f7d4f 100644 --- a/src/Imagine/FlysystemDataLoader.php +++ b/src/Imagine/FlysystemDataLoader.php @@ -46,7 +46,7 @@ public function find($path): Binary // This should be finding the file that we have uploaded into a location already - source file locator if (false === $filesystem->fileExists($path)) { - throw new NotLoadableException(sprintf('Source image "%s" not found.', $path)); + throw new NotLoadableException(\sprintf('Source image "%s" not found.', $path)); } $mimeType = $filesystem->mimeType($path); diff --git a/src/Mercure/MercureAuthorization.php b/src/Mercure/MercureAuthorization.php index 3c5e1dc1..65299de0 100644 --- a/src/Mercure/MercureAuthorization.php +++ b/src/Mercure/MercureAuthorization.php @@ -126,9 +126,9 @@ private function buildAbsoluteUriTemplate(): string $host = $this->requestContext->getHost(); $defaultPort = $this->requestContext->isSecure() ? $this->requestContext->getHttpsPort() : $this->requestContext->getHttpPort(); if (80 !== $defaultPort && 443 !== $defaultPort) { - return sprintf('%s://%s:%d', $scheme, $host, $defaultPort); + return \sprintf('%s://%s:%d', $scheme, $host, $defaultPort); } - return sprintf('%s://%s', $scheme, $host); + return \sprintf('%s://%s', $scheme, $host); } } diff --git a/src/Mercure/MercureResourcePublisher.php b/src/Mercure/MercureResourcePublisher.php index 294d9760..774a6133 100644 --- a/src/Mercure/MercureResourcePublisher.php +++ b/src/Mercure/MercureResourcePublisher.php @@ -85,7 +85,7 @@ public function __construct( $this->expressionLanguage->addFunction($rawurlencode); $this->expressionLanguage->addFunction( - new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string => sprintf('iri(%s, %d)', $apiResource, $referenceType), static fn (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string => $iriConverter->getIriFromResource($apiResource, $referenceType)) + new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string => \sprintf('iri(%s, %d)', $apiResource, $referenceType), static fn (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string => $iriConverter->getIriFromResource($apiResource, $referenceType)) ); } } @@ -99,9 +99,9 @@ public function reset(): void public function add(object $item, ?string $type = null): void { - $property = sprintf('%sObjects', $type); + $property = \sprintf('%sObjects', $type); if (!isset($this->{$property})) { - throw new \InvalidArgumentException(sprintf('Cannot collect Mercure resource with type %s : the property %s does not exist.', $type, $property)); + throw new \InvalidArgumentException(\sprintf('Cannot collect Mercure resource with type %s : the property %s does not exist.', $type, $property)); } if (!is_iterable($item)) { @@ -170,12 +170,12 @@ private function getObjectMercureOptions(object $object): ?array } if (!\is_array($options)) { - throw new InvalidArgumentException(sprintf('The value of the "mercure" attribute of the "%s" resource class must be a boolean, an array of options or an expression returning this array, "%s" given.', $resourceClass, \gettype($options))); + throw new InvalidArgumentException(\sprintf('The value of the "mercure" attribute of the "%s" resource class must be a boolean, an array of options or an expression returning this array, "%s" given.', $resourceClass, \gettype($options))); } foreach ($options as $key => $value) { if (!isset(self::ALLOWED_KEYS[$key])) { - throw new InvalidArgumentException(sprintf('The option "%s" set in the "mercure" attribute of the "%s" resource does not exist. Existing options: "%s"', $key, $resourceClass, implode('", "', self::ALLOWED_KEYS))); + throw new InvalidArgumentException(\sprintf('The option "%s" set in the "mercure" attribute of the "%s" resource does not exist. Existing options: "%s"', $key, $resourceClass, implode('", "', self::ALLOWED_KEYS))); } } diff --git a/src/Metadata/Factory/PageDataMetadataFactory.php b/src/Metadata/Factory/PageDataMetadataFactory.php index 3973ed80..31862f98 100644 --- a/src/Metadata/Factory/PageDataMetadataFactory.php +++ b/src/Metadata/Factory/PageDataMetadataFactory.php @@ -40,19 +40,19 @@ public function create(string $resourceClass): PageDataMetadata { // needs to be a class if (!class_exists($resourceClass)) { - throw new PageDataNotFoundException(sprintf('`%s` was not found', $resourceClass)); + throw new PageDataNotFoundException(\sprintf('`%s` was not found', $resourceClass)); } // Check it is page data $reflection = new \ReflectionClass($resourceClass); if (!$reflection->implementsInterface(PageDataInterface::class)) { - throw new PageDataNotFoundException(sprintf('Resource class `%s` is not a valid page data resource', $resourceClass)); + throw new PageDataNotFoundException(\sprintf('Resource class `%s` is not a valid page data resource', $resourceClass)); } // Find the doctrine manager $manager = $this->registry->getManagerForClass($resourceClass); if (!$manager) { - throw new PageDataNotFoundException(sprintf('Cannot find manager for page data resource `%s`', $resourceClass)); + throw new PageDataNotFoundException(\sprintf('Cannot find manager for page data resource `%s`', $resourceClass)); } $classMetadata = $manager->getClassMetadata($resourceClass); diff --git a/src/Model/Uploadable/DataUriFile.php b/src/Model/Uploadable/DataUriFile.php index 846c7ff6..131da8de 100644 --- a/src/Model/Uploadable/DataUriFile.php +++ b/src/Model/Uploadable/DataUriFile.php @@ -65,7 +65,7 @@ private function decodePlainBase64(string $encoded): string $path = $this->getTempFileBasePath(); if (false === file_put_contents($path, $decoded)) { - throw new FileException(sprintf('Unable to write the file "%s"', $path)); + throw new FileException(\sprintf('Unable to write the file "%s"', $path)); } return $path; @@ -76,7 +76,7 @@ private function decodeDataUri(string $dataUriMatch, string $mimeType): string $target = $this->createTempFileTarget($mimeType); $content = urldecode($dataUriMatch); if (false === @fwrite($target->resource, $content)) { - throw new FileException(sprintf('Unable to write the file "%s"', $target->path)); + throw new FileException(\sprintf('Unable to write the file "%s"', $target->path)); } $this->closeFile($target); @@ -93,7 +93,7 @@ private function decodeBase64Data(string $mimeType, string $fullMatch): string } if (false === stream_copy_to_stream($source, $target->resource)) { - throw new FileException(sprintf('Unable to write the file "%s"', $target->path)); + throw new FileException(\sprintf('Unable to write the file "%s"', $target->path)); } if (false === @fclose($source)) { @@ -108,7 +108,7 @@ private function decodeBase64Data(string $mimeType, string $fullMatch): string private function getTempFileBasePath(): string { if (false === $path = tempnam($directory = sys_get_temp_dir(), 'DataUriFile')) { - throw new FileException(sprintf('Unable to create a file into the "%s" directory: %s', $directory, $path)); + throw new FileException(\sprintf('Unable to create a file into the "%s" directory: %s', $directory, $path)); } return $path; @@ -123,10 +123,10 @@ private function createTempFileTarget(string $mimeType): object } if (false === $target = @fopen($path, 'wb+')) { - throw new FileException(sprintf('Unable to open the file "%s"', $path)); + throw new FileException(\sprintf('Unable to open the file "%s"', $path)); } - $class = new class() { + $class = new class { public string $path; public $resource; }; @@ -139,7 +139,7 @@ private function createTempFileTarget(string $mimeType): object private function closeFile(object $target): void { if (false === @fclose($target->resource)) { - throw new FileException(sprintf('Unable to close the file "%s"', $target->path)); + throw new FileException(\sprintf('Unable to close the file "%s"', $target->path)); } } } diff --git a/src/OpenApi/OpenApiFactory.php b/src/OpenApi/OpenApiFactory.php index deb8106e..8e8d8c19 100644 --- a/src/OpenApi/OpenApiFactory.php +++ b/src/OpenApi/OpenApiFactory.php @@ -75,7 +75,7 @@ private function removeResources(OpenApi $openApi, array $resourceClassNames): v public static function getExtendedVersion(string $version): string { - return sprintf('%s (%s)', $version, Versions::getVersion('components-web-app/api-components-bundle')); + return \sprintf('%s (%s)', $version, Versions::getVersion('components-web-app/api-components-bundle')); } public function __invoke(array $context = []): OpenApi diff --git a/src/Repository/Core/ComponentPositionRepository.php b/src/Repository/Core/ComponentPositionRepository.php index 60a27c30..94b6a042 100644 --- a/src/Repository/Core/ComponentPositionRepository.php +++ b/src/Repository/Core/ComponentPositionRepository.php @@ -45,7 +45,7 @@ public function findByPageDataProperties(array $properties): array $qb = $this->createQueryBuilder('cp'); $expr = $qb->expr(); foreach ($properties as $index => $property) { - $key = sprintf(':positionName%d', $index); + $key = \sprintf(':positionName%d', $index); $qb->orWhere($expr->eq('cp.pageDataProperty', $key)); $qb->setParameter($key, $property); } diff --git a/src/Repository/Core/RefreshTokenRepository.php b/src/Repository/Core/RefreshTokenRepository.php index 1ea67255..70978119 100644 --- a/src/Repository/Core/RefreshTokenRepository.php +++ b/src/Repository/Core/RefreshTokenRepository.php @@ -32,7 +32,7 @@ class RefreshTokenRepository extends ServiceEntityRepository public function __construct(ManagerRegistry $registry, string $entityClass) { if (!is_subclass_of($entityClass, AbstractRefreshToken::class)) { - throw new InvalidArgumentException(sprintf('The entity class `%s` used for the repository `%s` must be a subclass of `%s`', $entityClass, __CLASS__, AbstractRefreshToken::class)); + throw new InvalidArgumentException(\sprintf('The entity class `%s` used for the repository `%s` must be a subclass of `%s`', $entityClass, __CLASS__, AbstractRefreshToken::class)); } parent::__construct($registry, $entityClass); } diff --git a/src/Repository/User/UserRepository.php b/src/Repository/User/UserRepository.php index f371aced..9079db23 100644 --- a/src/Repository/User/UserRepository.php +++ b/src/Repository/User/UserRepository.php @@ -34,7 +34,7 @@ class UserRepository extends ServiceEntityRepository implements UserRepositoryIn public function __construct(ManagerRegistry $registry, string $entityClass, int $passwordRequestTimeout, int $newEmailConfirmTimeout) { if (!is_subclass_of($entityClass, AbstractUser::class)) { - throw new InvalidArgumentException(sprintf('The entity class `%s` used for the repository `%s` must be a subclass of `%s`', $entityClass, __CLASS__, AbstractUser::class)); + throw new InvalidArgumentException(\sprintf('The entity class `%s` used for the repository `%s` must be a subclass of `%s`', $entityClass, __CLASS__, AbstractUser::class)); } parent::__construct($registry, $entityClass); $this->passwordRequestTimeout = $passwordRequestTimeout; @@ -53,7 +53,7 @@ public function findOneByEmail(string $value): ?AbstractUser public function findOneWithPasswordResetToken(string $username): ?AbstractUser { $minimumRequestDateTime = new \DateTime(); - $minimumRequestDateTime->modify(sprintf('-%d seconds', $this->passwordRequestTimeout)); + $minimumRequestDateTime->modify(\sprintf('-%d seconds', $this->passwordRequestTimeout)); return $this->createQueryBuilder('u') ->andWhere('LOWER(u.username) = :username') @@ -68,7 +68,7 @@ public function findOneWithPasswordResetToken(string $username): ?AbstractUser public function findOneByUsernameAndNewEmailAddress(string $username, string $email): ?AbstractUser { $minimumRequestDateTime = new \DateTime(); - $minimumRequestDateTime->modify(sprintf('-%d seconds', $this->newEmailConfirmTimeout)); + $minimumRequestDateTime->modify(\sprintf('-%d seconds', $this->newEmailConfirmTimeout)); return $this->createQueryBuilder('u') ->andWhere('LOWER(u.username) = :username') diff --git a/src/Security/Voter/AbstractRoutableVoter.php b/src/Security/Voter/AbstractRoutableVoter.php index 82c2df53..255f68fa 100644 --- a/src/Security/Voter/AbstractRoutableVoter.php +++ b/src/Security/Voter/AbstractRoutableVoter.php @@ -29,7 +29,7 @@ protected function supports(string $attribute, $subject): bool return false; } if (!$subject instanceof RoutableInterface) { - throw new \InvalidArgumentException(sprintf('$subject must be of type `%s`', RoutableInterface::class)); + throw new \InvalidArgumentException(\sprintf('$subject must be of type `%s`', RoutableInterface::class)); } return true; diff --git a/src/Security/Voter/RouteVoter.php b/src/Security/Voter/RouteVoter.php index d5a93133..e656415a 100644 --- a/src/Security/Voter/RouteVoter.php +++ b/src/Security/Voter/RouteVoter.php @@ -45,7 +45,7 @@ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): { foreach ($this->config as $routeConfig) { $routeRegex = str_replace('\*', '(.*)', preg_quote($routeConfig['route'], '#')); - if (!$this->resourceAccessChecker->isGranted($subject::class, $routeConfig['security']) && preg_match(sprintf('#%s#', $routeRegex), $subject->getPath())) { + if (!$this->resourceAccessChecker->isGranted($subject::class, $routeConfig['security']) && preg_match(\sprintf('#%s#', $routeRegex), $subject->getPath())) { return false; } } diff --git a/src/Serializer/ContextBuilder/ComponentPositionContextBuilder.php b/src/Serializer/ContextBuilder/ComponentPositionContextBuilder.php index 5db66b8e..150d2cc4 100644 --- a/src/Serializer/ContextBuilder/ComponentPositionContextBuilder.php +++ b/src/Serializer/ContextBuilder/ComponentPositionContextBuilder.php @@ -42,12 +42,12 @@ public function createFromRequest(Request $request, bool $normalization, ?array return $context; } $rw = $normalization ? 'read' : 'write'; - $context['groups'][] = sprintf('ComponentPosition:%s', $rw); + $context['groups'][] = \sprintf('ComponentPosition:%s', $rw); $user = $this->security->getUser(); if ($user) { $reachableRoles = $this->roleHierarchy->getReachableRoleNames($user->getRoles()); foreach ($reachableRoles as $reachableRole) { - $context['groups'][] = sprintf('ComponentPosition:%s:%s', $rw, strtolower($reachableRole)); + $context['groups'][] = \sprintf('ComponentPosition:%s:%s', $rw, strtolower($reachableRole)); } } diff --git a/src/Serializer/ContextBuilder/CwaResourceContextBuilder.php b/src/Serializer/ContextBuilder/CwaResourceContextBuilder.php index 4615b5a5..1a13817b 100644 --- a/src/Serializer/ContextBuilder/CwaResourceContextBuilder.php +++ b/src/Serializer/ContextBuilder/CwaResourceContextBuilder.php @@ -53,14 +53,14 @@ public function createFromRequest(Request $request, bool $normalization, ?array } $rw = $normalization ? 'read' : 'write'; foreach ($componentNames as $componentName) { - $context['groups'][] = sprintf('%s:%s:%s', $componentName, CwaResourceLoader::GROUP_NAME, $rw); + $context['groups'][] = \sprintf('%s:%s:%s', $componentName, CwaResourceLoader::GROUP_NAME, $rw); } $user = $this->security->getUser(); if ($user) { $reachableRoles = $this->roleHierarchy->getReachableRoleNames($user->getRoles()); foreach ($reachableRoles as $reachableRole) { - $context['groups'][] = sprintf('%s:%s:%s:%s', $shortName, CwaResourceLoader::GROUP_NAME, $rw, strtolower($reachableRole)); + $context['groups'][] = \sprintf('%s:%s:%s:%s', $shortName, CwaResourceLoader::GROUP_NAME, $rw, strtolower($reachableRole)); } } diff --git a/src/Serializer/ContextBuilder/PublishableContextBuilder.php b/src/Serializer/ContextBuilder/PublishableContextBuilder.php index 91c25295..e3c38811 100644 --- a/src/Serializer/ContextBuilder/PublishableContextBuilder.php +++ b/src/Serializer/ContextBuilder/PublishableContextBuilder.php @@ -48,12 +48,12 @@ public function createFromRequest(Request $request, bool $normalization, ?array $reflectionClass = new \ReflectionClass($resourceClass); $isAuthorized = $this->publishableStatusChecker->isGranted($resourceClass); if ($normalization) { - $context['groups'][] = sprintf('%s:%s:read', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:read', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); if ($isAuthorized) { - $context['groups'][] = sprintf('%s:%s:read:authorized', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:read:authorized', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); } } elseif ($isAuthorized) { - $context['groups'][] = sprintf('%s:%s:write', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:write', $reflectionClass->getShortName(), PublishableLoader::GROUP_NAME); } return $context; diff --git a/src/Serializer/ContextBuilder/TimestampedContextBuilder.php b/src/Serializer/ContextBuilder/TimestampedContextBuilder.php index d96308ea..b9c72979 100644 --- a/src/Serializer/ContextBuilder/TimestampedContextBuilder.php +++ b/src/Serializer/ContextBuilder/TimestampedContextBuilder.php @@ -39,9 +39,9 @@ public function createFromRequest(Request $request, bool $normalization, ?array $reflectionClass = new \ReflectionClass($resourceClass); if ($normalization) { - $context['groups'][] = sprintf('%s:%s:read', $reflectionClass->getShortName(), TimestampedLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:read', $reflectionClass->getShortName(), TimestampedLoader::GROUP_NAME); } else { - $context['groups'][] = sprintf('%s:%s:write', $reflectionClass->getShortName(), TimestampedLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:write', $reflectionClass->getShortName(), TimestampedLoader::GROUP_NAME); } return $context; diff --git a/src/Serializer/ContextBuilder/UploadableContextBuilder.php b/src/Serializer/ContextBuilder/UploadableContextBuilder.php index ba2da155..514ffc90 100644 --- a/src/Serializer/ContextBuilder/UploadableContextBuilder.php +++ b/src/Serializer/ContextBuilder/UploadableContextBuilder.php @@ -39,9 +39,9 @@ public function createFromRequest(Request $request, bool $normalization, ?array $reflectionClass = new \ReflectionClass($resourceClass); if ($normalization) { - $context['groups'][] = sprintf('%s:%s:read', $reflectionClass->getShortName(), UploadableLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:read', $reflectionClass->getShortName(), UploadableLoader::GROUP_NAME); } else { - $context['groups'][] = sprintf('%s:%s:write', $reflectionClass->getShortName(), UploadableLoader::GROUP_NAME); + $context['groups'][] = \sprintf('%s:%s:write', $reflectionClass->getShortName(), UploadableLoader::GROUP_NAME); } return $context; diff --git a/src/Serializer/ContextBuilder/UserContextBuilder.php b/src/Serializer/ContextBuilder/UserContextBuilder.php index 4f729564..d9849d23 100644 --- a/src/Serializer/ContextBuilder/UserContextBuilder.php +++ b/src/Serializer/ContextBuilder/UserContextBuilder.php @@ -43,7 +43,7 @@ public function createFromRequest(Request $request, bool $normalization, ?array $context['groups'] = []; } $postfix = false === $normalization ? 'input' : 'output'; - $context['groups'][] = sprintf('User:%s', $postfix); + $context['groups'][] = \sprintf('User:%s', $postfix); if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) { $context['groups'][] = 'User:superAdmin'; diff --git a/src/Serializer/MappingLoader/CwaResourceLoader.php b/src/Serializer/MappingLoader/CwaResourceLoader.php index dc1a836a..d64781cc 100644 --- a/src/Serializer/MappingLoader/CwaResourceLoader.php +++ b/src/Serializer/MappingLoader/CwaResourceLoader.php @@ -43,8 +43,8 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool $allAttributesMetadata = $classMetadata->getAttributesMetadata(); $shortClassName = $reflectionClass->getShortName(); - $readGroup = sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); - $writeGroup = sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); + $readGroup = \sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); + $writeGroup = \sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); foreach ($allAttributesMetadata as $attributeMetadatum) { $name = $attributeMetadatum->getName(); diff --git a/src/Serializer/MappingLoader/PublishableLoader.php b/src/Serializer/MappingLoader/PublishableLoader.php index d1946a2f..403b10f3 100644 --- a/src/Serializer/MappingLoader/PublishableLoader.php +++ b/src/Serializer/MappingLoader/PublishableLoader.php @@ -41,8 +41,8 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool $allAttributesMetadata = $classMetadata->getAttributesMetadata(); $shortClassName = $reflectionClass->getShortName(); - $readGroup = sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); - $writeGroup = sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); + $readGroup = \sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); + $writeGroup = \sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); if ( ($attributeMetadata = ($allAttributesMetadata[$configuration->fieldName] ?? null)) @@ -62,7 +62,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool if ( $attributeMetadata = ($allAttributesMetadata[$configuration->reverseAssociationName] ?? null) ) { - $authorizedReadGroup = sprintf('%s:%s:read:authorized', $shortClassName, self::GROUP_NAME); + $authorizedReadGroup = \sprintf('%s:%s:read:authorized', $shortClassName, self::GROUP_NAME); $attributeMetadata->addGroup($authorizedReadGroup); } diff --git a/src/Serializer/MappingLoader/TimestampedLoader.php b/src/Serializer/MappingLoader/TimestampedLoader.php index 7deae021..120ffeaf 100644 --- a/src/Serializer/MappingLoader/TimestampedLoader.php +++ b/src/Serializer/MappingLoader/TimestampedLoader.php @@ -41,8 +41,8 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool $allAttributesMetadata = $classMetadata->getAttributesMetadata(); $shortClassName = $reflectionClass->getShortName(); - $readGroup = sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); - $writeGroup = sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); + $readGroup = \sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); + $writeGroup = \sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); if ( ($attributeMetadata = ($allAttributesMetadata[$configuration->createdAtField] ?? null)) && empty($attributeMetadata->getGroups()) diff --git a/src/Serializer/MappingLoader/UploadableLoader.php b/src/Serializer/MappingLoader/UploadableLoader.php index 2ab674c5..f14301a7 100644 --- a/src/Serializer/MappingLoader/UploadableLoader.php +++ b/src/Serializer/MappingLoader/UploadableLoader.php @@ -48,8 +48,8 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool $properties = $reflectionClass->getProperties(); $allAttributesMetadata = $classMetadata->getAttributesMetadata(); $shortClassName = $reflectionClass->getShortName(); - $readGroup = sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); - $writeGroup = sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); + $readGroup = \sprintf('%s:%s:read', $shortClassName, self::GROUP_NAME); + $writeGroup = \sprintf('%s:%s:write', $shortClassName, self::GROUP_NAME); foreach ($properties as $property) { if ( diff --git a/src/Serializer/Normalizer/ComponentPositionNormalizer.php b/src/Serializer/Normalizer/ComponentPositionNormalizer.php index 238a692a..b595ee07 100644 --- a/src/Serializer/Normalizer/ComponentPositionNormalizer.php +++ b/src/Serializer/Normalizer/ComponentPositionNormalizer.php @@ -135,7 +135,7 @@ private function normalizePublishableComponent(AbstractComponent $component) $configuration = $this->publishableStatusChecker->getAttributeReader()->getConfiguration($type = $component::class); $em = $this->registry->getManagerForClass($component::class); if (!$em) { - throw new InvalidArgumentException(sprintf('Could not find entity manager for class %s', $type)); + throw new InvalidArgumentException(\sprintf('Could not find entity manager for class %s', $type)); } /** @var ClassMetadataInfo $classMetadata */ $classMetadata = $em->getClassMetadata($type); @@ -174,7 +174,7 @@ private function normalizeForPageData(ComponentPosition $object): ComponentPosit // it must be a component if it is found though if (!$component instanceof AbstractComponent) { - throw new InvalidArgumentException(sprintf('The page data property %s is not a component', $object->pageDataProperty)); + throw new InvalidArgumentException(\sprintf('The page data property %s is not a component', $object->pageDataProperty)); } // populate the position diff --git a/src/Serializer/Normalizer/PublishableNormalizer.php b/src/Serializer/Normalizer/PublishableNormalizer.php index 64b7cc51..12729d26 100644 --- a/src/Serializer/Normalizer/PublishableNormalizer.php +++ b/src/Serializer/Normalizer/PublishableNormalizer.php @@ -267,7 +267,7 @@ private function getManagerFromType(string $type): ObjectManager { $em = $this->registry->getManagerForClass($type); if (!$em) { - throw new InvalidArgumentException(sprintf('Could not find entity manager for class %s', $type)); + throw new InvalidArgumentException(\sprintf('Could not find entity manager for class %s', $type)); } return $em; @@ -277,7 +277,7 @@ private function getClassMetadataInfo(ObjectManager $em, string $type): ClassMet { $classMetadata = $em->getClassMetadata($type); if (!$classMetadata instanceof ClassMetadataInfo) { - throw new InvalidArgumentException(sprintf('Class metadata for %s was not an instance of %s', $type, ClassMetadataInfo::class)); + throw new InvalidArgumentException(\sprintf('Class metadata for %s was not an instance of %s', $type, ClassMetadataInfo::class)); } return $classMetadata; diff --git a/src/Serializer/Normalizer/RouteNormalizer.php b/src/Serializer/Normalizer/RouteNormalizer.php index 8daf20fd..59ca85e9 100644 --- a/src/Serializer/Normalizer/RouteNormalizer.php +++ b/src/Serializer/Normalizer/RouteNormalizer.php @@ -45,7 +45,7 @@ public function normalize($object, $format = null, array $context = []): float|a break; } if (\in_array($nextRedirect->getId(), $redirectedRoutes, true)) { - throw new CircularReferenceException(sprintf('The redirect routes result in a circular reference: %s', implode(' -> ', $redirectedRoutes))); + throw new CircularReferenceException(\sprintf('The redirect routes result in a circular reference: %s', implode(' -> ', $redirectedRoutes))); } $redirectedRoutes[] = $nextRedirect->getId(); $finalRoute = $nextRedirect; diff --git a/src/Utility/ApiResourceRouteFinder.php b/src/Utility/ApiResourceRouteFinder.php index f406a928..941f0dd6 100644 --- a/src/Utility/ApiResourceRouteFinder.php +++ b/src/Utility/ApiResourceRouteFinder.php @@ -34,11 +34,11 @@ public function findByIri(string $iri): array try { $parameters = $this->router->match($iri); } catch (RoutingExceptionInterface $e) { - throw new InvalidArgumentException(sprintf('No route matches "%s".', $iri), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('No route matches "%s".', $iri), $e->getCode(), $e); } if (!isset($parameters['_api_resource_class'])) { - throw new InvalidArgumentException(sprintf('No resource associated to "%s".', $iri)); + throw new InvalidArgumentException(\sprintf('No resource associated to "%s".', $iri)); } return $parameters; diff --git a/src/Validator/ClassNameValidator.php b/src/Validator/ClassNameValidator.php index 4c6d6d76..4716ba77 100644 --- a/src/Validator/ClassNameValidator.php +++ b/src/Validator/ClassNameValidator.php @@ -37,7 +37,7 @@ public static function validate(string $className, iterable $validClasses): bool public static function isClassSame(string $className, object $validClass): bool { if (!class_exists($className) && !interface_exists($className)) { - throw new InvalidArgumentException(sprintf('The class/interface %s does not exist', $className)); + throw new InvalidArgumentException(\sprintf('The class/interface %s does not exist', $className)); } if ($validClass::class === $className) { diff --git a/src/Validator/Constraints/FormTypeClassValidator.php b/src/Validator/Constraints/FormTypeClassValidator.php index c85a10bc..2d09e7ec 100644 --- a/src/Validator/Constraints/FormTypeClassValidator.php +++ b/src/Validator/Constraints/FormTypeClassValidator.php @@ -37,10 +37,10 @@ public function validate($value, Constraint $constraint): void return; } if (!\is_string($value)) { - throw new InvalidArgumentException(sprintf('The value passed to %s must be a string', __CLASS__)); + throw new InvalidArgumentException(\sprintf('The value passed to %s must be a string', __CLASS__)); } if (!$constraint instanceof FormTypeClass) { - throw new InvalidArgumentException(sprintf('$constraint parameter must be %s', FormTypeClass::class)); + throw new InvalidArgumentException(\sprintf('$constraint parameter must be %s', FormTypeClass::class)); } try { diff --git a/src/Validator/MappingLoader/TimestampedLoader.php b/src/Validator/MappingLoader/TimestampedLoader.php index 6d133079..6ba1a8a9 100644 --- a/src/Validator/MappingLoader/TimestampedLoader.php +++ b/src/Validator/MappingLoader/TimestampedLoader.php @@ -46,8 +46,8 @@ public function loadClassMetadata(ClassMetadata $metadata): bool $configuration->createdAtField, new Assert\NotNull( [ - 'groups' => [sprintf('%s:timestamped', $shortName)], - 'message' => sprintf('%s should not be null', $configuration->createdAtField), + 'groups' => [\sprintf('%s:timestamped', $shortName)], + 'message' => \sprintf('%s should not be null', $configuration->createdAtField), ] ) ); @@ -56,8 +56,8 @@ public function loadClassMetadata(ClassMetadata $metadata): bool $configuration->modifiedAtField, new Assert\NotNull( [ - 'groups' => [sprintf('%s:timestamped', $shortName)], - 'message' => sprintf('%s should not be null', $configuration->modifiedAtField), + 'groups' => [\sprintf('%s:timestamped', $shortName)], + 'message' => \sprintf('%s should not be null', $configuration->modifiedAtField), ] ) ); diff --git a/tests/ApiPlatform/Metadata/Resource/RoutingPrefixResourceMetadataCollectionFactoryTest.php b/tests/ApiPlatform/Metadata/Resource/RoutingPrefixResourceMetadataCollectionFactoryTest.php index 9366a137..dad71f69 100644 --- a/tests/ApiPlatform/Metadata/Resource/RoutingPrefixResourceMetadataCollectionFactoryTest.php +++ b/tests/ApiPlatform/Metadata/Resource/RoutingPrefixResourceMetadataCollectionFactoryTest.php @@ -57,7 +57,7 @@ public function test_page_data_prefix(): void { $decoratedMock = $this->getDecoratedMock(); $factory = new RoutingPrefixResourceMetadataCollectionFactory($decoratedMock); - $pageDataClass = new class() extends AbstractPageData { + $pageDataClass = new class extends AbstractPageData { }; $metadataCollection = $factory->create($pageDataClass::class); /** @var ApiResource $apiResource */ diff --git a/tests/Entity/Core/AbstractComponentTest.php b/tests/Entity/Core/AbstractComponentTest.php index 64b17d12..a0950d25 100644 --- a/tests/Entity/Core/AbstractComponentTest.php +++ b/tests/Entity/Core/AbstractComponentTest.php @@ -24,7 +24,7 @@ class AbstractComponentTest extends TestCase protected function setUp(): void { // Create a new instance from the Abstract Class - $this->anonymousClassFromAbstract = new class() extends AbstractComponent { + $this->anonymousClassFromAbstract = new class extends AbstractComponent { }; } diff --git a/tests/Entity/User/AbstractUserTest.php b/tests/Entity/User/AbstractUserTest.php index 33e94102..56b9a61f 100644 --- a/tests/Entity/User/AbstractUserTest.php +++ b/tests/Entity/User/AbstractUserTest.php @@ -31,7 +31,7 @@ public function test_construct(): void $this->assertEquals('password', $user->getPassword()); $this->assertFalse($user->isEnabled()); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $this->assertEquals('', $user->getUsername()); $this->assertEquals('', $user->getEmailAddress()); @@ -43,7 +43,7 @@ public function test_construct(): void public function test_getters_and_setters(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $this->assertEquals($user, $user->setUsername('username')); @@ -95,7 +95,7 @@ public function test_getters_and_setters(): void public function test_is_password_request_limit_reached(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $dateTime = new \DateTime(); $user->setPasswordRequestedAt($dateTime); @@ -148,7 +148,7 @@ public function test_user_serialization(): void public function test_unserialize_object_throws_exception(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $original = [ '253e0f90-8842-4731-91dd-0191816e6a28', diff --git a/tests/Factory/User/Mailer/AbstractUserEmailFactoryTest.php b/tests/Factory/User/Mailer/AbstractUserEmailFactoryTest.php index 05bf4962..ec0ad744 100644 --- a/tests/Factory/User/Mailer/AbstractUserEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/AbstractUserEmailFactoryTest.php @@ -67,7 +67,7 @@ protected function getTemplate(): string } }; $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ); } @@ -75,7 +75,7 @@ protected function getTemplate(): string public function test_exception_thrown_if_user_has_no_username(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'email subject'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setEmailAddress('email@address.com'); @@ -88,7 +88,7 @@ public function test_exception_thrown_if_user_has_no_username(): void public function test_exception_thrown_if_user_has_no_email_address(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'email subject'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('my_username'); @@ -101,7 +101,7 @@ public function test_exception_thrown_if_user_has_no_email_address(): void public function test_exception_thrown_if_email_not_rfc_compliant(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'email subject'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('my_username')->setEmailAddress('invalid_email:address'); @@ -114,12 +114,12 @@ public function test_exception_thrown_if_email_not_rfc_compliant(): void public function test_exception_thrown_if_no_website_name_context_key(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'email subject'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('my_username')->setEmailAddress('email@address.com'); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('You have not specified required context key(s) for the user email factory factory `%s` (expected: `website_name`, `test_key`)', DummyUserEmailFactory::class)); + $this->expectExceptionMessage(\sprintf('You have not specified required context key(s) for the user email factory factory `%s` (expected: `website_name`, `test_key`)', DummyUserEmailFactory::class)); $userEmailFactory->create($user); } @@ -127,7 +127,7 @@ public function test_exception_thrown_if_no_website_name_context_key(): void public function test_create_email_message(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'website name is {{ website_name }}'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('my_username')->setEmailAddress('email@address.com'); @@ -167,7 +167,7 @@ public function test_create_email_message(): void public function test_do_not_create_email_message_if_not_enabled(): void { $userEmailFactory = new DummyUserEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('my_username')->setEmailAddress('email@address.com'); @@ -189,7 +189,7 @@ public function test_dummy_get_token_url_throws_exception_if_no_paths(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The `defaultRedirectPath` or `redirectPathQueryKey` must be set'); $userEmailFactory->dummyGetTokenUrl( - new class() extends AbstractUser { + new class extends AbstractUser { } ); } @@ -211,9 +211,9 @@ public function test_dummy_get_token_url_throws_exception_if_no_default_path_and ->willReturn($requestStackMock); $this->expectException(UnexpectedValueException::class); - $this->expectExceptionMessage(sprintf('The querystring key `%s` could not be found in the request to generate a token URL', 'queryKey')); + $this->expectExceptionMessage(\sprintf('The querystring key `%s` could not be found in the request to generate a token URL', 'queryKey')); $userEmailFactory->dummyGetTokenUrl( - new class() extends AbstractUser { + new class extends AbstractUser { } ); } @@ -253,7 +253,7 @@ public function test_dummy_get_token_url_can_get_path_from_querystring_over_defa self::assertEquals( '/any-path', $userEmailFactory->dummyGetTokenUrl( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -290,7 +290,7 @@ public function test_dummy_get_token_url_can_get_path_from_default_path(): void self::assertEquals( '/any-path', $userEmailFactory->dummyGetTokenUrl( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -321,7 +321,7 @@ public function test_token_path_variable_populate(): void ->with('/path/token%20username/my_token') ->willReturn('/any-path'); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setUsername('token username'); self::assertEquals('/any-path', $userEmailFactory->dummyGetTokenUrl($user)); diff --git a/tests/Factory/User/Mailer/ChangeEmailVerificationEmailFactoryTest.php b/tests/Factory/User/Mailer/ChangeEmailVerificationEmailFactoryTest.php index 0681eb6f..5eaba574 100644 --- a/tests/Factory/User/Mailer/ChangeEmailVerificationEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/ChangeEmailVerificationEmailFactoryTest.php @@ -26,7 +26,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new ChangeEmailConfirmationEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -34,7 +34,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_exception_thrown_if_no_token(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') @@ -50,7 +50,7 @@ public function test_exception_thrown_if_no_token(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user diff --git a/tests/Factory/User/Mailer/PasswordChangedEmailFactoryTest.php b/tests/Factory/User/Mailer/PasswordChangedEmailFactoryTest.php index 2656d094..2b8acdac 100644 --- a/tests/Factory/User/Mailer/PasswordChangedEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/PasswordChangedEmailFactoryTest.php @@ -25,7 +25,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new PasswordChangedEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -33,7 +33,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') diff --git a/tests/Factory/User/Mailer/PasswordResetEmailFactoryTest.php b/tests/Factory/User/Mailer/PasswordResetEmailFactoryTest.php index 5dbdf771..4ecfe455 100644 --- a/tests/Factory/User/Mailer/PasswordResetEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/PasswordResetEmailFactoryTest.php @@ -26,7 +26,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new PasswordResetEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -34,7 +34,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_exception_thrown_if_no_token(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') @@ -50,7 +50,7 @@ public function test_exception_thrown_if_no_token(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') diff --git a/tests/Factory/User/Mailer/UserEnabledEmailFactoryTest.php b/tests/Factory/User/Mailer/UserEnabledEmailFactoryTest.php index 81d3f988..188fbbf4 100644 --- a/tests/Factory/User/Mailer/UserEnabledEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/UserEnabledEmailFactoryTest.php @@ -25,7 +25,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new UserEnabledEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -33,7 +33,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') diff --git a/tests/Factory/User/Mailer/UsernameChangedEmailFactoryTest.php b/tests/Factory/User/Mailer/UsernameChangedEmailFactoryTest.php index e84334ed..a5d55f60 100644 --- a/tests/Factory/User/Mailer/UsernameChangedEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/UsernameChangedEmailFactoryTest.php @@ -25,7 +25,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new UsernameChangedEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -33,7 +33,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') diff --git a/tests/Factory/User/Mailer/WelcomeEmailFactoryTest.php b/tests/Factory/User/Mailer/WelcomeEmailFactoryTest.php index 7cf1a505..54bc282a 100644 --- a/tests/Factory/User/Mailer/WelcomeEmailFactoryTest.php +++ b/tests/Factory/User/Mailer/WelcomeEmailFactoryTest.php @@ -25,7 +25,7 @@ public function test_skip_user_validation_if_disabled(): void $factory = new WelcomeEmailFactory($this->containerInterfaceMock, $this->eventDispatcherMock, 'subject', false); $this->assertNull( $factory->create( - new class() extends AbstractUser { + new class extends AbstractUser { } ) ); @@ -33,7 +33,7 @@ public function test_skip_user_validation_if_disabled(): void public function test_redirect_url_context_added_and_html_template_passed(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') @@ -59,7 +59,7 @@ public function test_redirect_url_context_added_and_html_template_passed(): void public function test_redirect_url_context_added_and_html_template_passed_with_token(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user ->setUsername('username') diff --git a/tests/Helper/User/UserMailerTest.php b/tests/Helper/User/UserMailerTest.php index fc533088..ab068a2d 100644 --- a/tests/Helper/User/UserMailerTest.php +++ b/tests/Helper/User/UserMailerTest.php @@ -54,7 +54,7 @@ protected function setUp(): void public function test_context_can_be_omitted(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $userMailer = new UserMailer($this->mailerMock, $this->containerMock); @@ -72,7 +72,7 @@ public function test_context_can_be_omitted(): void public function test_send_method_skipped_if_no_message_returned(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $factoryMock = $this->getFactoryFromContainerMock(PasswordResetEmailFactory::class); @@ -92,7 +92,7 @@ public function test_send_method_skipped_if_no_message_returned(): void public function test_exception_thrown_if_mailer_send_throws_exception(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $templateEmail = new TemplatedEmail(); @@ -117,7 +117,7 @@ public function test_exception_thrown_if_mailer_send_throws_exception(): void public function test_send_password_reset_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_password_reset_email'; }; @@ -128,7 +128,7 @@ public function test_send_password_reset_email(): void public function test_send_change_email_verification_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_change_email_verification_email'; }; @@ -139,7 +139,7 @@ public function test_send_change_email_verification_email(): void public function test_send_welcome_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_welcome_email'; }; @@ -150,7 +150,7 @@ public function test_send_welcome_email(): void public function test_send_user_enabled_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_user_enabled_email'; }; @@ -161,7 +161,7 @@ public function test_send_user_enabled_email(): void public function test_send_username_changed_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_username_changed_email'; }; @@ -172,7 +172,7 @@ public function test_send_username_changed_email(): void public function test_send_password_changed_email(): void { - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { protected ?string $username = 'test_send_password_changed_email'; }; diff --git a/tests/Security/UserCheckerTest.php b/tests/Security/UserCheckerTest.php index 8befd144..116b11a3 100644 --- a/tests/Security/UserCheckerTest.php +++ b/tests/Security/UserCheckerTest.php @@ -40,7 +40,7 @@ public function test_pre_auth_does_nothing_if_object_is_not_user(): void public function test_user_not_enabled_throws_exception(): void { $userChecker = new UserChecker(); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setEnabled(false)->setEmailAddressVerified(true); @@ -55,7 +55,7 @@ public function test_user_not_enabled_throws_exception(): void public function test_user_with_unverified_email_throws_exception(): void { $userChecker = new UserChecker(); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setEnabled(true); @@ -71,7 +71,7 @@ public function test_user_with_unverified_email_throws_exception(): void public function test_user_with_unverified_email_can_be_allowed_and_not_throw_exception(): void { $userChecker = new UserChecker(false); - $user = new class() extends AbstractUser { + $user = new class extends AbstractUser { }; $user->setEnabled(true); diff --git a/tests/Validator/Constraints/FormTypeClassValidatorTest.php b/tests/Validator/Constraints/FormTypeClassValidatorTest.php index ff3ad424..8fb2b9db 100644 --- a/tests/Validator/Constraints/FormTypeClassValidatorTest.php +++ b/tests/Validator/Constraints/FormTypeClassValidatorTest.php @@ -82,7 +82,7 @@ public function test_exception_thrown_if_contraint_not_expected(): void $this->expectException(InvalidArgumentException::class); $this->formTypeClassValidator->validate( TestType::class, - new class() extends Constraint { + new class extends Constraint { } ); } diff --git a/tests/Validator/Constraints/NewEmailAddressValidatorTest.php b/tests/Validator/Constraints/NewEmailAddressValidatorTest.php index 0665fa50..d68928dd 100644 --- a/tests/Validator/Constraints/NewEmailAddressValidatorTest.php +++ b/tests/Validator/Constraints/NewEmailAddressValidatorTest.php @@ -57,9 +57,9 @@ protected function setUp(): void public function test_exception_thrown_for_incorrect_user_class(): void { $this->expectException(UnexpectedTypeException::class); - $constraint = new class() extends Constraint { + $constraint = new class extends Constraint { }; - $dummyUser = new class() { + $dummyUser = new class { }; $this->newEmailAddressValidator->validate($dummyUser, $constraint); } @@ -76,7 +76,7 @@ public function test_no_constraint_errors_if_no_new_email_address(): void $this->newEmailAddressValidator->initialize($this->executionContextMock); $constraint = new NewEmailAddress(); - $dummyUser = new class() extends AbstractUser { + $dummyUser = new class extends AbstractUser { }; $this->newEmailAddressValidator->validate($dummyUser, $constraint); } @@ -103,7 +103,7 @@ public function test_error_if_new_email_is_same_as_previous(): void $this->newEmailAddressValidator->initialize($this->executionContextMock); - $dummyUser = new class() extends AbstractUser { + $dummyUser = new class extends AbstractUser { }; // current email is verified $dummyUser->setEmailAddressVerified(true); @@ -127,7 +127,7 @@ public function test_error_if_new_email_is_same_as_previous(): void public function test_error_if_new_email_is_already_in_database(): void { - $dummyUser = new class() extends AbstractUser { + $dummyUser = new class extends AbstractUser { }; $this->repositoryMock @@ -163,7 +163,7 @@ public function test_error_if_new_email_is_already_in_database(): void public function test_no_error_if_new_email_is_unique(): void { - $dummyUser = new class() extends AbstractUser { + $dummyUser = new class extends AbstractUser { }; $this->repositoryMock