diff --git a/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php b/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php index caf62dce150..c8969bdc62b 100644 --- a/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php +++ b/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php @@ -53,7 +53,7 @@ private function createFilterDefinitions(\ReflectionClass $resourceReflectionCla } if (null === $filterReflectionClass = $container->getReflectionClass($filterClass, false)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $filterClass, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $filterClass, $id)); } if ($container->has($filterClass) && ($parentDefinition = $container->findDefinition($filterClass))->isAbstract()) { @@ -75,7 +75,7 @@ private function createFilterDefinitions(\ReflectionClass $resourceReflectionCla foreach ($arguments as $key => $value) { if (!isset($parameterNames[$key])) { - throw new InvalidArgumentException(sprintf('Class "%s" does not have argument "$%s".', $filterClass, $key)); + throw new InvalidArgumentException(\sprintf('Class "%s" does not have argument "$%s".', $filterClass, $key)); } $definition->setArgument("$$key", $value); diff --git a/src/Doctrine/Common/Filter/BooleanFilterTrait.php b/src/Doctrine/Common/Filter/BooleanFilterTrait.php index f906836b755..c9ee4a364d8 100644 --- a/src/Doctrine/Common/Filter/BooleanFilterTrait.php +++ b/src/Doctrine/Common/Filter/BooleanFilterTrait.php @@ -86,7 +86,7 @@ private function normalizeValue($value, string $property): ?bool } $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $property, implode('" | "', [ + 'exception' => new InvalidArgumentException(\sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $property, implode('" | "', [ 'true', 'false', '1', diff --git a/src/Doctrine/Common/Filter/DateFilterTrait.php b/src/Doctrine/Common/Filter/DateFilterTrait.php index f5ceb6d5874..33f24664459 100644 --- a/src/Doctrine/Common/Filter/DateFilterTrait.php +++ b/src/Doctrine/Common/Filter/DateFilterTrait.php @@ -73,7 +73,7 @@ protected function getFilterDescription(string $property, string $period): array $propertyName = $this->normalizePropertyName($property); return [ - sprintf('%s[%s]', $propertyName, $period) => [ + \sprintf('%s[%s]', $propertyName, $period) => [ 'property' => $propertyName, 'type' => \DateTimeInterface::class, 'required' => false, @@ -85,7 +85,7 @@ private function normalizeValue($value, string $operator): ?string { if (false === \is_string($value)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid value for "[%s]", expected string', $operator)), + 'exception' => new InvalidArgumentException(\sprintf('Invalid value for "[%s]", expected string', $operator)), ]); return null; diff --git a/src/Doctrine/Common/Filter/ExistsFilterTrait.php b/src/Doctrine/Common/Filter/ExistsFilterTrait.php index 88a3da57746..c1ab4a3e3a2 100644 --- a/src/Doctrine/Common/Filter/ExistsFilterTrait.php +++ b/src/Doctrine/Common/Filter/ExistsFilterTrait.php @@ -49,7 +49,7 @@ public function getDescription(string $resourceClass): array continue; } $propertyName = $this->normalizePropertyName($property); - $description[sprintf('%s[%s]', $this->existsParameterName, $propertyName)] = [ + $description[\sprintf('%s[%s]', $this->existsParameterName, $propertyName)] = [ 'property' => $propertyName, 'type' => 'bool', 'required' => false, @@ -81,7 +81,7 @@ private function normalizeValue($value, string $property): ?bool } $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid value for "%s[%s]", expected one of ( "%s" )', $this->existsParameterName, $property, implode('" | "', [ + 'exception' => new InvalidArgumentException(\sprintf('Invalid value for "%s[%s]", expected one of ( "%s" )', $this->existsParameterName, $property, implode('" | "', [ 'true', 'false', '1', diff --git a/src/Doctrine/Common/Filter/NumericFilterTrait.php b/src/Doctrine/Common/Filter/NumericFilterTrait.php index a8cc3b1d8ad..242a627531d 100644 --- a/src/Doctrine/Common/Filter/NumericFilterTrait.php +++ b/src/Doctrine/Common/Filter/NumericFilterTrait.php @@ -83,7 +83,7 @@ protected function normalizeValues($value, string $property): ?array { if (!is_numeric($value) && (!\is_array($value) || !$this->isNumericArray($value))) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid numeric value for "%s" property', $property)), + 'exception' => new InvalidArgumentException(\sprintf('Invalid numeric value for "%s" property', $property)), ]); return null; @@ -102,7 +102,7 @@ protected function normalizeValues($value, string $property): ?array if (empty($values)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)), + 'exception' => new InvalidArgumentException(\sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)), ]); return null; diff --git a/src/Doctrine/Common/Filter/OrderFilterTrait.php b/src/Doctrine/Common/Filter/OrderFilterTrait.php index 0d0659f6088..4a3f5f862e5 100644 --- a/src/Doctrine/Common/Filter/OrderFilterTrait.php +++ b/src/Doctrine/Common/Filter/OrderFilterTrait.php @@ -48,7 +48,7 @@ public function getDescription(string $resourceClass): array continue; } $propertyName = $this->normalizePropertyName($property); - $description[sprintf('%s[%s]', $this->orderParameterName, $propertyName)] = [ + $description[\sprintf('%s[%s]', $this->orderParameterName, $propertyName)] = [ 'property' => $propertyName, 'type' => 'string', 'required' => false, diff --git a/src/Doctrine/Common/Filter/RangeFilterTrait.php b/src/Doctrine/Common/Filter/RangeFilterTrait.php index 895488d1cb3..4ffc94587fa 100644 --- a/src/Doctrine/Common/Filter/RangeFilterTrait.php +++ b/src/Doctrine/Common/Filter/RangeFilterTrait.php @@ -68,7 +68,7 @@ protected function getFilterDescription(string $fieldName, string $operator): ar $propertyName = $this->normalizePropertyName($fieldName); return [ - sprintf('%s[%s]', $propertyName, $operator) => [ + \sprintf('%s[%s]', $propertyName, $operator) => [ 'property' => $propertyName, 'type' => 'string', 'required' => false, @@ -88,7 +88,7 @@ private function normalizeValues(array $values, string $property): ?array if (empty($values)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('At least one valid operator ("%s") is required for "%s" property', implode('", "', $operators), $property)), + 'exception' => new InvalidArgumentException(\sprintf('At least one valid operator ("%s") is required for "%s" property', implode('", "', $operators), $property)), ]); return null; @@ -104,7 +104,7 @@ private function normalizeBetweenValues(array $values): ?array { if (2 !== \count($values)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid format for "[%s]", expected ".."', self::PARAMETER_BETWEEN)), + 'exception' => new InvalidArgumentException(\sprintf('Invalid format for "[%s]", expected ".."', self::PARAMETER_BETWEEN)), ]); return null; @@ -112,7 +112,7 @@ private function normalizeBetweenValues(array $values): ?array if (!is_numeric($values[0]) || !is_numeric($values[1])) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid values for "[%s]" range, expected numbers', self::PARAMETER_BETWEEN)), + 'exception' => new InvalidArgumentException(\sprintf('Invalid values for "[%s]" range, expected numbers', self::PARAMETER_BETWEEN)), ]); return null; @@ -128,7 +128,7 @@ private function normalizeValue(string $value, string $operator): float|int|null { if (!is_numeric($value)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Invalid value for "[%s]", expected number', $operator)), + 'exception' => new InvalidArgumentException(\sprintf('Invalid value for "[%s]", expected number', $operator)), ]); return null; diff --git a/src/Doctrine/Common/Filter/SearchFilterTrait.php b/src/Doctrine/Common/Filter/SearchFilterTrait.php index 2dcb985490c..bf64d45370d 100644 --- a/src/Doctrine/Common/Filter/SearchFilterTrait.php +++ b/src/Doctrine/Common/Filter/SearchFilterTrait.php @@ -151,7 +151,7 @@ protected function normalizeValues(array $values, string $property): ?array if (empty($values)) { $this->getLogger()->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)), + 'exception' => new InvalidArgumentException(\sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)), ]); return null; diff --git a/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php b/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php index 8c09fae6e52..77a5330d474 100644 --- a/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php +++ b/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php @@ -39,6 +39,6 @@ private function getLinksHandler(Operation $operation): ?callable return [$this->handleLinksLocator->get($handleLinks), 'handleLinks']; } - throw new RuntimeException(sprintf('Could not find handleLinks service "%s"', $handleLinks)); + throw new RuntimeException(\sprintf('Could not find handleLinks service "%s"', $handleLinks)); } } diff --git a/src/Doctrine/Common/State/LinksHandlerTrait.php b/src/Doctrine/Common/State/LinksHandlerTrait.php index 44d05911070..5ff78a3eacf 100644 --- a/src/Doctrine/Common/State/LinksHandlerTrait.php +++ b/src/Doctrine/Common/State/LinksHandlerTrait.php @@ -83,7 +83,7 @@ private function getLinks(string $resourceClass, Operation $operation, array $co } if (!$newLink) { - throw new RuntimeException(sprintf('The class "%s" cannot be retrieved from "%s".', $resourceClass, $linkClass)); + throw new RuntimeException(\sprintf('The class "%s" cannot be retrieved from "%s".', $resourceClass, $linkClass)); } return [$newLink]; diff --git a/src/Doctrine/EventListener/PublishMercureUpdatesListener.php b/src/Doctrine/EventListener/PublishMercureUpdatesListener.php index 0e085715980..6f556e5dbb6 100644 --- a/src/Doctrine/EventListener/PublishMercureUpdatesListener.php +++ b/src/Doctrine/EventListener/PublishMercureUpdatesListener.php @@ -83,10 +83,10 @@ public function __construct(ResourceClassResolverInterface $resourceClassResolve $this->expressionLanguage->addFunction($rawurlencode); $this->expressionLanguage->addFunction( - new ExpressionFunction('get_operation', static fn (string $apiResource, string $name): string => sprintf('getOperation(%s, %s)', $apiResource, $name), static fn (array $arguments, $apiResource, string $name): Operation => $resourceMetadataFactory->create($resourceClassResolver->getResourceClass($apiResource))->getOperation($name)) + new ExpressionFunction('get_operation', static fn (string $apiResource, string $name): string => \sprintf('getOperation(%s, %s)', $apiResource, $name), static fn (array $arguments, $apiResource, string $name): Operation => $resourceMetadataFactory->create($resourceClassResolver->getResourceClass($apiResource))->getOperation($name)) ); $this->expressionLanguage->addFunction( - new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, ?string $operation = null): string => sprintf('iri(%s, %d, %s)', $apiResource, $referenceType, $operation), static fn (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, $operation = null): string => $iriConverter->getIriFromResource($apiResource, $referenceType, $operation)) + new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, ?string $operation = null): string => \sprintf('iri(%s, %d, %s)', $apiResource, $referenceType, $operation), static fn (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, $operation = null): string => $iriConverter->getIriFromResource($apiResource, $referenceType, $operation)) ); } @@ -184,12 +184,12 @@ private function storeObjectToPublish(object $object, string $property): void } 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/Doctrine/Odm/Extension/PaginationExtension.php b/src/Doctrine/Odm/Extension/PaginationExtension.php index aecf2475f04..f1c7892f5ca 100644 --- a/src/Doctrine/Odm/Extension/PaginationExtension.php +++ b/src/Doctrine/Odm/Extension/PaginationExtension.php @@ -56,7 +56,7 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC $manager = $this->managerRegistry->getManagerForClass($resourceClass); if (!$manager instanceof DocumentManager) { - throw new RuntimeException(sprintf('The manager for "%s" must be an instance of "%s".', $resourceClass, DocumentManager::class)); + throw new RuntimeException(\sprintf('The manager for "%s" must be an instance of "%s".', $resourceClass, DocumentManager::class)); } /** @@ -103,7 +103,7 @@ public function getResult(Builder $aggregationBuilder, string $resourceClass, ?O { $manager = $this->managerRegistry->getManagerForClass($resourceClass); if (!$manager instanceof DocumentManager) { - throw new RuntimeException(sprintf('The manager for "%s" must be an instance of "%s".', $resourceClass, DocumentManager::class)); + throw new RuntimeException(\sprintf('The manager for "%s" must be an instance of "%s".', $resourceClass, DocumentManager::class)); } $attribute = $operation?->getExtraProperties()['doctrine_mongodb'] ?? []; diff --git a/src/Doctrine/Odm/Filter/DateFilter.php b/src/Doctrine/Odm/Filter/DateFilter.php index e1279b62236..8be5534fbca 100644 --- a/src/Doctrine/Odm/Filter/DateFilter.php +++ b/src/Doctrine/Odm/Filter/DateFilter.php @@ -210,7 +210,7 @@ private function addMatch(Builder $aggregationBuilder, string $field, string $op } catch (\Exception) { // Silently ignore this filter if it can not be transformed to a \DateTime $this->logger->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)), + 'exception' => new InvalidArgumentException(\sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)), ]); return; diff --git a/src/Doctrine/Odm/Filter/SearchFilter.php b/src/Doctrine/Odm/Filter/SearchFilter.php index ecac83986db..c370e57dcf0 100644 --- a/src/Doctrine/Odm/Filter/SearchFilter.php +++ b/src/Doctrine/Odm/Filter/SearchFilter.php @@ -203,7 +203,7 @@ protected function filterProperty(string $property, $value, Builder $aggregation 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; @@ -227,7 +227,7 @@ protected function filterProperty(string $property, $value, Builder $aggregation 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.', $property)), + 'exception' => new InvalidArgumentException(\sprintf('Values for field "%s" are not valid according to the doctrine type.', $property)), ]); return; @@ -276,7 +276,7 @@ private function getEqualityMatchStrategyValue(string $strategy, string $field, self::STRATEGY_START => new Regex("^$quotedValue", $caseSensitive ? '' : 'i'), self::STRATEGY_END => new Regex("$quotedValue$", $caseSensitive ? '' : 'i'), self::STRATEGY_WORD_START => new Regex("(^$quotedValue.*|.*\s$quotedValue.*)", $caseSensitive ? '' : 'i'), - default => throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy)), + default => throw new InvalidArgumentException(\sprintf('strategy %s does not exist.', $strategy)), }; } diff --git a/src/Doctrine/Odm/PropertyHelperTrait.php b/src/Doctrine/Odm/PropertyHelperTrait.php index c368df150c7..e1c7693f2b0 100644 --- a/src/Doctrine/Odm/PropertyHelperTrait.php +++ b/src/Doctrine/Odm/PropertyHelperTrait.php @@ -112,7 +112,7 @@ protected function addLookupsForNestedProperty(string $property, Builder $aggreg } if ('' === $alias) { - throw new InvalidArgumentException(sprintf('Cannot add lookups for property "%s" - property is not nested.', $property)); + throw new InvalidArgumentException(\sprintf('Cannot add lookups for property "%s" - property is not nested.', $property)); } return [$property, $propertyParts['field'], $propertyParts['associations']]; diff --git a/src/Doctrine/Odm/State/CollectionProvider.php b/src/Doctrine/Odm/State/CollectionProvider.php index 31c0a74d9ce..3c5c923f893 100644 --- a/src/Doctrine/Odm/State/CollectionProvider.php +++ b/src/Doctrine/Odm/State/CollectionProvider.php @@ -55,7 +55,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c $repository = $manager->getRepository($documentClass); if (!$repository instanceof DocumentRepository) { - throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $documentClass, DocumentRepository::class)); + throw new RuntimeException(\sprintf('The repository for "%s" must be an instance of "%s".', $documentClass, DocumentRepository::class)); } $aggregationBuilder = $repository->createAggregationBuilder(); diff --git a/src/Doctrine/Odm/State/ItemProvider.php b/src/Doctrine/Odm/State/ItemProvider.php index 4a719b68c7c..d367ea4fa02 100644 --- a/src/Doctrine/Odm/State/ItemProvider.php +++ b/src/Doctrine/Odm/State/ItemProvider.php @@ -63,7 +63,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c $repository = $manager->getRepository($documentClass); if (!$repository instanceof DocumentRepository) { - throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $documentClass, DocumentRepository::class)); + throw new RuntimeException(\sprintf('The repository for "%s" must be an instance of "%s".', $documentClass, DocumentRepository::class)); } $aggregationBuilder = $repository->createAggregationBuilder(); diff --git a/src/Doctrine/Odm/State/LinksHandlerTrait.php b/src/Doctrine/Odm/State/LinksHandlerTrait.php index 179dc1a89c5..340007e1848 100644 --- a/src/Doctrine/Odm/State/LinksHandlerTrait.php +++ b/src/Doctrine/Odm/State/LinksHandlerTrait.php @@ -92,14 +92,14 @@ private function buildAggregation(string $toClass, array $links, array $identifi } if (!$manager instanceof DocumentManager) { - throw new RuntimeException(sprintf('The manager for "%s" must be an instance of "%s".', $aggregationClass, DocumentManager::class)); + throw new RuntimeException(\sprintf('The manager for "%s" must be an instance of "%s".', $aggregationClass, DocumentManager::class)); } } $classMetadata = $manager->getClassMetadata($aggregationClass); if (!$classMetadata instanceof ClassMetadata) { - throw new RuntimeException(sprintf('The class metadata for "%s" must be an instance of "%s".', $aggregationClass, ClassMetadata::class)); + throw new RuntimeException(\sprintf('The class metadata for "%s" must be an instance of "%s".', $aggregationClass, ClassMetadata::class)); } $aggregation = $previousAggregationBuilder; @@ -113,7 +113,7 @@ private function buildAggregation(string $toClass, array $links, array $identifi if ($toProperty) { foreach ($identifierProperties as $identifierProperty) { - $aggregation->match()->field(sprintf('%s.%s', $lookupPropertyAlias, 'id' === $identifierProperty ? '_id' : $identifierProperty))->equals($this->getIdentifierValue($identifiers, $hasCompositeIdentifiers ? $identifierProperty : null)); + $aggregation->match()->field(\sprintf('%s.%s', $lookupPropertyAlias, 'id' === $identifierProperty ? '_id' : $identifierProperty))->equals($this->getIdentifierValue($identifiers, $hasCompositeIdentifiers ? $identifierProperty : null)); } } else { foreach ($identifierProperties as $identifierProperty) { diff --git a/src/Doctrine/Odm/Tests/AppKernel.php b/src/Doctrine/Odm/Tests/AppKernel.php index 1525929a33a..0333f06741e 100644 --- a/src/Doctrine/Odm/Tests/AppKernel.php +++ b/src/Doctrine/Odm/Tests/AppKernel.php @@ -43,7 +43,7 @@ public function registerBundles(): array return [ new FrameworkBundle(), new DoctrineMongoDBBundle(), - new class() extends Bundle { + new class extends Bundle { public function shutdown(): void { restore_exception_handler(); diff --git a/src/Doctrine/Orm/AbstractPaginator.php b/src/Doctrine/Orm/AbstractPaginator.php index a3c2a08dc89..59595c721a6 100644 --- a/src/Doctrine/Orm/AbstractPaginator.php +++ b/src/Doctrine/Orm/AbstractPaginator.php @@ -33,7 +33,7 @@ public function __construct(DoctrinePaginator $paginator) $query = $paginator->getQuery(); if (null === ($firstResult = $query->getFirstResult()) || $firstResult < 0 || null === $maxResults = $query->getMaxResults()) { // @phpstan-ignore-line - throw new InvalidArgumentException(sprintf('"%1$s::setFirstResult()" or/and "%1$s::setMaxResults()" was/were not applied to the query.', Query::class)); + throw new InvalidArgumentException(\sprintf('"%1$s::setFirstResult()" or/and "%1$s::setMaxResults()" was/were not applied to the query.', Query::class)); } $this->paginator = $paginator; diff --git a/src/Doctrine/Orm/Extension/EagerLoadingExtension.php b/src/Doctrine/Orm/Extension/EagerLoadingExtension.php index bd0935d231f..aa1e08adc88 100644 --- a/src/Doctrine/Orm/Extension/EagerLoadingExtension.php +++ b/src/Doctrine/Orm/Extension/EagerLoadingExtension.php @@ -186,7 +186,7 @@ private function joinRelations(QueryBuilder $queryBuilder, QueryNameGeneratorInt $method = $isLeftJoin ? 'leftJoin' : 'innerJoin'; $associationAlias = $queryNameGenerator->generateJoinAlias($association); - $queryBuilder->{$method}(sprintf('%s.%s', $parentAlias, $association), $associationAlias); + $queryBuilder->{$method}(\sprintf('%s.%s', $parentAlias, $association), $associationAlias); ++$joinCount; } @@ -264,7 +264,7 @@ private function addSelect(QueryBuilder $queryBuilder, string $entity, string $a } } - $queryBuilder->addSelect(sprintf('partial %s.{%s}', $associationAlias, implode(',', $select))); + $queryBuilder->addSelect(\sprintf('partial %s.{%s}', $associationAlias, implode(',', $select))); } private function addSelectOnce(QueryBuilder $queryBuilder, string $alias): void diff --git a/src/Doctrine/Orm/Extension/OrderExtension.php b/src/Doctrine/Orm/Extension/OrderExtension.php index 39890727c90..1d3deaf0b5b 100644 --- a/src/Doctrine/Orm/Extension/OrderExtension.php +++ b/src/Doctrine/Orm/Extension/OrderExtension.php @@ -67,7 +67,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator $field = "{$rootAlias}.{$field}"; } else { $alias = QueryBuilderHelper::addJoinOnce($queryBuilder, $queryNameGenerator, $rootAlias, substr($field, 0, $pos)); - $field = sprintf('%s.%s', $alias, substr($field, $pos + 1)); + $field = \sprintf('%s.%s', $alias, substr($field, $pos + 1)); } $queryBuilder->addOrderBy($field, $order); } diff --git a/src/Doctrine/Orm/Filter/BooleanFilter.php b/src/Doctrine/Orm/Filter/BooleanFilter.php index 2f230c465dd..e9f0a8373e0 100644 --- a/src/Doctrine/Orm/Filter/BooleanFilter.php +++ b/src/Doctrine/Orm/Filter/BooleanFilter.php @@ -142,7 +142,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB $valueParameter = $queryNameGenerator->generateParameterName($field); $queryBuilder - ->andWhere(sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); } } diff --git a/src/Doctrine/Orm/Filter/DateFilter.php b/src/Doctrine/Orm/Filter/DateFilter.php index 066606e88ad..8533ee34406 100644 --- a/src/Doctrine/Orm/Filter/DateFilter.php +++ b/src/Doctrine/Orm/Filter/DateFilter.php @@ -161,7 +161,7 @@ protected function filterProperty(string $property, $values, QueryBuilder $query $type = (string) $this->getDoctrineFieldType($property, $resourceClass); if (self::EXCLUDE_NULL === $nullManagement) { - $queryBuilder->andWhere($queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field))); + $queryBuilder->andWhere($queryBuilder->expr()->isNotNull(\sprintf('%s.%s', $alias, $field))); } if (isset($values[self::PARAMETER_BEFORE])) { @@ -234,7 +234,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf } catch (\Exception) { // Silently ignore this filter if it can not be transformed to a \DateTime $this->logger->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)), + 'exception' => new InvalidArgumentException(\sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)), ]); return; @@ -247,7 +247,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf self::PARAMETER_AFTER => '>=', self::PARAMETER_STRICTLY_AFTER => '>', ]; - $baseWhere = sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter); + $baseWhere = \sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter); if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) { $queryBuilder->andWhere($baseWhere); @@ -258,12 +258,12 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf ) { $queryBuilder->andWhere($queryBuilder->expr()->orX( $baseWhere, - $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $field)) + $queryBuilder->expr()->isNull(\sprintf('%s.%s', $alias, $field)) )); } else { $queryBuilder->andWhere($queryBuilder->expr()->andX( $baseWhere, - $queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field)) + $queryBuilder->expr()->isNotNull(\sprintf('%s.%s', $alias, $field)) )); } diff --git a/src/Doctrine/Orm/Filter/ExistsFilter.php b/src/Doctrine/Orm/Filter/ExistsFilter.php index 5f516c44a73..0dde78e9e97 100644 --- a/src/Doctrine/Orm/Filter/ExistsFilter.php +++ b/src/Doctrine/Orm/Filter/ExistsFilter.php @@ -164,7 +164,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB if ($metadata->hasAssociation($field)) { if ($metadata->isCollectionValuedAssociation($field)) { $queryBuilder - ->andWhere(sprintf('%s.%s %s EMPTY', $alias, $field, $value ? 'IS NOT' : 'IS')); + ->andWhere(\sprintf('%s.%s %s EMPTY', $alias, $field, $value ? 'IS NOT' : 'IS')); return; } @@ -173,20 +173,20 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB $alias = QueryBuilderHelper::addJoinOnce($queryBuilder, $queryNameGenerator, $alias, $field, Join::LEFT_JOIN); $queryBuilder - ->andWhere(sprintf('%s %s NULL', $alias, $value ? 'IS NOT' : 'IS')); + ->andWhere(\sprintf('%s %s NULL', $alias, $value ? 'IS NOT' : 'IS')); return; } $queryBuilder - ->andWhere(sprintf('%s.%s %s NULL', $alias, $field, $value ? 'IS NOT' : 'IS')); + ->andWhere(\sprintf('%s.%s %s NULL', $alias, $field, $value ? 'IS NOT' : 'IS')); return; } if ($metadata->hasField($field)) { $queryBuilder - ->andWhere(sprintf('%s.%s %s NULL', $alias, $field, $value ? 'IS NOT' : 'IS')); + ->andWhere(\sprintf('%s.%s %s NULL', $alias, $field, $value ? 'IS NOT' : 'IS')); } } diff --git a/src/Doctrine/Orm/Filter/NumericFilter.php b/src/Doctrine/Orm/Filter/NumericFilter.php index c27e3f648a4..545b552d040 100644 --- a/src/Doctrine/Orm/Filter/NumericFilter.php +++ b/src/Doctrine/Orm/Filter/NumericFilter.php @@ -152,11 +152,11 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB if (1 === \count($values)) { $queryBuilder - ->andWhere(sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $values[0], (string) $this->getDoctrineFieldType($property, $resourceClass)); } else { $queryBuilder - ->andWhere(sprintf('%s.%s IN (:%s)', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s IN (:%s)', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $values); } } diff --git a/src/Doctrine/Orm/Filter/OrderFilter.php b/src/Doctrine/Orm/Filter/OrderFilter.php index 1987ee2c4a8..b2abdabb94c 100644 --- a/src/Doctrine/Orm/Filter/OrderFilter.php +++ b/src/Doctrine/Orm/Filter/OrderFilter.php @@ -263,12 +263,12 @@ protected function filterProperty(string $property, $direction, QueryBuilder $qu if (null !== $nullsComparison = $this->properties[$property]['nulls_comparison'] ?? $this->orderNullsComparison) { $nullsDirection = self::NULLS_DIRECTION_MAP[$nullsComparison][$direction]; - $nullRankHiddenField = sprintf('_%s_%s_null_rank', $alias, str_replace('.', '_', $field)); + $nullRankHiddenField = \sprintf('_%s_%s_null_rank', $alias, str_replace('.', '_', $field)); - $queryBuilder->addSelect(sprintf('CASE WHEN %s.%s IS NULL THEN 0 ELSE 1 END AS HIDDEN %s', $alias, $field, $nullRankHiddenField)); + $queryBuilder->addSelect(\sprintf('CASE WHEN %s.%s IS NULL THEN 0 ELSE 1 END AS HIDDEN %s', $alias, $field, $nullRankHiddenField)); $queryBuilder->addOrderBy($nullRankHiddenField, $nullsDirection); } - $queryBuilder->addOrderBy(sprintf('%s.%s', $alias, $field), $direction); + $queryBuilder->addOrderBy(\sprintf('%s.%s', $alias, $field), $direction); } } diff --git a/src/Doctrine/Orm/Filter/RangeFilter.php b/src/Doctrine/Orm/Filter/RangeFilter.php index 70c3e6867d0..85de7117171 100644 --- a/src/Doctrine/Orm/Filter/RangeFilter.php +++ b/src/Doctrine/Orm/Filter/RangeFilter.php @@ -164,16 +164,16 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf if ($rangeValue[0] === $rangeValue[1]) { $queryBuilder - ->andWhere(sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s = :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $rangeValue[0]); return; } $queryBuilder - ->andWhere(sprintf('%1$s.%2$s BETWEEN :%3$s_1 AND :%3$s_2', $alias, $field, $valueParameter)) - ->setParameter(sprintf('%s_1', $valueParameter), $rangeValue[0]) - ->setParameter(sprintf('%s_2', $valueParameter), $rangeValue[1]); + ->andWhere(\sprintf('%1$s.%2$s BETWEEN :%3$s_1 AND :%3$s_2', $alias, $field, $valueParameter)) + ->setParameter(\sprintf('%s_1', $valueParameter), $rangeValue[0]) + ->setParameter(\sprintf('%s_2', $valueParameter), $rangeValue[1]); break; case self::PARAMETER_GREATER_THAN: @@ -183,7 +183,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf } $queryBuilder - ->andWhere(sprintf('%s.%s > :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s > :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); break; @@ -194,7 +194,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf } $queryBuilder - ->andWhere(sprintf('%s.%s >= :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s >= :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); break; @@ -205,7 +205,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf } $queryBuilder - ->andWhere(sprintf('%s.%s < :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s < :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); break; @@ -216,7 +216,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf } $queryBuilder - ->andWhere(sprintf('%s.%s <= :%s', $alias, $field, $valueParameter)) + ->andWhere(\sprintf('%s.%s <= :%s', $alias, $field, $valueParameter)) ->setParameter($valueParameter, $value); break; diff --git a/src/Doctrine/Orm/Filter/SearchFilter.php b/src/Doctrine/Orm/Filter/SearchFilter.php index 61b35b77bd7..d0caccb94d4 100644 --- a/src/Doctrine/Orm/Filter/SearchFilter.php +++ b/src/Doctrine/Orm/Filter/SearchFilter.php @@ -203,7 +203,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; @@ -241,7 +241,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB */ if (!$this->hasValidValues([$value], $doctrineTypeField)) { $this->logger->notice('Invalid filter ignored', [ - 'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $associationFieldIdentifier)), + 'exception' => new InvalidArgumentException(\sprintf('Values for field "%s" are not valid according to the doctrine type.', $associationFieldIdentifier)), ]); return null; @@ -258,7 +258,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB * Shouldn't this actually fail harder? */ $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; @@ -287,7 +287,7 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild $wrapCase = $this->createWrapCase($caseSensitive); $valueParameter = ':'.$queryNameGenerator->generateParameterName($field); - $aliasedField = sprintf('%s.%s', $alias, $field); + $aliasedField = \sprintf('%s.%s', $alias, $field); if (!$strategy || self::STRATEGY_EXACT === $strategy) { if (1 === \count($values)) { @@ -308,7 +308,7 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild $ors = []; $parameters = []; foreach ($values as $key => $value) { - $keyValueParameter = sprintf('%s_%s', $valueParameter, $key); + $keyValueParameter = \sprintf('%s_%s', $valueParameter, $key); $parameters[] = [$caseSensitive ? $value : strtolower($value), $keyValueParameter]; $ors[] = match ($strategy) { @@ -334,7 +334,7 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild $wrapCase((string) $queryBuilder->expr()->concat("'% '", $keyValueParameter, "'%'")) ) ), - default => throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy)), + default => throw new InvalidArgumentException(\sprintf('strategy %s does not exist.', $strategy)), }; } @@ -358,7 +358,7 @@ protected function createWrapCase(bool $caseSensitive): \Closure return $expr; } - return sprintf('LOWER(%s)', $expr); + return \sprintf('LOWER(%s)', $expr); }; } diff --git a/src/Doctrine/Orm/PropertyHelperTrait.php b/src/Doctrine/Orm/PropertyHelperTrait.php index a8086ca15d0..8431e3e1680 100644 --- a/src/Doctrine/Orm/PropertyHelperTrait.php +++ b/src/Doctrine/Orm/PropertyHelperTrait.php @@ -73,7 +73,7 @@ protected function addJoinsForNestedProperty(string $property, string $rootAlias } if (null === $alias) { - throw new InvalidArgumentException(sprintf('Cannot add joins for property "%s" - property is not nested.', $property)); + throw new InvalidArgumentException(\sprintf('Cannot add joins for property "%s" - property is not nested.', $property)); } return [$alias, $propertyParts['field'], $propertyParts['associations']]; diff --git a/src/Doctrine/Orm/Tests/AppKernel.php b/src/Doctrine/Orm/Tests/AppKernel.php index 3f1efecf06d..94b796bb140 100644 --- a/src/Doctrine/Orm/Tests/AppKernel.php +++ b/src/Doctrine/Orm/Tests/AppKernel.php @@ -44,7 +44,7 @@ public function registerBundles(): array new FrameworkBundle(), new DoctrineBundle(), new TestBundle(), - new class() extends Bundle { + new class extends Bundle { public function shutdown(): void { restore_exception_handler(); diff --git a/src/Doctrine/Orm/Tests/DoctrineOrmFilterTestCase.php b/src/Doctrine/Orm/Tests/DoctrineOrmFilterTestCase.php index 9a2c0e94f58..1b8b25cfa10 100644 --- a/src/Doctrine/Orm/Tests/DoctrineOrmFilterTestCase.php +++ b/src/Doctrine/Orm/Tests/DoctrineOrmFilterTestCase.php @@ -76,8 +76,8 @@ protected function doTestApply(?array $properties, array $filterParameters, stri foreach ($expectedParameters as $parameterName => $expectedParameterValue) { $queryParameter = $queryBuilder->getQuery()->getParameter($parameterName); - $this->assertNotNull($queryParameter, sprintf('Expected query parameter "%s" to be set', $parameterName)); - $this->assertEquals($expectedParameterValue, $queryParameter->getValue(), sprintf('Expected query parameter "%s" to be "%s"', $parameterName, var_export($expectedParameterValue, true))); + $this->assertNotNull($queryParameter, \sprintf('Expected query parameter "%s" to be set', $parameterName)); + $this->assertEquals($expectedParameterValue, $queryParameter->getValue(), \sprintf('Expected query parameter "%s" to be "%s"', $parameterName, var_export($expectedParameterValue, true))); } } diff --git a/src/Doctrine/Orm/Tests/Filter/BooleanFilterTest.php b/src/Doctrine/Orm/Tests/Filter/BooleanFilterTest.php index 1fdd6aa46e8..0be3965761f 100644 --- a/src/Doctrine/Orm/Tests/Filter/BooleanFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/BooleanFilterTest.php @@ -32,37 +32,37 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'string ("true")' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], 'string ("false")' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], 'non-boolean' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'numeric string ("0")' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], 'numeric string ("1")' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], 'nested properties' => [ - sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], 'numeric string ("1") on non-boolean property' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'numeric string ("0") on non-boolean property' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'string ("true") on non-boolean property' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'string ("false") on non-boolean property' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'mixed boolean, non-boolean and invalid property' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyBoolean = :dummyBoolean_p1', Dummy::class), ], ] ); diff --git a/src/Doctrine/Orm/Tests/Filter/DateFilterTest.php b/src/Doctrine/Orm/Tests/Filter/DateFilterTest.php index 01d5e72f483..cd66dd13f19 100644 --- a/src/Doctrine/Orm/Tests/Filter/DateFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/DateFilterTest.php @@ -62,58 +62,58 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'after (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1', Dummy::class), ], 'after but not equals (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate > :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate > :dummyDate_p1', Dummy::class), ], 'after' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1', Dummy::class), ], 'after but not equals' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate > :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate > :dummyDate_p1', Dummy::class), ], 'before (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1', Dummy::class), ], 'before but not equals (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1', Dummy::class), ], 'before' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1', Dummy::class), ], 'before but not equals' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1', Dummy::class), ], 'before + after (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1 AND o.dummyDate >= :dummyDate_p2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1 AND o.dummyDate >= :dummyDate_p2', Dummy::class), ], 'before but not equals + after but not equals (all properties enabled)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1 AND o.dummyDate > :dummyDate_p2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1 AND o.dummyDate > :dummyDate_p2', Dummy::class), ], 'before + after' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1 AND o.dummyDate >= :dummyDate_p2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate <= :dummyDate_p1 AND o.dummyDate >= :dummyDate_p2', Dummy::class), ], 'before but not equals + after but not equals' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1 AND o.dummyDate > :dummyDate_p2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate < :dummyDate_p1 AND o.dummyDate > :dummyDate_p2', Dummy::class), ], 'property not enabled' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'nested property' => [ - sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.dummyDate >= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.dummyDate >= :dummyDate_p1', Dummy::class), ], 'after (exclude_null)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate IS NOT NULL AND o.dummyDate >= :dummyDate_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate IS NOT NULL AND o.dummyDate >= :dummyDate_p1', Dummy::class), ], 'after (include_null_after)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1 OR o.dummyDate IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1 OR o.dummyDate IS NULL', Dummy::class), ], 'include null before and after (include_null_before_and_after)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1 OR o.dummyDate IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyDate >= :dummyDate_p1 OR o.dummyDate IS NULL', Dummy::class), ], 'bad date format' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], ] ); diff --git a/src/Doctrine/Orm/Tests/Filter/ExistsFilterTest.php b/src/Doctrine/Orm/Tests/Filter/ExistsFilterTest.php index 9f3f345b284..fa9f0a71378 100644 --- a/src/Doctrine/Orm/Tests/Filter/ExistsFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/ExistsFilterTest.php @@ -100,121 +100,121 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'valid values' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'valid values (empty for true)' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'valid values (1 for true)' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'invalid values' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), null, $existsFilterFactory, ], 'negative values' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NULL', Dummy::class), null, $existsFilterFactory, ], 'negative values (0)' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NULL', Dummy::class), null, $existsFilterFactory, ], 'multiple values (true and true)' => [ - sprintf('SELECT o FROM %s o WHERE o.alias IS NOT NULL AND o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.alias IS NOT NULL AND o.description IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'multiple values (1 and 0)' => [ - sprintf('SELECT o FROM %s o WHERE o.alias IS NOT NULL AND o.description IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.alias IS NOT NULL AND o.description IS NULL', Dummy::class), null, $existsFilterFactory, ], 'multiple values (false and 0)' => [ - sprintf('SELECT o FROM %s o WHERE o.alias IS NULL AND o.description IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.alias IS NULL AND o.description IS NULL', Dummy::class), null, $existsFilterFactory, ], 'custom exists parameter name' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), null, $customExistsFilterFactory, ], 'related values' => [ - sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE o.description IS NOT NULL AND relatedDummy_a1.name IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE o.description IS NOT NULL AND relatedDummy_a1.name IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'not nullable values' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'related collection not empty' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummies IS NOT EMPTY', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummies IS NOT EMPTY', Dummy::class), null, $existsFilterFactory, ], 'related collection empty' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummies IS EMPTY', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummies IS EMPTY', Dummy::class), null, $existsFilterFactory, ], 'related association exists' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummy IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummy IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'related association does not exist' => [ - sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummy IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.description IS NOT NULL AND o.relatedDummy IS NULL', Dummy::class), null, $existsFilterFactory, ], 'related owned association does not exist' => [ - sprintf('SELECT o FROM %s o LEFT JOIN o.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1 IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o LEFT JOIN o.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1 IS NULL', Dummy::class), null, $existsFilterFactory, ], 'related owned association exists' => [ - sprintf('SELECT o FROM %s o LEFT JOIN o.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1 IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o LEFT JOIN o.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1 IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], 'related owning association does not exist' => [ - sprintf('SELECT o FROM %s o WHERE o.relatedOwningDummy IS NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.relatedOwningDummy IS NULL', Dummy::class), null, $existsFilterFactory, ], 'related owning association exists' => [ - sprintf('SELECT o FROM %s o WHERE o.relatedOwningDummy IS NOT NULL', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.relatedOwningDummy IS NOT NULL', Dummy::class), null, $existsFilterFactory, ], diff --git a/src/Doctrine/Orm/Tests/Filter/NumericFilterTest.php b/src/Doctrine/Orm/Tests/Filter/NumericFilterTest.php index d5a4eda625b..2ef8494f09f 100644 --- a/src/Doctrine/Orm/Tests/Filter/NumericFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/NumericFilterTest.php @@ -76,37 +76,37 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'numeric string (positive integer)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'multiple numeric string (positive integer)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice IN (:dummyPrice_p1)', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice IN (:dummyPrice_p1)', Dummy::class), ], 'multiple numeric string with one invalid property key' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'multiple numeric string with invalid value keys' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'multiple non-numeric' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'numeric string (negative integer)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'non-numeric' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'numeric string ("0")' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'nested property' => [ - sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.id = :id_p1', Dummy::class), + \sprintf('SELECT o FROM %s o INNER JOIN o.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.id = :id_p1', Dummy::class), ], 'mixed numeric and non-numeric' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'mixed numeric, non-numeric and invalid property' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], ] ); diff --git a/src/Doctrine/Orm/Tests/Filter/OrderFilterTest.php b/src/Doctrine/Orm/Tests/Filter/OrderFilterTest.php index 8864928edd1..f75fb5add2a 100644 --- a/src/Doctrine/Orm/Tests/Filter/OrderFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/OrderFilterTest.php @@ -323,119 +323,119 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'valid values' => [ - sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'invalid values' => [ - sprintf('SELECT o FROM %s o ORDER BY o.id ASC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.id ASC', Dummy::class), null, $orderFilterFactory, ], 'valid values (properties not enabled)' => [ - sprintf('SELECT o FROM %s o ORDER BY o.id ASC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.id ASC', Dummy::class), null, $orderFilterFactory, ], 'invalid values (properties not enabled)' => [ - sprintf('SELECT o FROM %s o ORDER BY o.name ASC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.name ASC', Dummy::class), null, $orderFilterFactory, ], 'invalid property (property not enabled)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), null, $orderFilterFactory, ], 'invalid property (property enabled)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), null, $orderFilterFactory, ], 'custom order parameter name' => [ - sprintf('SELECT o FROM %s o ORDER BY o.name DESC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.name DESC', Dummy::class), null, $customOrderFilterFactory, ], 'valid values (all properties enabled)' => [ - sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name ASC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name ASC', Dummy::class), null, $orderFilterFactory, ], 'nested property' => [ - sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY o.id ASC, o.name DESC, relatedDummy_a1.symfony DESC', Dummy::class), + \sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY o.id ASC, o.name DESC, relatedDummy_a1.symfony DESC', Dummy::class), null, $orderFilterFactory, ], 'empty values with default sort direction' => [ - sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.id ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_smallest (asc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_smallest (desc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate DESC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate DESC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_largest (asc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_largest (desc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate DESC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate DESC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_always_first (asc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_always_first (desc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate DESC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank ASC, o.dummyDate DESC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_always_last (asc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate ASC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate ASC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'nulls_always_last (desc)' => [ - sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate DESC, o.name DESC', Dummy::class), + \sprintf('SELECT o, CASE WHEN o.dummyDate IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_dummyDate_null_rank FROM %s o ORDER BY _o_dummyDate_null_rank DESC, o.dummyDate DESC, o.name DESC', Dummy::class), null, $orderFilterFactory, ], 'not having order should not throw a deprecation (select unchanged)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), null, $orderFilterFactory, ], 'not nullable relation will be a LEFT JOIN' => [ - sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY relatedDummy_a1.name ASC', Dummy::class), + \sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY relatedDummy_a1.name ASC', Dummy::class), null, $orderFilterFactory, ], 'embedded' => [ - sprintf('SELECT o FROM %s o ORDER BY o.embeddedDummy.dummyName ASC', EmbeddedDummy::class), + \sprintf('SELECT o FROM %s o ORDER BY o.embeddedDummy.dummyName ASC', EmbeddedDummy::class), null, $orderFilterFactory, EmbeddedDummy::class, ], 'embedded with nulls_comparison' => [ - sprintf('SELECT o, CASE WHEN o.embeddedDummy.dummyName IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_embeddedDummy_dummyName_null_rank FROM %s o ORDER BY _o_embeddedDummy_dummyName_null_rank DESC, o.embeddedDummy.dummyName ASC', EmbeddedDummy::class), + \sprintf('SELECT o, CASE WHEN o.embeddedDummy.dummyName IS NULL THEN 0 ELSE 1 END AS HIDDEN _o_embeddedDummy_dummyName_null_rank FROM %s o ORDER BY _o_embeddedDummy_dummyName_null_rank DESC, o.embeddedDummy.dummyName ASC', EmbeddedDummy::class), null, $orderFilterFactory, EmbeddedDummy::class, ], 'nullable field in relation will be a LEFT JOIN' => [ - sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY relatedDummy_a1.name ASC', Dummy::class), + \sprintf('SELECT o FROM %s o LEFT JOIN o.relatedDummy relatedDummy_a1 ORDER BY relatedDummy_a1.name ASC', Dummy::class), null, $orderFilterFactory, ], diff --git a/src/Doctrine/Orm/Tests/Filter/RangeFilterTest.php b/src/Doctrine/Orm/Tests/Filter/RangeFilterTest.php index ac31b95ecb4..3fbdb9ffb67 100644 --- a/src/Doctrine/Orm/Tests/Filter/RangeFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/RangeFilterTest.php @@ -340,46 +340,46 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'between' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice BETWEEN :dummyPrice_p1_1 AND :dummyPrice_p1_2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice BETWEEN :dummyPrice_p1_1 AND :dummyPrice_p1_2', Dummy::class), ], 'between (same values)' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class), ], 'between (too many operands)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'between (too few operands)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'between (non-numeric operands)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'lt' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice < :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice < :dummyPrice_p1', Dummy::class), ], 'lt (non-numeric)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'lte' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice <= :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice <= :dummyPrice_p1', Dummy::class), ], 'lte (non-numeric)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'gt' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice > :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice > :dummyPrice_p1', Dummy::class), ], 'gt (non-numeric)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'gte' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice >= :dummyPrice_p1', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice >= :dummyPrice_p1', Dummy::class), ], 'gte (non-numeric)' => [ - sprintf('SELECT o FROM %s o', Dummy::class), + \sprintf('SELECT o FROM %s o', Dummy::class), ], 'lte + gte' => [ - sprintf('SELECT o FROM %s o WHERE o.dummyPrice >= :dummyPrice_p1 AND o.dummyPrice <= :dummyPrice_p2', Dummy::class), + \sprintf('SELECT o FROM %s o WHERE o.dummyPrice >= :dummyPrice_p1 AND o.dummyPrice <= :dummyPrice_p2', Dummy::class), ], ] ); diff --git a/src/Doctrine/Orm/Tests/Filter/SearchFilterTest.php b/src/Doctrine/Orm/Tests/Filter/SearchFilterTest.php index 89f2e3f372e..0b11fb16b45 100644 --- a/src/Doctrine/Orm/Tests/Filter/SearchFilterTest.php +++ b/src/Doctrine/Orm/Tests/Filter/SearchFilterTest.php @@ -221,11 +221,11 @@ public function testDoubleJoin(): void $queryBuilder = $this->repository->createQueryBuilder(static::ALIAS); $filter = self::buildSearchFilter($this, $this->managerRegistry, ['relatedDummy.symfony' => null]); - $queryBuilder->innerJoin(sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); + $queryBuilder->innerJoin(\sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); $filter->apply($queryBuilder, new QueryNameGenerator(), $this->resourceClass, new Get(), ['filters' => $filters]); $actual = strtolower($queryBuilder->getQuery()->getDQL()); - $expected = strtolower(sprintf('SELECT %s FROM %s %1$s inner join %1$s.relatedDummy relateddummy_a1 WHERE relateddummy_a1.symfony = :symfony_p1', static::ALIAS, Dummy::class)); + $expected = strtolower(\sprintf('SELECT %s FROM %s %1$s inner join %1$s.relatedDummy relateddummy_a1 WHERE relateddummy_a1.symfony = :symfony_p1', static::ALIAS, Dummy::class)); $this->assertSame($actual, $expected); } @@ -236,12 +236,12 @@ public function testTripleJoin(): void $queryBuilder = $this->repository->createQueryBuilder(static::ALIAS); $filter = self::buildSearchFilter($this, $this->managerRegistry, ['relatedDummy.symfony' => null, 'relatedDummy.thirdLevel.level' => null]); - $queryBuilder->innerJoin(sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); + $queryBuilder->innerJoin(\sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); $queryBuilder->innerJoin('relateddummy_a1.thirdLevel', 'thirdLevel_a1'); $filter->apply($queryBuilder, new QueryNameGenerator(), $this->resourceClass, new Get(), ['filters' => $filters]); $actual = strtolower($queryBuilder->getQuery()->getDQL()); - $expected = strtolower(sprintf('SELECT %s FROM %s %1$s inner join %1$s.relatedDummy relateddummy_a1 inner join relateddummy_a1.thirdLevel thirdLevel_a1 WHERE relateddummy_a1.symfony = :symfony_p1 and thirdLevel_a1.level = :level_p2', static::ALIAS, Dummy::class)); + $expected = strtolower(\sprintf('SELECT %s FROM %s %1$s inner join %1$s.relatedDummy relateddummy_a1 inner join relateddummy_a1.thirdLevel thirdLevel_a1 WHERE relateddummy_a1.symfony = :symfony_p1 and thirdLevel_a1.level = :level_p2', static::ALIAS, Dummy::class)); $this->assertSame($actual, $expected); } @@ -250,13 +250,13 @@ public function testJoinLeft(): void $filters = ['relatedDummy.symfony' => 'foo', 'relatedDummy.thirdLevel.level' => '3']; $queryBuilder = $this->repository->createQueryBuilder(static::ALIAS); - $queryBuilder->leftJoin(sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); + $queryBuilder->leftJoin(\sprintf('%s.relatedDummy', static::ALIAS), 'relateddummy_a1'); $filter = self::buildSearchFilter($this, $this->managerRegistry, ['relatedDummy.symfony' => null, 'relatedDummy.thirdLevel.level' => null]); $filter->apply($queryBuilder, new QueryNameGenerator(), $this->resourceClass, new Get(), ['filters' => $filters]); $actual = strtolower($queryBuilder->getQuery()->getDQL()); - $expected = strtolower(sprintf('SELECT %s FROM %s %1$s left join %1$s.relatedDummy relateddummy_a1 left join relateddummy_a1.thirdLevel thirdLevel_a1 WHERE relateddummy_a1.symfony = :symfony_p1 and thirdLevel_a1.level = :level_p2', static::ALIAS, Dummy::class)); + $expected = strtolower(\sprintf('SELECT %s FROM %s %1$s left join %1$s.relatedDummy relateddummy_a1 left join relateddummy_a1.thirdLevel thirdLevel_a1 WHERE relateddummy_a1.symfony = :symfony_p1 and thirdLevel_a1.level = :level_p2', static::ALIAS, Dummy::class)); $this->assertSame($actual, $expected); } @@ -269,7 +269,7 @@ public function testApplyWithAnotherAlias(): void $filter = self::buildSearchFilter($this, $this->managerRegistry, ['id' => null, 'name' => null]); $filter->apply($queryBuilder, new QueryNameGenerator(), $this->resourceClass, new Get(), ['filters' => $filters]); - $expectedDql = sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', 'somealias', Dummy::class); + $expectedDql = \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', 'somealias', Dummy::class); $this->assertSame($expectedDql, $queryBuilder->getQuery()->getDQL()); } @@ -281,22 +281,22 @@ public static function provideApplyTestData(): array self::provideApplyTestArguments(), [ 'exact' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', static::ALIAS, Dummy::class), ['name_p1' => 'exact'], $filterFactory, ], 'exact (case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) = LOWER(:name_p1)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) = LOWER(:name_p1)', static::ALIAS, Dummy::class), ['name_p1' => 'exact'], $filterFactory, ], 'exact (case insensitive, with special characters)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) = LOWER(:name_p1)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) = LOWER(:name_p1)', static::ALIAS, Dummy::class), ['name_p1' => 'exact (special)'], $filterFactory, ], 'exact (multiple values)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name IN(:name_p1)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name IN(:name_p1)', static::ALIAS, Dummy::class), [ 'name_p1' => [ 'CaSE', @@ -306,7 +306,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'exact (multiple values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) IN(:name_p1)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) IN(:name_p1)', static::ALIAS, Dummy::class), [ 'name_p1' => [ 'case', @@ -316,27 +316,27 @@ public static function provideApplyTestData(): array $filterFactory, ], 'invalid property' => [ - sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), [], $filterFactory, ], 'invalid values for relations' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name = :name_p1', static::ALIAS, Dummy::class), [], $filterFactory, ], 'partial' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0, \'%%\')', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0, \'%%\')', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'partial (case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'partial (multiple values)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%%\', :name_p1_1, \'%%\')', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%%\', :name_p1_1, \'%%\')', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'CaSE', 'name_p1_1' => 'SENSitive', @@ -344,7 +344,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'partial (multiple values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'case', 'name_p1_1' => 'insensitive', @@ -352,7 +352,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'partial (multiple almost same values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'blue car', 'name_p1_1' => 'blue car', @@ -360,17 +360,17 @@ public static function provideApplyTestData(): array $filterFactory, ], 'start' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\')', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\')', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'start (case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'start (multiple values)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(:name_p1_1, \'%%\')', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(:name_p1_1, \'%%\')', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'CaSE', 'name_p1_1' => 'SENSitive', @@ -378,7 +378,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'start (multiple values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'case', 'name_p1_1' => 'insensitive', @@ -386,17 +386,17 @@ public static function provideApplyTestData(): array $filterFactory, ], 'end' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0)', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'end (case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0))', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'end (multiple values)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0) OR %1$s.name LIKE CONCAT(\'%%\', :name_p1_1)', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(\'%%\', :name_p1_0) OR %1$s.name LIKE CONCAT(\'%%\', :name_p1_1)', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'CaSE', 'name_p1_1' => 'SENSitive', @@ -404,7 +404,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'end (multiple values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0)) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_0)) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%%\', :name_p1_1))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'case', 'name_p1_1' => 'insensitive', @@ -412,17 +412,17 @@ public static function provideApplyTestData(): array $filterFactory, ], 'word_start' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_0, \'%%\')', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_0, \'%%\')', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'word_start (case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_0, \'%%\'))', static::ALIAS, Dummy::class), ['name_p1_0' => 'partial'], $filterFactory, ], 'word_start (multiple values)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE (%1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_0, \'%%\')) OR (%1$s.name LIKE CONCAT(:name_p1_1, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE (%1$s.name LIKE CONCAT(:name_p1_0, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_0, \'%%\')) OR (%1$s.name LIKE CONCAT(:name_p1_1, \'%%\') OR %1$s.name LIKE CONCAT(\'%% \', :name_p1_1, \'%%\'))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'CaSE', 'name_p1_1' => 'SENSitive', @@ -430,7 +430,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'word_start (multiple values; case insensitive)' => [ - sprintf('SELECT %s FROM %s %1$s WHERE (LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_0, \'%%\'))) OR (LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_1, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_1, \'%%\')))', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE (LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_0, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_0, \'%%\'))) OR (LOWER(%1$s.name) LIKE LOWER(CONCAT(:name_p1_1, \'%%\')) OR LOWER(%1$s.name) LIKE LOWER(CONCAT(\'%% \', :name_p1_1, \'%%\')))', static::ALIAS, Dummy::class), [ 'name_p1_0' => 'case', 'name_p1_1' => 'insensitive', @@ -438,7 +438,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'invalid value for relation' => [ - sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), [], $filterFactory, ], @@ -451,17 +451,17 @@ public static function provideApplyTestData(): array [ 'relatedDummy' => '/related_dummie/1', ], - sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), [], $filterFactory, ], 'IRI value for relation' => [ - sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.id = :id_p1', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummy relatedDummy_a1 WHERE relatedDummy_a1.id = :id_p1', static::ALIAS, Dummy::class), ['id_p1' => 1], $filterFactory, ], 'mixed IRI and entity ID values for relations' => [ - sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummies relatedDummies_a1 WHERE %1$s.relatedDummy IN(:relatedDummy_p1) AND relatedDummies_a1.id = :id_p2', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummies relatedDummies_a1 WHERE %1$s.relatedDummy IN(:relatedDummy_p1) AND relatedDummies_a1.id = :id_p2', static::ALIAS, Dummy::class), [ 'relatedDummy_p1' => [1, 2], 'id_p2' => 1, @@ -469,7 +469,7 @@ public static function provideApplyTestData(): array $filterFactory, ], 'nested property' => [ - sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummy relatedDummy_a1 WHERE %1$s.name = :name_p1 AND relatedDummy_a1.symfony = :symfony_p2', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedDummy relatedDummy_a1 WHERE %1$s.name = :name_p1 AND relatedDummy_a1.symfony = :symfony_p2', static::ALIAS, Dummy::class), [ 'name_p1' => 'exact', 'symfony_p2' => 'exact', @@ -477,24 +477,24 @@ public static function provideApplyTestData(): array $filterFactory, ], 'empty nested property' => [ - sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s', static::ALIAS, Dummy::class), [], $filterFactory, ], 'integer value' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.age = :age_p1', static::ALIAS, RelatedDummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.age = :age_p1', static::ALIAS, RelatedDummy::class), ['age_p1' => 46], $filterFactory, RelatedDummy::class, ], 'related owned one-to-one association' => [ - sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1.id = :id_p1', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s INNER JOIN %1$s.relatedOwnedDummy relatedOwnedDummy_a1 WHERE relatedOwnedDummy_a1.id = :id_p1', static::ALIAS, Dummy::class), ['id_p1' => 1], $filterFactory, Dummy::class, ], 'related owning one-to-one association' => [ - sprintf('SELECT %s FROM %s %1$s WHERE %1$s.relatedOwningDummy = :relatedOwningDummy_p1', static::ALIAS, Dummy::class), + \sprintf('SELECT %s FROM %s %1$s WHERE %1$s.relatedOwningDummy = :relatedOwningDummy_p1', static::ALIAS, Dummy::class), ['relatedOwningDummy_p1' => 1], $filterFactory, Dummy::class, diff --git a/src/Doctrine/Orm/Util/QueryBuilderHelper.php b/src/Doctrine/Orm/Util/QueryBuilderHelper.php index 7814f988d6d..54956fcc595 100644 --- a/src/Doctrine/Orm/Util/QueryBuilderHelper.php +++ b/src/Doctrine/Orm/Util/QueryBuilderHelper.php @@ -57,7 +57,7 @@ public static function addJoinOnce(QueryBuilder $queryBuilder, QueryNameGenerato public static function getEntityClassByAlias(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): string { if (!\in_array($alias, $queryBuilder->getAllAliases(), true)) { - throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); + throw new \LogicException(\sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); } $rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities()); @@ -73,7 +73,7 @@ public static function getEntityClassByAlias(string $alias, QueryBuilder $queryB } if (null === $metadata) { - throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); + throw new \LogicException(\sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); } return $metadata->getName(); @@ -96,7 +96,7 @@ public static function findRootAlias(string $alias, QueryBuilder $queryBuilder): } } - throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); + throw new \LogicException(\sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias)); } /** @@ -122,7 +122,7 @@ public static function traverseJoins(string $alias, QueryBuilder $queryBuilder, while (null === $apexEntityClass) { if (!isset($aliasMap[$currentAlias])) { - throw new \LogicException(sprintf('Unknown alias "%s".', $currentAlias)); + throw new \LogicException(\sprintf('Unknown alias "%s".', $currentAlias)); } if (\is_string($aliasMap[$currentAlias])) { @@ -171,7 +171,7 @@ public static function getExistingJoin(QueryBuilder $queryBuilder, string $alias foreach ($parts[$rootAlias] as $join) { /** @var Join $join */ - if (sprintf('%s.%s', $alias, $association) === $join->getJoin()) { + if (\sprintf('%s.%s', $alias, $association) === $join->getJoin()) { return $join; } } diff --git a/src/Doctrine/Orm/Util/QueryNameGenerator.php b/src/Doctrine/Orm/Util/QueryNameGenerator.php index 810a1e050c4..f6a47d2b0d0 100644 --- a/src/Doctrine/Orm/Util/QueryNameGenerator.php +++ b/src/Doctrine/Orm/Util/QueryNameGenerator.php @@ -30,7 +30,7 @@ final class QueryNameGenerator implements QueryNameGeneratorInterface */ public function generateJoinAlias(string $association): string { - return sprintf('%s_a%d', $association, $this->incrementedAssociation++); + return \sprintf('%s_a%d', $association, $this->incrementedAssociation++); } /** @@ -38,6 +38,6 @@ public function generateJoinAlias(string $association): string */ public function generateParameterName(string $name): string { - return sprintf('%s_p%d', str_replace('.', '_', $name), $this->incrementedName++); + return \sprintf('%s_p%d', str_replace('.', '_', $name), $this->incrementedName++); } } diff --git a/src/Elasticsearch/Serializer/DocumentNormalizer.php b/src/Elasticsearch/Serializer/DocumentNormalizer.php index 0ab75a6e18a..1d523d66633 100644 --- a/src/Elasticsearch/Serializer/DocumentNormalizer.php +++ b/src/Elasticsearch/Serializer/DocumentNormalizer.php @@ -89,7 +89,7 @@ public function supportsNormalization(mixed $data, ?string $format = null, array */ public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null { - throw new LogicException(sprintf('%s is a write-only format.', self::FORMAT)); + throw new LogicException(\sprintf('%s is a write-only format.', self::FORMAT)); } /** diff --git a/src/Elasticsearch/Serializer/ItemNormalizer.php b/src/Elasticsearch/Serializer/ItemNormalizer.php index e45ca74ec4e..74c1194b609 100644 --- a/src/Elasticsearch/Serializer/ItemNormalizer.php +++ b/src/Elasticsearch/Serializer/ItemNormalizer.php @@ -41,7 +41,7 @@ public function __construct(private readonly NormalizerInterface $decorated) public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed { if (!$this->decorated instanceof DenormalizerInterface) { - throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); + throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); } return $this->decorated->denormalize($data, $type, $format, $context); @@ -55,7 +55,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { if (!$this->decorated instanceof DenormalizerInterface) { - throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); + throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); } return DocumentNormalizer::FORMAT !== $format && $this->decorated->supportsDenormalization($data, $type, $format, $context); @@ -97,7 +97,7 @@ public function getSupportedTypes($format): array public function setSerializer(SerializerInterface $serializer): void { if (!$this->decorated instanceof SerializerAwareInterface) { - throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', SerializerAwareInterface::class)); + throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', SerializerAwareInterface::class)); } $this->decorated->setSerializer($serializer); diff --git a/src/Elasticsearch/State/ItemProvider.php b/src/Elasticsearch/State/ItemProvider.php index 21523af54c1..7828145f89d 100644 --- a/src/Elasticsearch/State/ItemProvider.php +++ b/src/Elasticsearch/State/ItemProvider.php @@ -46,7 +46,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c $resourceClass = $operation->getClass(); $options = $operation->getStateOptions() instanceof Options ? $operation->getStateOptions() : new Options(index: $this->getIndex($operation)); if (!$options instanceof Options) { - throw new RuntimeException(sprintf('The "%s" provider was called without "%s".', self::class, Options::class)); + throw new RuntimeException(\sprintf('The "%s" provider was called without "%s".', self::class, Options::class)); } $params = [ diff --git a/src/Elasticsearch/Tests/Serializer/DocumentNormalizerTest.php b/src/Elasticsearch/Tests/Serializer/DocumentNormalizerTest.php index 554a5dd84ae..8ae0afc9b27 100644 --- a/src/Elasticsearch/Tests/Serializer/DocumentNormalizerTest.php +++ b/src/Elasticsearch/Tests/Serializer/DocumentNormalizerTest.php @@ -95,7 +95,7 @@ public function testSupportsNormalization(): void public function testNormalize(): void { $this->expectException(LogicException::class); - $this->expectExceptionMessage(sprintf('%s is a write-only format.', DocumentNormalizer::FORMAT)); + $this->expectExceptionMessage(\sprintf('%s is a write-only format.', DocumentNormalizer::FORMAT)); (new DocumentNormalizer($this->prophesize(ResourceMetadataCollectionFactoryInterface::class)->reveal()))->normalize(new Foo(), DocumentNormalizer::FORMAT); } diff --git a/src/Elasticsearch/Tests/Serializer/ItemNormalizerTest.php b/src/Elasticsearch/Tests/Serializer/ItemNormalizerTest.php index f18960e13a0..7819eb3951c 100644 --- a/src/Elasticsearch/Tests/Serializer/ItemNormalizerTest.php +++ b/src/Elasticsearch/Tests/Serializer/ItemNormalizerTest.php @@ -90,7 +90,7 @@ public function testSetSerializer(): void public function testDenormalizeWithDecoratedNormalizerNotAnInstanceOfDenormalizerInterface(): void { $this->expectException(LogicException::class); - $this->expectExceptionMessage(sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); + $this->expectExceptionMessage(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); (new ItemNormalizer($this->prophesize(NormalizerInterface::class)->reveal()))->denormalize('foo', 'string'); } @@ -98,7 +98,7 @@ public function testDenormalizeWithDecoratedNormalizerNotAnInstanceOfDenormalize public function testSupportsDenormalizationWithDecoratedNormalizerNotAnInstanceOfDenormalizerInterface(): void { $this->expectException(LogicException::class); - $this->expectExceptionMessage(sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); + $this->expectExceptionMessage(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class)); (new ItemNormalizer($this->prophesize(NormalizerInterface::class)->reveal()))->supportsDenormalization('foo', 'string'); } @@ -106,7 +106,7 @@ public function testSupportsDenormalizationWithDecoratedNormalizerNotAnInstanceO public function testSetSerializerWithDecoratedNormalizerNotAnInstanceOfSerializerAwareInterface(): void { $this->expectException(LogicException::class); - $this->expectExceptionMessage(sprintf('The decorated normalizer must be an instance of "%s".', SerializerAwareInterface::class)); + $this->expectExceptionMessage(\sprintf('The decorated normalizer must be an instance of "%s".', SerializerAwareInterface::class)); (new ItemNormalizer($this->prophesize(NormalizerInterface::class)->reveal()))->setSerializer($this->prophesize(SerializerInterface::class)->reveal()); } @@ -114,7 +114,7 @@ public function testSetSerializerWithDecoratedNormalizerNotAnInstanceOfSerialize public function testGetSupportedTypes(): void { // TODO: use prophecy when getSupportedTypes() will be added to the interface - $this->itemNormalizer = new ItemNormalizer(new class() implements NormalizerInterface { + $this->itemNormalizer = new ItemNormalizer(new class implements NormalizerInterface { public function normalize(mixed $object, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null { return null; diff --git a/src/GraphQl/Serializer/Exception/ValidationExceptionNormalizer.php b/src/GraphQl/Serializer/Exception/ValidationExceptionNormalizer.php index cc1cf8ffdec..df9f096d596 100644 --- a/src/GraphQl/Serializer/Exception/ValidationExceptionNormalizer.php +++ b/src/GraphQl/Serializer/Exception/ValidationExceptionNormalizer.php @@ -39,7 +39,7 @@ public function normalize(mixed $object, ?string $format = null, array $context { $validationException = $object->getPrevious(); if (!$validationException instanceof ConstraintViolationListAwareExceptionInterface) { - throw new RuntimeException(sprintf('Object is not a "%s".', ConstraintViolationListAwareExceptionInterface::class)); + throw new RuntimeException(\sprintf('Object is not a "%s".', ConstraintViolationListAwareExceptionInterface::class)); } $error = FormattedError::createFromException($object); diff --git a/src/GraphQl/State/Processor/NormalizeProcessor.php b/src/GraphQl/State/Processor/NormalizeProcessor.php index c0baf855382..825e562d392 100644 --- a/src/GraphQl/State/Processor/NormalizeProcessor.php +++ b/src/GraphQl/State/Processor/NormalizeProcessor.php @@ -127,7 +127,7 @@ private function serializeCursorBasedPaginatedCollection(iterable $collection, a $args = $context['args']; if (!($collection instanceof PartialPaginatorInterface)) { - throw new \LogicException(sprintf('Collection returned by the collection data provider must implement %s or %s.', PaginatorInterface::class, PartialPaginatorInterface::class)); + throw new \LogicException(\sprintf('Collection returned by the collection data provider must implement %s or %s.', PaginatorInterface::class, PartialPaginatorInterface::class)); } $selection = $context['info']->getFieldSelection(1); @@ -140,7 +140,7 @@ private function serializeCursorBasedPaginatedCollection(iterable $collection, a if (isset($args['after'])) { $after = base64_decode($args['after'], true); if (false === $after || '' === $args['after']) { - throw new \UnexpectedValueException('' === $args['after'] ? 'Empty cursor is invalid' : sprintf('Cursor %s is invalid', $args['after'])); + throw new \UnexpectedValueException('' === $args['after'] ? 'Empty cursor is invalid' : \sprintf('Cursor %s is invalid', $args['after'])); } $offset = 1 + (int) $after; } @@ -150,7 +150,7 @@ private function serializeCursorBasedPaginatedCollection(iterable $collection, a if (isset($args['before'])) { $before = base64_decode($args['before'], true); if (false === $before || '' === $args['before']) { - throw new \UnexpectedValueException('' === $args['before'] ? 'Empty cursor is invalid' : sprintf('Cursor %s is invalid', $args['before'])); + throw new \UnexpectedValueException('' === $args['before'] ? 'Empty cursor is invalid' : \sprintf('Cursor %s is invalid', $args['before'])); } $offset = (int) $before - $nbPageItems; } @@ -203,25 +203,25 @@ private function serializePageBasedPaginatedCollection(iterable $collection, arr $data['paginationInfo'] = []; if (isset($selection['paginationInfo']['itemsPerPage'])) { if (!($collection instanceof PartialPaginatorInterface)) { - throw new \LogicException(sprintf('Collection returned by the collection data provider must implement %s to return itemsPerPage field.', PartialPaginatorInterface::class)); + throw new \LogicException(\sprintf('Collection returned by the collection data provider must implement %s to return itemsPerPage field.', PartialPaginatorInterface::class)); } $data['paginationInfo']['itemsPerPage'] = $collection->getItemsPerPage(); } if (isset($selection['paginationInfo']['totalCount'])) { if (!($collection instanceof PaginatorInterface)) { - throw new \LogicException(sprintf('Collection returned by the collection data provider must implement %s to return totalCount field.', PaginatorInterface::class)); + throw new \LogicException(\sprintf('Collection returned by the collection data provider must implement %s to return totalCount field.', PaginatorInterface::class)); } $data['paginationInfo']['totalCount'] = $collection->getTotalItems(); } if (isset($selection['paginationInfo']['lastPage'])) { if (!($collection instanceof PaginatorInterface)) { - throw new \LogicException(sprintf('Collection returned by the collection data provider must implement %s to return lastPage field.', PaginatorInterface::class)); + throw new \LogicException(\sprintf('Collection returned by the collection data provider must implement %s to return lastPage field.', PaginatorInterface::class)); } $data['paginationInfo']['lastPage'] = $collection->getLastPage(); } if (isset($selection['paginationInfo']['hasNextPage'])) { if (!($collection instanceof HasNextPagePaginatorInterface)) { - throw new \LogicException(sprintf('Collection returned by the collection data provider must implement %s to return hasNextPage field.', HasNextPagePaginatorInterface::class)); + throw new \LogicException(\sprintf('Collection returned by the collection data provider must implement %s to return hasNextPage field.', HasNextPagePaginatorInterface::class)); } $data['paginationInfo']['hasNextPage'] = $collection->hasNextPage(); } diff --git a/src/GraphQl/State/Provider/ReadProvider.php b/src/GraphQl/State/Provider/ReadProvider.php index bd67782037e..58c32f08097 100644 --- a/src/GraphQl/State/Provider/ReadProvider.php +++ b/src/GraphQl/State/Provider/ReadProvider.php @@ -70,11 +70,11 @@ public function provide(Operation $operation, array $uriVariables = [], array $c if ($operation instanceof Subscription || $operation instanceof Mutation) { if (null === $item) { - throw new NotFoundHttpException(sprintf('Item "%s" not found.', $args['input']['id'])); + throw new NotFoundHttpException(\sprintf('Item "%s" not found.', $args['input']['id'])); } if ($operation->getClass() !== $this->getObjectClass($item)) { - throw new \UnexpectedValueException(sprintf('Item "%s" did not match expected type "%s".', $args['input']['id'], $operation->getShortName())); + throw new \UnexpectedValueException(\sprintf('Item "%s" did not match expected type "%s".', $args['input']['id'], $operation->getShortName())); } } diff --git a/src/GraphQl/State/Provider/ResolverProvider.php b/src/GraphQl/State/Provider/ResolverProvider.php index 1b6f1fe77f3..5d51f5c8d50 100644 --- a/src/GraphQl/State/Provider/ResolverProvider.php +++ b/src/GraphQl/State/Provider/ResolverProvider.php @@ -44,7 +44,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c $item = $queryResolver($item, $context); if (!$operation instanceof CollectionOperationInterface) { // The item retrieved can be of another type when using an identifier (see Relay Nodes at query.feature:23) - $this->getResourceClass($item, $operation->getOutput()['class'] ?? $operation->getClass(), sprintf('Custom query resolver "%s"', $queryResolverId).' has to return an item of class %s but returned an item of class %s.'); + $this->getResourceClass($item, $operation->getOutput()['class'] ?? $operation->getClass(), \sprintf('Custom query resolver "%s"', $queryResolverId).' has to return an item of class %s but returned an item of class %s.'); } return $item; @@ -70,7 +70,7 @@ private function getResourceClass(?object $item, ?string $resourceClass, string } if ($resourceClass !== $itemClass && !$item instanceof $resourceClass) { - throw new \UnexpectedValueException(sprintf($errorMessage, (new \ReflectionClass($resourceClass))->getShortName(), (new \ReflectionClass($itemClass))->getShortName())); + throw new \UnexpectedValueException(\sprintf($errorMessage, (new \ReflectionClass($resourceClass))->getShortName(), (new \ReflectionClass($itemClass))->getShortName())); } return $resourceClass; diff --git a/src/GraphQl/Subscription/MercureSubscriptionIriGenerator.php b/src/GraphQl/Subscription/MercureSubscriptionIriGenerator.php index f7e3434f023..0069a4a9cc7 100644 --- a/src/GraphQl/Subscription/MercureSubscriptionIriGenerator.php +++ b/src/GraphQl/Subscription/MercureSubscriptionIriGenerator.php @@ -41,6 +41,6 @@ public function generateTopicIri(string $subscriptionId): string public function generateMercureUrl(string $subscriptionId, ?string $hub = null): string { - return sprintf('%s?topic=%s', $this->registry->getHub($hub)->getUrl(), $this->generateTopicIri($subscriptionId)); + return \sprintf('%s?topic=%s', $this->registry->getHub($hub)->getUrl(), $this->generateTopicIri($subscriptionId)); } } diff --git a/src/GraphQl/Tests/Fixtures/Type/Definition/DateTimeType.php b/src/GraphQl/Tests/Fixtures/Type/Definition/DateTimeType.php index 2b6484b3e77..c1767eae639 100644 --- a/src/GraphQl/Tests/Fixtures/Type/Definition/DateTimeType.php +++ b/src/GraphQl/Tests/Fixtures/Type/Definition/DateTimeType.php @@ -52,7 +52,7 @@ public function serialize($value): string } if (!($value instanceof \DateTime)) { - throw new Error(sprintf('Value must be an instance of DateTime to be represented by DateTime: %s', Utils::printSafe($value))); + throw new Error(\sprintf('Value must be an instance of DateTime to be represented by DateTime: %s', Utils::printSafe($value))); } return $value->format(\DateTime::ATOM); @@ -64,11 +64,11 @@ public function serialize($value): string public function parseValue($value): string { if (!\is_string($value)) { - throw new Error(sprintf('DateTime cannot represent non string value: %s', Utils::printSafeJson($value))); + throw new Error(\sprintf('DateTime cannot represent non string value: %s', Utils::printSafeJson($value))); } if (false === \DateTime::createFromFormat(\DateTime::ATOM, $value)) { - throw new Error(sprintf('DateTime cannot represent non date value: %s', Utils::printSafeJson($value))); + throw new Error(\sprintf('DateTime cannot represent non date value: %s', Utils::printSafeJson($value))); } // Will be denormalized into a \DateTime. diff --git a/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php b/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php index 54b87fa8138..64b0645750e 100644 --- a/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php +++ b/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php @@ -23,7 +23,7 @@ class IdentifierTraitTest extends TestCase { private function getIdentifierTraitImplementation() { - return new class() { + return new class { use IdentifierTrait { IdentifierTrait::getIdentifierFromContext as public; } diff --git a/src/GraphQl/Tests/Util/ArrayTraitTest.php b/src/GraphQl/Tests/Util/ArrayTraitTest.php index e8ec0a29690..d4b28c96da0 100644 --- a/src/GraphQl/Tests/Util/ArrayTraitTest.php +++ b/src/GraphQl/Tests/Util/ArrayTraitTest.php @@ -22,7 +22,7 @@ class ArrayTraitTest extends TestCase protected function setUp(): void { - $this->arrayTraitClass = (new class() { + $this->arrayTraitClass = (new class { use ArrayTrait; }); } diff --git a/src/GraphQl/Type/Definition/IterableType.php b/src/GraphQl/Type/Definition/IterableType.php index 26c08c0d694..c6e6f81e63a 100644 --- a/src/GraphQl/Type/Definition/IterableType.php +++ b/src/GraphQl/Type/Definition/IterableType.php @@ -52,7 +52,7 @@ public function getName(): string public function serialize(mixed $value): iterable { if (!is_iterable($value)) { - throw new Error(sprintf('`Iterable` cannot represent non iterable value: %s', Utils::printSafe($value))); + throw new Error(\sprintf('`Iterable` cannot represent non iterable value: %s', Utils::printSafe($value))); } return $value; @@ -64,7 +64,7 @@ public function serialize(mixed $value): iterable public function parseValue(mixed $value): iterable { if (!is_iterable($value)) { - throw new Error(sprintf('`Iterable` cannot represent non iterable value: %s', Utils::printSafeJson($value))); + throw new Error(\sprintf('`Iterable` cannot represent non iterable value: %s', Utils::printSafeJson($value))); } return $value; diff --git a/src/GraphQl/Type/Definition/UploadType.php b/src/GraphQl/Type/Definition/UploadType.php index 766a6d66645..e58cdf5ca78 100644 --- a/src/GraphQl/Type/Definition/UploadType.php +++ b/src/GraphQl/Type/Definition/UploadType.php @@ -53,7 +53,7 @@ public function serialize(mixed $value): void public function parseValue(mixed $value): UploadedFile { if (!$value instanceof UploadedFile) { - throw new Error(sprintf('Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: %s', Utils::printSafe($value))); + throw new Error(\sprintf('Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: %s', Utils::printSafe($value))); } return $value; diff --git a/src/GraphQl/Type/FieldsBuilder.php b/src/GraphQl/Type/FieldsBuilder.php index cb825944365..35b6c5148ea 100644 --- a/src/GraphQl/Type/FieldsBuilder.php +++ b/src/GraphQl/Type/FieldsBuilder.php @@ -139,7 +139,7 @@ public function getSubscriptionFields(string $resourceClass, Operation $operatio { $subscriptionFields = []; $resourceType = new Type(Type::BUILTIN_TYPE_OBJECT, true, $resourceClass); - $description = $operation->getDescription() ?? sprintf('Subscribes to the action event of a %s.', $operation->getShortName()); + $description = $operation->getDescription() ?? \sprintf('Subscribes to the action event of a %s.', $operation->getShortName()); if ($fieldConfiguration = $this->getResourceFieldConfiguration(null, $description, $operation->getDeprecationReason(), $resourceType, $resourceClass, false, $operation)) { $fieldConfiguration['args'] += ['input' => $this->getResourceFieldConfiguration(null, null, $operation->getDeprecationReason(), $resourceType, $resourceClass, true, $operation)]; @@ -280,7 +280,7 @@ public function resolveResourceArgs(array $args, Operation $operation): array { foreach ($args as $id => $arg) { if (!isset($arg['type'])) { - throw new \InvalidArgumentException(sprintf('The argument "%s" of the custom operation "%s" in %s needs a "type" option.', $id, $operation->getName(), $operation->getShortName())); + throw new \InvalidArgumentException(\sprintf('The argument "%s" of the custom operation "%s" in %s needs a "type" option.', $id, $operation->getName(), $operation->getShortName())); } $args[$id]['type'] = $this->typeConverter->resolveType($arg['type']); @@ -644,12 +644,12 @@ private function convertType(Type $type, bool $input, Operation $resourceOperati $graphqlType = $this->typeConverter->convertType($type, $input, $rootOperation, $resourceClass, $rootResource, $property, $depth); if (null === $graphqlType) { - throw new InvalidTypeException(sprintf('The type "%s" is not supported.', $type->getBuiltinType())); + throw new InvalidTypeException(\sprintf('The type "%s" is not supported.', $type->getBuiltinType())); } if (\is_string($graphqlType)) { if (!$this->typesContainer->has($graphqlType)) { - throw new InvalidTypeException(sprintf('The GraphQL type %s is not valid. Valid types are: %s. Have you registered this type by implementing %s?', $graphqlType, implode(', ', array_keys($this->typesContainer->all())), TypeInterface::class)); + throw new InvalidTypeException(\sprintf('The GraphQL type %s is not valid. Valid types are: %s. Have you registered this type by implementing %s?', $graphqlType, implode(', ', array_keys($this->typesContainer->all())), TypeInterface::class)); } $graphqlType = $this->typesContainer->get($graphqlType); diff --git a/src/GraphQl/Type/SchemaBuilder.php b/src/GraphQl/Type/SchemaBuilder.php index b253735ca41..dd91a2e3c9e 100644 --- a/src/GraphQl/Type/SchemaBuilder.php +++ b/src/GraphQl/Type/SchemaBuilder.php @@ -35,7 +35,7 @@ final class SchemaBuilder implements SchemaBuilderInterface public function __construct(private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, private readonly TypesFactoryInterface $typesFactory, private readonly TypesContainerInterface $typesContainer, private readonly FieldsBuilderEnumInterface|FieldsBuilderInterface $fieldsBuilder) { if ($this->fieldsBuilder instanceof FieldsBuilderInterface) { - @trigger_error(sprintf('$fieldsBuilder argument of SchemaBuilder implementing "%s" is deprecated since API Platform 3.1. It has to implement "%s" instead.', FieldsBuilderInterface::class, FieldsBuilderEnumInterface::class), \E_USER_DEPRECATED); + @trigger_error(\sprintf('$fieldsBuilder argument of SchemaBuilder implementing "%s" is deprecated since API Platform 3.1. It has to implement "%s" instead.', FieldsBuilderInterface::class, FieldsBuilderEnumInterface::class), \E_USER_DEPRECATED); } } diff --git a/src/GraphQl/Type/TypeBuilder.php b/src/GraphQl/Type/TypeBuilder.php index b9136d71fed..b900e97622f 100644 --- a/src/GraphQl/Type/TypeBuilder.php +++ b/src/GraphQl/Type/TypeBuilder.php @@ -96,7 +96,7 @@ public function getResourceObjectType(ResourceMetadataCollection $resourceMetada $resourceObjectType = $resourceObjectType ?? $this->typesContainer->get($shortName); if (!($resourceObjectType instanceof ObjectType || $resourceObjectType instanceof NonNull || $resourceObjectType instanceof InputObjectType)) { - throw new \LogicException(sprintf('Expected GraphQL type "%s" to be %s.', $shortName, implode('|', [ObjectType::class, NonNull::class, InputObjectType::class]))); + throw new \LogicException(\sprintf('Expected GraphQL type "%s" to be %s.', $shortName, implode('|', [ObjectType::class, NonNull::class, InputObjectType::class]))); } $required = $propertyMetadata?->isRequired() ?? true; @@ -115,7 +115,7 @@ public function getNodeInterface(): InterfaceType if ($this->typesContainer->has('Node')) { $nodeInterface = $this->typesContainer->get('Node'); if (!$nodeInterface instanceof InterfaceType) { - throw new \LogicException(sprintf('Expected GraphQL type "Node" to be %s.', InterfaceType::class)); + throw new \LogicException(\sprintf('Expected GraphQL type "Node" to be %s.', InterfaceType::class)); } return $nodeInterface; @@ -166,7 +166,7 @@ public function getPaginatedCollectionType(GraphQLType $resourceType, Operation $shortName = method_exists($namedType, 'name') ? $namedType->name() : $namedType->name; $paginationType = $this->pagination->getGraphQlPaginationType($operation); - $connectionTypeKey = sprintf('%s%sConnection', $shortName, ucfirst($paginationType)); + $connectionTypeKey = \sprintf('%s%sConnection', $shortName, ucfirst($paginationType)); if ($this->typesContainer->has($connectionTypeKey)) { return $this->typesContainer->get($connectionTypeKey); } @@ -177,7 +177,7 @@ public function getPaginatedCollectionType(GraphQLType $resourceType, Operation $configuration = [ 'name' => $connectionTypeKey, - 'description' => sprintf("%s connection for $shortName.", ucfirst($paginationType)), + 'description' => \sprintf("%s connection for $shortName.", ucfirst($paginationType)), 'fields' => $fields, ]; @@ -202,7 +202,7 @@ public function getEnumType(Operation $operation): GraphQLType if ($fieldsBuilder instanceof FieldsBuilderEnumInterface) { $enumCases = $fieldsBuilder->getEnumFields($operation->getClass()); } else { - @trigger_error(sprintf('api_platform.graphql.fields_builder service implementing "%s" is deprecated since API Platform 3.1. It has to implement "%s" instead.', FieldsBuilderInterface::class, FieldsBuilderEnumInterface::class), \E_USER_DEPRECATED); + @trigger_error(\sprintf('api_platform.graphql.fields_builder service implementing "%s" is deprecated since API Platform 3.1. It has to implement "%s" instead.', FieldsBuilderInterface::class, FieldsBuilderEnumInterface::class), \E_USER_DEPRECATED); } $enumConfig = [ diff --git a/src/GraphQl/Type/TypeConverter.php b/src/GraphQl/Type/TypeConverter.php index e5224fd8895..fa9430f5c77 100644 --- a/src/GraphQl/Type/TypeConverter.php +++ b/src/GraphQl/Type/TypeConverter.php @@ -81,14 +81,14 @@ public function resolveType(string $type): ?GraphQLType try { $astTypeNode = Parser::parseType($type); } catch (SyntaxError $e) { - throw new InvalidArgumentException(sprintf('"%s" is not a valid GraphQL type.', $type), 0, $e); + throw new InvalidArgumentException(\sprintf('"%s" is not a valid GraphQL type.', $type), 0, $e); } if ($graphQlType = $this->resolveAstTypeNode($astTypeNode, $type)) { return $graphQlType; } - throw new InvalidArgumentException(sprintf('The type "%s" was not resolved.', $type)); + throw new InvalidArgumentException(\sprintf('The type "%s" was not resolved.', $type)); } private function getResourceType(Type $type, bool $input, Operation $rootOperation, string $rootResource, ?string $property, int $depth): ?GraphQLType diff --git a/src/GraphQl/Type/TypesContainer.php b/src/GraphQl/Type/TypesContainer.php index 1a39cee73eb..286f06e727f 100644 --- a/src/GraphQl/Type/TypesContainer.php +++ b/src/GraphQl/Type/TypesContainer.php @@ -41,7 +41,7 @@ public function get(string $id): GraphQLType return $this->graphqlTypes[$id]; } - throw new TypeNotFoundException(sprintf('Type with id "%s" is not present in the types container', $id), $id); + throw new TypeNotFoundException(\sprintf('Type with id "%s" is not present in the types container', $id), $id); } /** diff --git a/src/Hal/Serializer/ItemNormalizer.php b/src/Hal/Serializer/ItemNormalizer.php index 2219ba8a390..f128e150909 100644 --- a/src/Hal/Serializer/ItemNormalizer.php +++ b/src/Hal/Serializer/ItemNormalizer.php @@ -113,7 +113,7 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form */ public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): never { - throw new LogicException(sprintf('%s is a read-only format.', self::FORMAT)); + throw new LogicException(\sprintf('%s is a read-only format.', self::FORMAT)); } /** @@ -304,7 +304,7 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str return false; } - $key = sprintf(self::DEPTH_KEY_PATTERN, $class, $attribute); + $key = \sprintf(self::DEPTH_KEY_PATTERN, $class, $attribute); if (!isset($context[$key])) { $context[$key] = 1; diff --git a/src/Hal/Serializer/ObjectNormalizer.php b/src/Hal/Serializer/ObjectNormalizer.php index e632d5fe224..ea3d7a895b8 100644 --- a/src/Hal/Serializer/ObjectNormalizer.php +++ b/src/Hal/Serializer/ObjectNormalizer.php @@ -90,6 +90,6 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form */ public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed { - throw new LogicException(sprintf('%s is a read-only format.', self::FORMAT)); + throw new LogicException(\sprintf('%s is a read-only format.', self::FORMAT)); } } diff --git a/src/HttpCache/SurrogateKeysPurger.php b/src/HttpCache/SurrogateKeysPurger.php index 0206dea9ace..0890d5e4e0f 100644 --- a/src/HttpCache/SurrogateKeysPurger.php +++ b/src/HttpCache/SurrogateKeysPurger.php @@ -46,7 +46,7 @@ private function getChunkedIris(array $iris): \Iterator $chunk = array_shift($iris); foreach ($iris as $iri) { - $nextChunk = sprintf('%s%s%s', $chunk, $this->separator, $iri); + $nextChunk = \sprintf('%s%s%s', $chunk, $this->separator, $iri); if (\strlen($nextChunk) <= $this->maxHeaderLength) { $chunk = $nextChunk; continue; @@ -66,7 +66,7 @@ public function purge(array $iris): void { foreach ($this->getChunkedIris($iris) as $chunk) { if (\strlen((string) $chunk) > $this->maxHeaderLength) { - throw new RuntimeException(sprintf('IRI "%s" is too long to fit current max header length (currently set to "%s"). You can increase it using the "api_platform.http_cache.invalidation.max_header_length" parameter.', $chunk, $this->maxHeaderLength)); + throw new RuntimeException(\sprintf('IRI "%s" is too long to fit current max header length (currently set to "%s"). You can increase it using the "api_platform.http_cache.invalidation.max_header_length" parameter.', $chunk, $this->maxHeaderLength)); } foreach ($this->clients as $client) { diff --git a/src/HttpCache/Tests/SouinPurgerTest.php b/src/HttpCache/Tests/SouinPurgerTest.php index ac66be6f63b..1a07617d9da 100644 --- a/src/HttpCache/Tests/SouinPurgerTest.php +++ b/src/HttpCache/Tests/SouinPurgerTest.php @@ -51,7 +51,7 @@ private function generateXResourcesTags(int $number, int $minimum = 0): array $stack = []; for ($i = $minimum; $i < $number; ++$i) { - $stack[] = sprintf('/tags/%d', $i); + $stack[] = \sprintf('/tags/%d', $i); } return $stack; @@ -60,7 +60,7 @@ private function generateXResourcesTags(int $number, int $minimum = 0): array public function testMultiChunkedTags(): void { /** @var HttpClientInterface $client */ - $client = new class() implements ClientInterface { + $client = new class implements ClientInterface { public array $sentRegexes = []; public function send(RequestInterface $request, array $options = []): ResponseInterface @@ -102,7 +102,7 @@ public function getConfig($option = null): void public function testPurgeWithMultipleClients(): void { /** @var HttpClientInterface $client1 */ - $client1 = new class() implements ClientInterface { + $client1 = new class implements ClientInterface { public $requests = []; public function send(RequestInterface $request, array $options = []): ResponseInterface @@ -133,7 +133,7 @@ public function getConfig($option = null): void } }; /** @var HttpClientInterface $client2 */ - $client2 = new class() implements ClientInterface { + $client2 = new class implements ClientInterface { public $requests = []; public function send(RequestInterface $request, array $options = []): ResponseInterface diff --git a/src/HttpCache/Tests/VarnishPurgerTest.php b/src/HttpCache/Tests/VarnishPurgerTest.php index 65c336e857c..0cfb5883458 100644 --- a/src/HttpCache/Tests/VarnishPurgerTest.php +++ b/src/HttpCache/Tests/VarnishPurgerTest.php @@ -72,7 +72,7 @@ public function testEmptyTags(): void public function testItChunksHeaderToAvoidHittingVarnishLimit(int $maxHeaderLength, array $iris, array $regexesToSend): void { /** @var HttpClientInterface $client */ - $client = new class() implements ClientInterface { + $client = new class implements ClientInterface { public array $sentRegexes = []; public function send(RequestInterface $request, array $options = []): ResponseInterface @@ -169,8 +169,8 @@ public static function provideChunkHeaderCases(): \Generator 8000, array_fill(0, 3000, '/foo'), [ - sprintf('(%s)($|\,)', implode('|', array_fill(0, 1598, '/foo'))), - sprintf('(%s)($|\,)', implode('|', array_fill(0, 1402, '/foo'))), + \sprintf('(%s)($|\,)', implode('|', array_fill(0, 1598, '/foo'))), + \sprintf('(%s)($|\,)', implode('|', array_fill(0, 1402, '/foo'))), ], ]; } diff --git a/src/HttpCache/Tests/VarnishXKeyPurgerTest.php b/src/HttpCache/Tests/VarnishXKeyPurgerTest.php index 0e029f185e6..b73dc0e7458 100644 --- a/src/HttpCache/Tests/VarnishXKeyPurgerTest.php +++ b/src/HttpCache/Tests/VarnishXKeyPurgerTest.php @@ -102,7 +102,7 @@ public function testCustomGlue(): void public function testItChunksHeaderToAvoidHittingVarnishLimit(int $maxHeaderLength, array $iris, array $keysToSend): void { /** @var HttpClientInterface $client */ - $client = new class() implements ClientInterface { + $client = new class implements ClientInterface { public array $sentKeys = []; public function send(RequestInterface $request, array $options = []): ResponseInterface diff --git a/src/HttpCache/VarnishPurger.php b/src/HttpCache/VarnishPurger.php index 6b4ddc2059e..a0a680ba49e 100644 --- a/src/HttpCache/VarnishPurger.php +++ b/src/HttpCache/VarnishPurger.php @@ -93,7 +93,7 @@ private function purgeRequest(array $iris): void preg_quote($iri), $iris); foreach ($this->chunkRegexParts($parts) as $regex) { - $regex = sprintf(self::REGEXP_PATTERN, $regex); + $regex = \sprintf(self::REGEXP_PATTERN, $regex); $this->banRegex($regex); } } diff --git a/src/Hydra/Serializer/CollectionFiltersNormalizer.php b/src/Hydra/Serializer/CollectionFiltersNormalizer.php index b030d688f6f..9ea2afd78a5 100644 --- a/src/Hydra/Serializer/CollectionFiltersNormalizer.php +++ b/src/Hydra/Serializer/CollectionFiltersNormalizer.php @@ -177,7 +177,7 @@ private function getSearch(string $resourceClass, array $parts, array $filters, $mapping[] = $m; } - return ['@type' => 'hydra:IriTemplate', 'hydra:template' => sprintf('%s{?%s}', $parts['path'], implode(',', $variables)), 'hydra:variableRepresentation' => 'BasicRepresentation', 'hydra:mapping' => $mapping]; + return ['@type' => 'hydra:IriTemplate', 'hydra:template' => \sprintf('%s{?%s}', $parts['path'], implode(',', $variables)), 'hydra:variableRepresentation' => 'BasicRepresentation', 'hydra:mapping' => $mapping]; } /** diff --git a/src/Hydra/Serializer/CollectionNormalizer.php b/src/Hydra/Serializer/CollectionNormalizer.php index 3e92c85aed4..6a278472614 100644 --- a/src/Hydra/Serializer/CollectionNormalizer.php +++ b/src/Hydra/Serializer/CollectionNormalizer.php @@ -44,7 +44,7 @@ public function __construct(private readonly ContextBuilderInterface $contextBui $this->defaultContext = array_merge($this->defaultContext, $defaultContext); if ($resourceMetadataCollectionFactory) { - trigger_deprecation('api-platform/core', '3.0', sprintf('Injecting "%s" within "%s" is not needed anymore and this dependency will be removed in 4.0.', ResourceMetadataCollectionFactoryInterface::class, self::class)); + trigger_deprecation('api-platform/core', '3.0', \sprintf('Injecting "%s" within "%s" is not needed anymore and this dependency will be removed in 4.0.', ResourceMetadataCollectionFactoryInterface::class, self::class)); } parent::__construct($resourceClassResolver, ''); diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index 8fc1e50e6e7..19696043316 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -84,7 +84,7 @@ private function populateEntrypointProperties(ApiResource $resourceMetadata, str $entrypointProperty = [ '@type' => 'hydra:SupportedProperty', 'hydra:property' => [ - '@id' => sprintf('#Entrypoint/%s', lcfirst($shortName)), + '@id' => \sprintf('#Entrypoint/%s', lcfirst($shortName)), '@type' => 'hydra:Link', 'domain' => '#Entrypoint', 'rdfs:label' => "The collection of $shortName resources", diff --git a/src/Hydra/Tests/Serializer/CollectionFiltersNormalizerTest.php b/src/Hydra/Tests/Serializer/CollectionFiltersNormalizerTest.php index b8711134984..6943b8db13c 100644 --- a/src/Hydra/Tests/Serializer/CollectionFiltersNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/CollectionFiltersNormalizerTest.php @@ -331,7 +331,7 @@ public function testGetSupportedTypes(): void // TODO: use prophecy when getSupportedTypes() will be added to the interface $normalizer = new CollectionFiltersNormalizer( - new class() implements NormalizerInterface { + new class implements NormalizerInterface { public function normalize(mixed $object, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null { return null; diff --git a/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php b/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php index 0d02ec146e1..3f45a4287f2 100644 --- a/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php @@ -189,7 +189,7 @@ public function testGetSupportedTypes(): void } // TODO: use prophecy when getSupportedTypes() will be added to the interface - $normalizer = new PartialCollectionViewNormalizer(new class() implements NormalizerInterface { + $normalizer = new PartialCollectionViewNormalizer(new class implements NormalizerInterface { public function normalize(mixed $object, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null { return null; diff --git a/src/JsonApi/Serializer/ItemNormalizer.php b/src/JsonApi/Serializer/ItemNormalizer.php index 6b5fba82c4c..d1e5ba7de16 100644 --- a/src/JsonApi/Serializer/ItemNormalizer.php +++ b/src/JsonApi/Serializer/ItemNormalizer.php @@ -254,7 +254,7 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel if (null === $relatedObject || isset($context['api_included'])) { if (!$this->serializer instanceof NormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); } $normalizedRelatedObject = $this->serializer->normalize($relatedObject, $format, $context); @@ -420,7 +420,7 @@ private function getPopulatedRelations(object $object, ?string $format, array $c // Many to many relationship foreach ($attributeValue as $attributeValueElement) { if (!isset($attributeValueElement['data'])) { - throw new UnexpectedValueException(sprintf('The JSON API attribute \'%s\' must contain a "data" key.', $relationshipName)); + throw new UnexpectedValueException(\sprintf('The JSON API attribute \'%s\' must contain a "data" key.', $relationshipName)); } unset($attributeValueElement['data']['attributes']); $data[$relationshipName]['data'][] = $attributeValueElement['data']; diff --git a/src/JsonLd/ContextBuilder.php b/src/JsonLd/ContextBuilder.php index 67673dbbb4e..c3eb26e70b6 100644 --- a/src/JsonLd/ContextBuilder.php +++ b/src/JsonLd/ContextBuilder.php @@ -160,7 +160,7 @@ private function getResourceContextWithShortname(string $resourceClass, int $ref } if (!$id) { - $id = sprintf('%s/%s', $shortName, $convertedName); + $id = \sprintf('%s/%s', $shortName, $convertedName); } if (false === $propertyMetadata->isReadableLink()) { diff --git a/src/JsonSchema/Command/JsonSchemaGenerateCommand.php b/src/JsonSchema/Command/JsonSchemaGenerateCommand.php index 708c83d5fcb..835f7de6cfd 100644 --- a/src/JsonSchema/Command/JsonSchemaGenerateCommand.php +++ b/src/JsonSchema/Command/JsonSchemaGenerateCommand.php @@ -51,7 +51,7 @@ protected function configure(): void ->addArgument('resource', InputArgument::REQUIRED, 'The Fully Qualified Class Name (FQCN) of the resource') ->addOption('operation', null, InputOption::VALUE_REQUIRED, 'The operation name') ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The response format', (string) $this->formats[0]) - ->addOption('type', null, InputOption::VALUE_REQUIRED, sprintf('The type of schema to generate (%s or %s)', Schema::TYPE_INPUT, Schema::TYPE_OUTPUT), Schema::TYPE_INPUT); + ->addOption('type', null, InputOption::VALUE_REQUIRED, \sprintf('The type of schema to generate (%s or %s)', Schema::TYPE_INPUT, Schema::TYPE_OUTPUT), Schema::TYPE_INPUT); } /** @@ -70,19 +70,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $type = $input->getOption('type'); if (!\in_array($type, [Schema::TYPE_INPUT, Schema::TYPE_OUTPUT], true)) { - $io->error(sprintf('You can only use "%s" or "%s" for the "type" option', Schema::TYPE_INPUT, Schema::TYPE_OUTPUT)); + $io->error(\sprintf('You can only use "%s" or "%s" for the "type" option', Schema::TYPE_INPUT, Schema::TYPE_OUTPUT)); return 1; } if (!\in_array($format, $this->formats, true)) { - throw new InvalidOptionException(sprintf('The response format "%s" is not supported. Supported formats are : %s.', $format, implode(', ', $this->formats))); + throw new InvalidOptionException(\sprintf('The response format "%s" is not supported. Supported formats are : %s.', $format, implode(', ', $this->formats))); } - $schema = $this->schemaFactory->buildSchema($resource, $format, $type, $operation ? (new class() extends HttpOperation {})->withName($operation) : null); + $schema = $this->schemaFactory->buildSchema($resource, $format, $type, $operation ? (new class extends HttpOperation {})->withName($operation) : null); if (!$schema->isDefined()) { - $io->error(sprintf('There is no %s defined for the operation "%s" of the resource "%s".', $type, $operation, $resource)); + $io->error(\sprintf('There is no %s defined for the operation "%s" of the resource "%s".', $type, $operation, $resource)); return 1; } diff --git a/src/JsonSchema/DefinitionNameFactory.php b/src/JsonSchema/DefinitionNameFactory.php index 4007e837fa5..86076def71c 100644 --- a/src/JsonSchema/DefinitionNameFactory.php +++ b/src/JsonSchema/DefinitionNameFactory.php @@ -48,10 +48,10 @@ public function create(string $className, string $format = 'json', ?string $inpu $definitionName = $serializerContext[SchemaFactory::OPENAPI_DEFINITION_NAME] ?? null; if ($definitionName) { - $name = sprintf('%s-%s', $prefix, $definitionName); + $name = \sprintf('%s-%s', $prefix, $definitionName); } else { $groups = (array) ($serializerContext[AbstractNormalizer::GROUPS] ?? []); - $name = $groups ? sprintf('%s-%s', $prefix, implode('_', $groups)) : $prefix; + $name = $groups ? \sprintf('%s-%s', $prefix, implode('_', $groups)) : $prefix; } return $this->encodeDefinitionName($name); diff --git a/src/Laravel/Eloquent/State/LinksHandlerLocatorTrait.php b/src/Laravel/Eloquent/State/LinksHandlerLocatorTrait.php index 356e64f69bc..0975cf52e3f 100644 --- a/src/Laravel/Eloquent/State/LinksHandlerLocatorTrait.php +++ b/src/Laravel/Eloquent/State/LinksHandlerLocatorTrait.php @@ -39,6 +39,6 @@ private function getLinksHandler(Operation $operation): ?callable return [$this->handleLinksLocator->get($handleLinks), 'handleLinks']; // @phpstan-ignore-line } - throw new RuntimeException(sprintf('Could not find handleLinks service "%s"', $handleLinks)); + throw new RuntimeException(\sprintf('Could not find handleLinks service "%s"', $handleLinks)); } } diff --git a/src/Laravel/Exception/Handler.php b/src/Laravel/Exception/Handler.php index 6540b3e8654..dda1c7405a7 100644 --- a/src/Laravel/Exception/Handler.php +++ b/src/Laravel/Exception/Handler.php @@ -191,6 +191,6 @@ public static function provide(): mixed return $data; } - throw new \LogicException(sprintf('We could not find the thrown exception in the %s.', self::class)); + throw new \LogicException(\sprintf('We could not find the thrown exception in the %s.', self::class)); } } diff --git a/src/Laravel/Routing/IriConverter.php b/src/Laravel/Routing/IriConverter.php index 5dc89c459b4..d85ff34d1f0 100644 --- a/src/Laravel/Routing/IriConverter.php +++ b/src/Laravel/Routing/IriConverter.php @@ -66,24 +66,24 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation { $parameters = $this->router->match($iri); if (!isset($parameters['_api_resource_class'], $parameters['_api_operation_name'], $parameters['uri_variables'])) { - throw new InvalidArgumentException(sprintf('No resource associated to "%s".', $iri)); + throw new InvalidArgumentException(\sprintf('No resource associated to "%s".', $iri)); } $operation = $parameters['_api_operation'] = $this->resourceMetadataCollectionFactory->create($parameters['_api_resource_class'])->getOperation($parameters['_api_operation_name']); if ($operation instanceof CollectionOperationInterface) { - throw new InvalidArgumentException(sprintf('The iri "%s" references a collection not an item.', $iri)); + throw new InvalidArgumentException(\sprintf('The iri "%s" references a collection not an item.', $iri)); } if (!$operation instanceof HttpOperation) { - throw new RuntimeException(sprintf('The iri "%s" does not reference an HTTP operation.', $iri)); + throw new RuntimeException(\sprintf('The iri "%s" does not reference an HTTP operation.', $iri)); } if ($item = $this->provider->provide($operation, $parameters['uri_variables'], $context)) { return $item; // @phpstan-ignore-line } - throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri)); + throw new ItemNotFoundException(\sprintf('Item not found for "%s".', $iri)); } /** @@ -160,7 +160,7 @@ private function generateRoute(object|string $resource, int $referenceType = Url } catch (InvalidArgumentException|RuntimeException $e) { // We can try using context uri variables if any if (!$identifiers) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); } } } @@ -168,7 +168,7 @@ private function generateRoute(object|string $resource, int $referenceType = Url try { return $this->router->generate($operation->getName(), $identifiers, $operation->getUrlGenerationStrategy() ?? $referenceType); } catch (RoutingExceptionInterface $e) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); } } @@ -179,7 +179,7 @@ private function generateRoute(object|string $resource, int $referenceType = Url private function generateSkolemIri(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = [], ?string $resourceClass = null): string { if (!$this->decorated) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass)); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass)); } // Use a skolem iri, the route is defined in genid.xml diff --git a/src/Laravel/Routing/SkolemIriConverter.php b/src/Laravel/Routing/SkolemIriConverter.php index d25fc2ca006..dc0506be859 100644 --- a/src/Laravel/Routing/SkolemIriConverter.php +++ b/src/Laravel/Routing/SkolemIriConverter.php @@ -46,7 +46,7 @@ public function __construct(private readonly Router $router) */ public function getResourceFromIri(string $iri, array $context = [], ?Operation $operation = null): object { - throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri)); + throw new ItemNotFoundException(\sprintf('Item not found for "%s".', $iri)); } /** diff --git a/src/Laravel/State/SwaggerUiProcessor.php b/src/Laravel/State/SwaggerUiProcessor.php index f51cdf4597a..e38d4317825 100644 --- a/src/Laravel/State/SwaggerUiProcessor.php +++ b/src/Laravel/State/SwaggerUiProcessor.php @@ -101,6 +101,6 @@ private function getPathAndMethod(array $swaggerData): array } } - throw new RuntimeException(sprintf('The operation "%s" cannot be found in the Swagger specification.', $swaggerData['operationId'])); + throw new RuntimeException(\sprintf('The operation "%s" cannot be found in the Swagger specification.', $swaggerData['operationId'])); } } diff --git a/src/Laravel/workbench/database/migrations/2023_07_15_231244_create_book_table.php b/src/Laravel/workbench/database/migrations/2023_07_15_231244_create_book_table.php index f0bf189ddd9..4cad10e8a26 100644 --- a/src/Laravel/workbench/database/migrations/2023_07_15_231244_create_book_table.php +++ b/src/Laravel/workbench/database/migrations/2023_07_15_231244_create_book_table.php @@ -15,7 +15,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class extends Migration { /** * Run the migrations. */ diff --git a/src/Metadata/ApiFilter.php b/src/Metadata/ApiFilter.php index f9799755f4a..6a96f191b29 100644 --- a/src/Metadata/ApiFilter.php +++ b/src/Metadata/ApiFilter.php @@ -36,7 +36,7 @@ public function __construct( public ?string $alias = null, ) { if (!is_a($this->filterClass, FilterInterface::class, true)) { - throw new InvalidArgumentException(sprintf('The filter class "%s" does not implement "%s". Did you forget a use statement?', $this->filterClass, FilterInterface::class)); + throw new InvalidArgumentException(\sprintf('The filter class "%s" does not implement "%s". Did you forget a use statement?', $this->filterClass, FilterInterface::class)); } } } diff --git a/src/Metadata/Extractor/AbstractPropertyExtractor.php b/src/Metadata/Extractor/AbstractPropertyExtractor.php index 16a19f32f0f..2f011bf64d9 100644 --- a/src/Metadata/Extractor/AbstractPropertyExtractor.php +++ b/src/Metadata/Extractor/AbstractPropertyExtractor.php @@ -96,7 +96,7 @@ protected function resolve(mixed $value): mixed } if (preg_match('/^env\(\w+\)$/', $parameter)) { - throw new \RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $parameter)); + throw new \RuntimeException(\sprintf('Using "%%%s%%" is not allowed in routing configuration.', $parameter)); } if (\array_key_exists($parameter, $this->collectedParameters)) { @@ -115,7 +115,7 @@ protected function resolve(mixed $value): mixed return (string) $resolved; } - throw new \RuntimeException(sprintf('The container parameter "%s", used in the resource configuration value "%s", must be a string or numeric, but it is of type %s.', $parameter, $value, \gettype($resolved))); + throw new \RuntimeException(\sprintf('The container parameter "%s", used in the resource configuration value "%s", must be a string or numeric, but it is of type %s.', $parameter, $value, \gettype($resolved))); }, $value); return str_replace('%%', '%', $escapedValue); diff --git a/src/Metadata/Extractor/AbstractResourceExtractor.php b/src/Metadata/Extractor/AbstractResourceExtractor.php index dde2f331008..d9bd3eac43d 100644 --- a/src/Metadata/Extractor/AbstractResourceExtractor.php +++ b/src/Metadata/Extractor/AbstractResourceExtractor.php @@ -96,7 +96,7 @@ protected function resolve(mixed $value): mixed } if (preg_match('/^env\(\w+\)$/', $parameter)) { - throw new \RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $parameter)); + throw new \RuntimeException(\sprintf('Using "%%%s%%" is not allowed in routing configuration.', $parameter)); } if (\array_key_exists($parameter, $this->collectedParameters)) { @@ -115,7 +115,7 @@ protected function resolve(mixed $value): mixed return (string) $resolved; } - throw new \RuntimeException(sprintf('The container parameter "%s", used in the resource configuration value "%s", must be a string or numeric, but it is of type %s.', $parameter, $value, \gettype($resolved))); + throw new \RuntimeException(\sprintf('The container parameter "%s", used in the resource configuration value "%s", must be a string or numeric, but it is of type %s.', $parameter, $value, \gettype($resolved))); }, $value); return str_replace('%%', '%', $escapedValue); diff --git a/src/Metadata/Extractor/ResourceExtractorTrait.php b/src/Metadata/Extractor/ResourceExtractorTrait.php index dc235448571..55fbde96e77 100644 --- a/src/Metadata/Extractor/ResourceExtractorTrait.php +++ b/src/Metadata/Extractor/ResourceExtractorTrait.php @@ -38,7 +38,7 @@ private function buildArrayValue(\SimpleXMLElement|array|null $resource, string } if (!\is_array($resource[$key])) { - throw new InvalidArgumentException(sprintf('"%s" setting is expected to be an array, %s given', $key, \gettype($resource[$key]))); + throw new InvalidArgumentException(\sprintf('"%s" setting is expected to be an array, %s given', $key, \gettype($resource[$key]))); } return $resource[$key]; @@ -68,7 +68,7 @@ private function phpize(\SimpleXMLElement|array|null $resource, string $key, str return \in_array($resource[$key], ['1', 'true', 1, true], false); } - throw new InvalidArgumentException(sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($resource[$key]))); + throw new InvalidArgumentException(\sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($resource[$key]))); } private function buildArgs(\SimpleXMLElement $resource): ?array diff --git a/src/Metadata/Extractor/XmlResourceExtractor.php b/src/Metadata/Extractor/XmlResourceExtractor.php index 3074188ab2b..c3843d6f550 100644 --- a/src/Metadata/Extractor/XmlResourceExtractor.php +++ b/src/Metadata/Extractor/XmlResourceExtractor.php @@ -51,7 +51,7 @@ protected function extractPath(string $path): void try { simplexml_import_dom(XmlUtils::loadFile($path, XmlPropertyExtractor::SCHEMA)); } catch (\InvalidArgumentException) { - throw new InvalidArgumentException(sprintf('Error while parsing %s: %s', $path, $e->getMessage()), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Error while parsing %s: %s', $path, $e->getMessage()), $e->getCode(), $e); } // It's a property: ignore error @@ -392,7 +392,7 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr if (\in_array((string) $operation['class'], [GetCollection::class, Post::class], true)) { $datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string'); } elseif (isset($operation['itemUriTemplate'])) { - throw new InvalidArgumentException(sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $operation['class'])); + throw new InvalidArgumentException(\sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $operation['class'])); } $data[] = array_merge($datum, [ diff --git a/src/Metadata/Extractor/YamlPropertyExtractor.php b/src/Metadata/Extractor/YamlPropertyExtractor.php index d06c7797e11..70f26becf2a 100644 --- a/src/Metadata/Extractor/YamlPropertyExtractor.php +++ b/src/Metadata/Extractor/YamlPropertyExtractor.php @@ -42,7 +42,7 @@ protected function extractPath(string $path): void } if (!\is_array($propertiesYaml)) { - throw new InvalidArgumentException(sprintf('"properties" setting is expected to be null or an array, %s given in "%s".', \gettype($propertiesYaml), $path)); + throw new InvalidArgumentException(\sprintf('"properties" setting is expected to be null or an array, %s given in "%s".', \gettype($propertiesYaml), $path)); } $this->buildProperties($propertiesYaml); @@ -64,7 +64,7 @@ private function buildProperties(array $resourcesYaml): void } if (!\is_array($propertyValues)) { - throw new InvalidArgumentException(sprintf('"%s" setting is expected to be null or an array, %s given.', $propertyName, \gettype($propertyValues))); + throw new InvalidArgumentException(\sprintf('"%s" setting is expected to be null or an array, %s given.', $propertyName, \gettype($propertyValues))); } $this->properties[$resourceName][$propertyName] = [ @@ -107,7 +107,7 @@ private function buildAttribute(array $resource, string $key, mixed $default = n } if (!\is_array($resource[$key])) { - throw new InvalidArgumentException(sprintf('"%s" setting is expected to be an array, %s given', $key, \gettype($resource[$key]))); + throw new InvalidArgumentException(\sprintf('"%s" setting is expected to be an array, %s given', $key, \gettype($resource[$key]))); } return $resource[$key]; @@ -127,7 +127,7 @@ private function phpize(?array $resource, string $key, string $type, mixed $defa 'string' => (string) $resource[$key], 'integer' => (int) $resource[$key], 'bool' => \in_array($resource[$key], ['1', 'true', 1, true], false), - default => throw new InvalidArgumentException(sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($resource[$key]))), + default => throw new InvalidArgumentException(\sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($resource[$key]))), }; } } diff --git a/src/Metadata/Extractor/YamlResourceExtractor.php b/src/Metadata/Extractor/YamlResourceExtractor.php index 9e156059618..22b8e0fdd32 100644 --- a/src/Metadata/Extractor/YamlResourceExtractor.php +++ b/src/Metadata/Extractor/YamlResourceExtractor.php @@ -58,7 +58,7 @@ protected function extractPath(string $path): void } if (!\is_array($resourcesYaml)) { - throw new InvalidArgumentException(sprintf('"resources" setting is expected to be null or an array, %s given in "%s".', \gettype($resourcesYaml), $path)); + throw new InvalidArgumentException(\sprintf('"resources" setting is expected to be null or an array, %s given in "%s".', \gettype($resourcesYaml), $path)); } $this->buildResources($resourcesYaml, $path); @@ -89,7 +89,7 @@ private function buildResources(array $resourcesYaml, string $path): void 'graphQlOperations' => $this->buildGraphQlOperations($resourceYamlDatum, $base), ]); } catch (InvalidArgumentException $exception) { - throw new InvalidArgumentException(sprintf('%s in "%s" (%s).', $exception->getMessage(), $resourceName, $path)); + throw new InvalidArgumentException(\sprintf('%s in "%s" (%s).', $exception->getMessage(), $resourceName, $path)); } } } @@ -315,7 +315,7 @@ private function buildOperations(array $resource, array $root): ?array } if (!class_exists($class)) { - throw new InvalidArgumentException(sprintf('Operation class "%s" does not exist', $class)); + throw new InvalidArgumentException(\sprintf('Operation class "%s" does not exist', $class)); } $datum = $this->buildExtendedBase($operation); @@ -328,7 +328,7 @@ private function buildOperations(array $resource, array $root): ?array if (\in_array((string) $class, [GetCollection::class, Post::class], true)) { $datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string'); } elseif (isset($operation['itemUriTemplate'])) { - throw new InvalidArgumentException(sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class)); + throw new InvalidArgumentException(\sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class)); } $data[] = array_merge($datum, [ @@ -371,7 +371,7 @@ private function buildGraphQlOperations(array $resource, array $root): ?array } if (!class_exists($class)) { - throw new InvalidArgumentException(sprintf('Operation class "%s" does not exist', $class)); + throw new InvalidArgumentException(\sprintf('Operation class "%s" does not exist', $class)); } $datum = $this->buildBase($operation); diff --git a/src/Metadata/IdentifiersExtractor.php b/src/Metadata/IdentifiersExtractor.php index 1d6d9b9d2e6..a9f5efe801e 100644 --- a/src/Metadata/IdentifiersExtractor.php +++ b/src/Metadata/IdentifiersExtractor.php @@ -120,7 +120,7 @@ private function getIdentifierValue(object $item, string $class, string $propert $collectionValueType = $type->getCollectionValueTypes()[0] ?? null; if (null !== $collectionValueType && $collectionValueType->getClassName() === $class) { - return $this->resolveIdentifierValue($this->propertyAccessor->getValue($item, sprintf('%s[0].%s', $propertyName, $property)), $parameterName); + return $this->resolveIdentifierValue($this->propertyAccessor->getValue($item, \sprintf('%s[0].%s', $propertyName, $property)), $parameterName); } } @@ -158,6 +158,6 @@ private function resolveIdentifierValue(mixed $identifierValue, string $paramete return (string) $identifierValue->value; } - throw new RuntimeException(sprintf('We were not able to resolve the identifier matching parameter "%s".', $parameterName)); + throw new RuntimeException(\sprintf('We were not able to resolve the identifier matching parameter "%s".', $parameterName)); } } diff --git a/src/Metadata/Operations.php b/src/Metadata/Operations.php index a08e53870ba..83b5e3ab443 100644 --- a/src/Metadata/Operations.php +++ b/src/Metadata/Operations.php @@ -76,7 +76,7 @@ public function remove(string $key): self } } - throw new \RuntimeException(sprintf('Could not remove operation "%s".', $key)); + throw new \RuntimeException(\sprintf('Could not remove operation "%s".', $key)); } public function has(string $key): bool diff --git a/src/Metadata/Parameters.php b/src/Metadata/Parameters.php index 9200ac54880..bb8a1ec650e 100644 --- a/src/Metadata/Parameters.php +++ b/src/Metadata/Parameters.php @@ -80,7 +80,7 @@ public function remove(string $key, string $parameterClass): self } } - throw new RuntimeException(sprintf('Could not remove parameter "%s".', $key)); + throw new RuntimeException(\sprintf('Could not remove parameter "%s".', $key)); } /** diff --git a/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php b/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php index 33409aeb11d..c7340b0537a 100644 --- a/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php +++ b/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php @@ -103,7 +103,7 @@ private function handleNotFound(?ApiProperty $parentPropertyMetadata, string $re return $parentPropertyMetadata; } - throw new PropertyNotFoundException(sprintf('Property "%s" of class "%s" not found.', $property, $resourceClass)); + throw new PropertyNotFoundException(\sprintf('Property "%s" of class "%s" not found.', $property, $resourceClass)); } private function createMetadata(ApiProperty $attribute, ?ApiProperty $propertyMetadata = null): ApiProperty diff --git a/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php b/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php index b8e5f371e67..62e62a90384 100644 --- a/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php +++ b/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php @@ -84,7 +84,7 @@ private function handleNotFound(?ApiProperty $parentPropertyMetadata, string $re return $parentPropertyMetadata; } - throw new PropertyNotFoundException(sprintf('Property "%s" of the resource class "%s" not found.', $property, $resourceClass)); + throw new PropertyNotFoundException(\sprintf('Property "%s" of the resource class "%s" not found.', $property, $resourceClass)); } /** diff --git a/src/Metadata/Property/Factory/ExtractorPropertyNameCollectionFactory.php b/src/Metadata/Property/Factory/ExtractorPropertyNameCollectionFactory.php index 79c6f6d959b..47712f3b94d 100644 --- a/src/Metadata/Property/Factory/ExtractorPropertyNameCollectionFactory.php +++ b/src/Metadata/Property/Factory/ExtractorPropertyNameCollectionFactory.php @@ -58,7 +58,7 @@ public function create(string $resourceClass, array $options = []): PropertyName return $propertyNameCollection; } - throw new ResourceClassNotFoundException(sprintf('The resource class "%s" does not exist.', $resourceClass)); + throw new ResourceClassNotFoundException(\sprintf('The resource class "%s" does not exist.', $resourceClass)); } if ($properties = $this->extractor->getProperties()[$resourceClass] ?? false) { diff --git a/src/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php index fd85c4cd58e..6cc34b8ade5 100644 --- a/src/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php @@ -56,7 +56,7 @@ public function create(string $resourceClass): ResourceMetadataCollection try { $reflectionClass = new \ReflectionClass($resourceClass); } catch (\ReflectionException) { - throw new ResourceClassNotFoundException(sprintf('Resource "%s" not found.', $resourceClass)); + throw new ResourceClassNotFoundException(\sprintf('Resource "%s" not found.', $resourceClass)); } if ($this->hasResourceAttributes($reflectionClass)) { diff --git a/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php index 8c2b6b28de2..75aaace146a 100644 --- a/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php @@ -111,7 +111,7 @@ private function addOperations(?array $data, ApiResource $resource): ApiResource foreach ($data as $attributes) { if (!class_exists($attributes['class'])) { - throw new \InvalidArgumentException(sprintf('Operation "%s" does not exist.', $attributes['class'])); + throw new \InvalidArgumentException(\sprintf('Operation "%s" does not exist.', $attributes['class'])); } /** @var HttpOperation $operation */ @@ -150,7 +150,7 @@ private function addGraphQlOperations(?array $data, ApiResource $resource): ApiR foreach ($data as $attributes) { if (!class_exists($attributes['class'])) { - throw new \InvalidArgumentException(sprintf('Operation "%s" does not exist.', $attributes['class'])); + throw new \InvalidArgumentException(\sprintf('Operation "%s" does not exist.', $attributes['class'])); } /** @var GraphQlOperation $operation */ diff --git a/src/Metadata/Resource/Factory/FiltersResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/FiltersResourceMetadataCollectionFactory.php index 6ec1d31f2df..00ebfc6bc45 100644 --- a/src/Metadata/Resource/Factory/FiltersResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/FiltersResourceMetadataCollectionFactory.php @@ -44,7 +44,7 @@ public function create(string $resourceClass): ResourceMetadataCollection try { $reflectionClass = new \ReflectionClass($resourceClass); } catch (\ReflectionException) { - throw new ResourceClassNotFoundException(sprintf('Resource "%s" not found.', $resourceClass)); + throw new ResourceClassNotFoundException(\sprintf('Resource "%s" not found.', $resourceClass)); } $classFilters = $this->readFilterAttributes($reflectionClass); diff --git a/src/Metadata/Resource/Factory/FormatsResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/FormatsResourceMetadataCollectionFactory.php index 69bf28cddc5..4070884317d 100644 --- a/src/Metadata/Resource/Factory/FormatsResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/FormatsResourceMetadataCollectionFactory.php @@ -124,14 +124,14 @@ private function normalizeFormats(array|string $currentFormats): array continue; } if (!\is_string($value)) { - throw new InvalidArgumentException(sprintf("The 'formats' attributes value must be a string when trying to include an already configured format, %s given.", \gettype($value))); + throw new InvalidArgumentException(\sprintf("The 'formats' attributes value must be a string when trying to include an already configured format, %s given.", \gettype($value))); } if (\array_key_exists($value, $this->formats)) { $normalizedFormats[$value] = $this->formats[$value]; continue; } - throw new InvalidArgumentException(sprintf("You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation.", $value)); + throw new InvalidArgumentException(\sprintf("You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation.", $value)); } return $normalizedFormats; diff --git a/src/Metadata/Resource/Factory/LinkFactory.php b/src/Metadata/Resource/Factory/LinkFactory.php index 95fecdd95b2..248bf6d5986 100644 --- a/src/Metadata/Resource/Factory/LinkFactory.php +++ b/src/Metadata/Resource/Factory/LinkFactory.php @@ -38,7 +38,7 @@ public function createLinkFromProperty(Metadata $operation, string $property): L $metadata = $this->propertyMetadataFactory->create($resourceClass = $operation->getClass(), $property); $relationClass = $this->getPropertyClassType($metadata->getBuiltinTypes()); if (!$relationClass) { - throw new RuntimeException(sprintf('We could not find a class matching the uriVariable "%s" on "%s".', $property, $resourceClass)); + throw new RuntimeException(\sprintf('We could not find a class matching the uriVariable "%s" on "%s".', $property, $resourceClass)); } $identifiers = $this->resourceClassResolver->isResourceClass($relationClass) ? $this->getIdentifiersFromResourceClass($relationClass) : ['id']; diff --git a/src/Metadata/Resource/Factory/OperationDefaultsTrait.php b/src/Metadata/Resource/Factory/OperationDefaultsTrait.php index c21f71ea81a..dab37b23dae 100644 --- a/src/Metadata/Resource/Factory/OperationDefaultsTrait.php +++ b/src/Metadata/Resource/Factory/OperationDefaultsTrait.php @@ -204,7 +204,7 @@ private function getOperationWithDefaults(ApiResource $resource, Operation $oper } if (!$operation instanceof HttpOperation) { - throw new RuntimeException(sprintf('Operation should be an instance of "%s"', HttpOperation::class)); + throw new RuntimeException(\sprintf('Operation should be an instance of "%s"', HttpOperation::class)); } if (!$operation->getName() && $operation->getRouteName()) { @@ -229,7 +229,7 @@ private function getDefaultOperationName(HttpOperation $operation, string $resou { $path = ($operation->getRoutePrefix() ?? '').($operation->getUriTemplate() ?? ''); - return sprintf( + return \sprintf( '_api_%s_%s%s', $path ?: ($operation->getShortName() ?? $this->getDefaultShortname($resourceClass)), strtolower($operation->getMethod()), diff --git a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php index 989add4f794..fba1119570a 100644 --- a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php @@ -148,7 +148,7 @@ private function addSchemaValidation(Parameter $parameter, ?array $schema = null $assertions = []; if ($required && false !== ($allowEmptyValue = $openApi?->getAllowEmptyValue())) { - $assertions[] = new NotNull(message: sprintf('The parameter "%s" is required.', $parameter->getKey())); + $assertions[] = new NotNull(message: \sprintf('The parameter "%s" is required.', $parameter->getKey())); } if (false === ($allowEmptyValue ?? $openApi?->getAllowEmptyValue())) { diff --git a/src/Metadata/Resource/Factory/UriTemplateResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/UriTemplateResourceMetadataCollectionFactory.php index c1045ed01d0..2bc7a407a3f 100644 --- a/src/Metadata/Resource/Factory/UriTemplateResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/UriTemplateResourceMetadataCollectionFactory.php @@ -95,7 +95,7 @@ public function create(string $resourceClass): ResourceMetadataCollection private function generateUriTemplate(HttpOperation $operation): string { - $uriTemplate = $operation->getUriTemplate() ?? sprintf('/%s', $this->pathSegmentNameGenerator->getSegmentName($operation->getShortName())); + $uriTemplate = $operation->getUriTemplate() ?? \sprintf('/%s', $this->pathSegmentNameGenerator->getSegmentName($operation->getShortName())); $uriVariables = $operation->getUriVariables() ?? []; if (str_ends_with($uriTemplate, '{._format}')) { @@ -104,14 +104,14 @@ private function generateUriTemplate(HttpOperation $operation): string if ($parameters = array_keys($uriVariables)) { foreach ($parameters as $parameterName) { - $part = sprintf('/{%s}', $parameterName); + $part = \sprintf('/{%s}', $parameterName); if (!str_contains($uriTemplate, $part)) { - $uriTemplate .= sprintf('/{%s}', $parameterName); + $uriTemplate .= \sprintf('/{%s}', $parameterName); } } } - return sprintf('%s%s', $uriTemplate, '{._format}'); + return \sprintf('%s%s', $uriTemplate, '{._format}'); } private function configureUriVariables(ApiResource|HttpOperation $operation): ApiResource|HttpOperation diff --git a/src/Metadata/Resource/ResourceMetadataCollection.php b/src/Metadata/Resource/ResourceMetadataCollection.php index 7936067b52d..e6c0523eff5 100644 --- a/src/Metadata/Resource/ResourceMetadataCollection.php +++ b/src/Metadata/Resource/ResourceMetadataCollection.php @@ -108,6 +108,6 @@ private function handleNotFound(string $operationName, ?ApiResource $metadata): $shortName = substr($shortName, $pos + 1); } - throw new OperationNotFoundException(sprintf('Operation "%s" not found for resource "%s".', $operationName, $shortName)); + throw new OperationNotFoundException(\sprintf('Operation "%s" not found for resource "%s".', $operationName, $shortName)); } } diff --git a/src/Metadata/ResourceClassResolver.php b/src/Metadata/ResourceClassResolver.php index 54bca45dc86..c7d7fc8e4ff 100644 --- a/src/Metadata/ResourceClassResolver.php +++ b/src/Metadata/ResourceClassResolver.php @@ -50,15 +50,15 @@ public function getResourceClass(mixed $value, ?string $resourceClass = null, bo } if (null !== $actualClass && !$this->isResourceClass($actualClass)) { - throw new InvalidArgumentException(sprintf('No resource class found for object of type "%s".', $actualClass)); + throw new InvalidArgumentException(\sprintf('No resource class found for object of type "%s".', $actualClass)); } if (null !== $resourceClass && !$this->isResourceClass($resourceClass)) { - throw new InvalidArgumentException(sprintf('Specified class "%s" is not a resource class.', $resourceClass)); + throw new InvalidArgumentException(\sprintf('Specified class "%s" is not a resource class.', $resourceClass)); } if ($strict && null !== $actualClass && !is_a($actualClass, $resourceClass, true)) { - throw new InvalidArgumentException(sprintf('Object of type "%s" does not match "%s" resource class.', $actualClass, $resourceClass)); + throw new InvalidArgumentException(\sprintf('Object of type "%s" does not match "%s" resource class.', $actualClass, $resourceClass)); } $targetClass = $actualClass ?? $resourceClass; diff --git a/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php b/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php index b127b9e7efa..0edb5f4ae41 100644 --- a/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php +++ b/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php @@ -80,7 +80,7 @@ public function __invoke(string $resourceClass, string $propertyName, array $par continue; } - throw new \LogicException(sprintf('Cannot adapt attribute or child "%s". Please add fixtures in '.PropertyMetadataCompatibilityTest::class.' and create a "%s" method in %s.', $parameterName, 'build'.ucfirst($parameterName), self::class)); + throw new \LogicException(\sprintf('Cannot adapt attribute or child "%s". Please add fixtures in '.PropertyMetadataCompatibilityTest::class.' and create a "%s" method in %s.', $parameterName, 'build'.ucfirst($parameterName), self::class)); } $filename = __DIR__.'/properties.xml'; diff --git a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php index a5e592e8f2e..8e195d49990 100644 --- a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php +++ b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php @@ -110,7 +110,7 @@ public function __invoke(string $resourceClass, array $parameters, array $fixtur continue; } - throw new \LogicException(sprintf('Cannot adapt attribute or child "%s". Please add fixtures in '.ResourceMetadataCompatibilityTest::class.' and create a "%s" method in %s.', $parameterName, 'build'.ucfirst($parameterName), self::class)); + throw new \LogicException(\sprintf('Cannot adapt attribute or child "%s". Please add fixtures in '.ResourceMetadataCompatibilityTest::class.' and create a "%s" method in %s.', $parameterName, 'build'.ucfirst($parameterName), self::class)); } } @@ -428,7 +428,7 @@ private function buildGraphQlOperations(\SimpleXMLElement $resource, array $valu continue; } - throw new \LogicException(sprintf('Cannot adapt graphQlOperation attribute or child "%s". Please create a "%s" method in %s.', $index, 'build'.ucfirst($index), self::class)); + throw new \LogicException(\sprintf('Cannot adapt graphQlOperation attribute or child "%s". Please create a "%s" method in %s.', $index, 'build'.ucfirst($index), self::class)); } } } @@ -449,7 +449,7 @@ private function buildOperations(\SimpleXMLElement $resource, array $values): vo continue; } - throw new \LogicException(sprintf('Cannot adapt operation attribute or child "%s". Please create a "%s" method in %s.', $index, 'build'.ucfirst($index), self::class)); + throw new \LogicException(\sprintf('Cannot adapt operation attribute or child "%s". Please create a "%s" method in %s.', $index, 'build'.ucfirst($index), self::class)); } } } diff --git a/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php b/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php index 3a8333ebc3e..55ebdb5d919 100644 --- a/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php +++ b/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php @@ -117,7 +117,7 @@ private function buildApiProperty(): ApiProperty continue; } - throw new \RuntimeException(sprintf('Unknown ApiProperty parameter "%s".', $parameter)); + throw new \RuntimeException(\sprintf('Unknown ApiProperty parameter "%s".', $parameter)); } return $property; diff --git a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php index 4c67c74ca71..879e4572a97 100644 --- a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php +++ b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php @@ -579,7 +579,7 @@ private function buildApiResources(): array continue; } - throw new \RuntimeException(sprintf('Unknown ApiResource parameter "%s".', $parameter)); + throw new \RuntimeException(\sprintf('Unknown ApiResource parameter "%s".', $parameter)); } $resources[] = $resource; @@ -670,7 +670,7 @@ private function withOperations(array $values, ?array $fixtures): Operations continue; } - throw new \RuntimeException(sprintf('Unknown Operation parameter "%s".', $parameter)); + throw new \RuntimeException(\sprintf('Unknown Operation parameter "%s".', $parameter)); } $operationName = $operation->getName() ?? $this->getDefaultOperationName($operation, self::RESOURCE_CLASS); @@ -704,7 +704,7 @@ private function withGraphQlOperations(array $values, ?array $fixtures): array continue; } - throw new \RuntimeException(sprintf('Unknown GraphQlOperation parameter "%s".', $parameter)); + throw new \RuntimeException(\sprintf('Unknown GraphQlOperation parameter "%s".', $parameter)); } $operationName = $operation->getName(); @@ -730,7 +730,7 @@ private function withStateOptions(array $values) return null; } - throw new \LogicException(sprintf('Unsupported "%s" state options.', key($values))); + throw new \LogicException(\sprintf('Unsupported "%s" state options.', key($values))); } private function withLinks(array $values): ?array diff --git a/src/Metadata/Tests/Property/Factory/CachedPropertyMetadataFactoryTest.php b/src/Metadata/Tests/Property/Factory/CachedPropertyMetadataFactoryTest.php index 81946fff365..0abd9780e5b 100644 --- a/src/Metadata/Tests/Property/Factory/CachedPropertyMetadataFactoryTest.php +++ b/src/Metadata/Tests/Property/Factory/CachedPropertyMetadataFactoryTest.php @@ -78,7 +78,7 @@ public function testCreateWithGetCacheItemThrowsCacheException(): void $decoratedPropertyMetadataFactory = $this->prophesize(PropertyMetadataFactoryInterface::class); $decoratedPropertyMetadataFactory->create(Dummy::class, 'dummy', [])->willReturn($propertyMetadata)->shouldBeCalled(); - $cacheException = new class() extends \Exception implements CacheException {}; + $cacheException = new class extends \Exception implements CacheException {}; $cacheItemPool = $this->prophesize(CacheItemPoolInterface::class); $cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalled(); diff --git a/src/Metadata/Tests/Property/Factory/CachedPropertyNameCollectionFactoryTest.php b/src/Metadata/Tests/Property/Factory/CachedPropertyNameCollectionFactoryTest.php index 88ef2b3742a..8ed75605627 100644 --- a/src/Metadata/Tests/Property/Factory/CachedPropertyNameCollectionFactoryTest.php +++ b/src/Metadata/Tests/Property/Factory/CachedPropertyNameCollectionFactoryTest.php @@ -77,7 +77,7 @@ public function testCreateWithGetCacheItemThrowsCacheException(): void $decoratedPropertyNameCollectionFactory = $this->prophesize(PropertyNameCollectionFactoryInterface::class); $decoratedPropertyNameCollectionFactory->create(Dummy::class, [])->willReturn(new PropertyNameCollection(['id', 'name', 'description', 'dummy']))->shouldBeCalled(); - $cacheException = new class() extends \Exception implements CacheException {}; + $cacheException = new class extends \Exception implements CacheException {}; $cacheItemPool = $this->prophesize(CacheItemPoolInterface::class); $cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalled(); diff --git a/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTests.php b/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTests.php index d36836e4060..99712574328 100644 --- a/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTests.php +++ b/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTests.php @@ -29,7 +29,7 @@ public function testParameterFactory(): void { $filterLocator = $this->createStub(ContainerInterface::class); $filterLocator->method('has')->willReturn(true); - $filterLocator->method('get')->willReturn(new class() implements FilterInterface { + $filterLocator->method('get')->willReturn(new class implements FilterInterface { public function getDescription(string $resourceClass): array { return [ diff --git a/src/Metadata/Tests/Resource/StringableSecurityParameterTest.php b/src/Metadata/Tests/Resource/StringableSecurityParameterTest.php index 7ff3736546c..680ac08b040 100644 --- a/src/Metadata/Tests/Resource/StringableSecurityParameterTest.php +++ b/src/Metadata/Tests/Resource/StringableSecurityParameterTest.php @@ -47,19 +47,19 @@ public function testOnMetadata(Metadata $metadata): void public static function metadataProvider(): \Generator { - $stringableSecurity = new class() implements \Stringable { + $stringableSecurity = new class implements \Stringable { public function __toString(): string { return 'stringable_security'; } }; - $stringableSecurityPostDenormalize = new class() implements \Stringable { + $stringableSecurityPostDenormalize = new class implements \Stringable { public function __toString(): string { return 'stringable_security_post_denormalize'; } }; - $stringableSecurityPostValidation = new class() implements \Stringable { + $stringableSecurityPostValidation = new class implements \Stringable { public function __toString(): string { return 'stringable_security_post_validation'; @@ -90,13 +90,13 @@ public function __toString(): string public function testOnApiProperty(): void { - $stringableSecurity = new class() implements \Stringable { + $stringableSecurity = new class implements \Stringable { public function __toString(): string { return 'stringable_security'; } }; - $stringableSecurityPostDenormalize = new class() implements \Stringable { + $stringableSecurityPostDenormalize = new class implements \Stringable { public function __toString(): string { return 'stringable_security_post_denormalize'; diff --git a/src/Metadata/UriVariablesConverter.php b/src/Metadata/UriVariablesConverter.php index db838be38e6..ff4d6213f67 100644 --- a/src/Metadata/UriVariablesConverter.php +++ b/src/Metadata/UriVariablesConverter.php @@ -67,7 +67,7 @@ public function convert(array $uriVariables, string $class, array $context = []) $uriVariables[$parameterName] = $uriVariableTransformer->transform($value, $types, $context); break; } catch (InvalidUriVariableException $e) { - throw new InvalidUriVariableException(sprintf('Identifier "%s" could not be transformed.', $parameterName), $e->getCode(), $e); + throw new InvalidUriVariableException(\sprintf('Identifier "%s" could not be transformed.', $parameterName), $e->getCode(), $e); } } } diff --git a/src/Metadata/Util/CompositeIdentifierParser.php b/src/Metadata/Util/CompositeIdentifierParser.php index f433cdf0abe..c7d45a0668d 100644 --- a/src/Metadata/Util/CompositeIdentifierParser.php +++ b/src/Metadata/Util/CompositeIdentifierParser.php @@ -57,7 +57,7 @@ public static function stringify(array $identifiers): string { $composite = []; foreach ($identifiers as $name => $value) { - $composite[] = sprintf('%s=%s', $name, $value); + $composite[] = \sprintf('%s=%s', $name, $value); } return implode(';', $composite); diff --git a/src/Metadata/Util/ContentNegotiationTrait.php b/src/Metadata/Util/ContentNegotiationTrait.php index e2cecb80d3c..6690cca7041 100644 --- a/src/Metadata/Util/ContentNegotiationTrait.php +++ b/src/Metadata/Util/ContentNegotiationTrait.php @@ -84,7 +84,7 @@ private function getRequestFormat(Request $request, array $formats, bool $throw $mimeTypes = Request::getMimeTypes($routeFormat); $flattenedMimeTypes = $this->flattenMimeTypes([$routeFormat => $mimeTypes]); } elseif ($throw) { - throw new NotFoundHttpException(sprintf('Format "%s" is not supported', $routeFormat)); + throw new NotFoundHttpException(\sprintf('Format "%s" is not supported', $routeFormat)); } } @@ -129,7 +129,7 @@ private function getRequestFormat(Request $request, array $formats, bool $throw */ private function getNotAcceptableHttpException(string $accept, array $mimeTypes): NotAcceptableHttpException { - return new NotAcceptableHttpException(sprintf( + return new NotAcceptableHttpException(\sprintf( 'Requested format "%s" is not supported. Supported MIME types are "%s".', $accept, implode('", "', array_keys($mimeTypes)) diff --git a/src/Metadata/Util/IriHelper.php b/src/Metadata/Util/IriHelper.php index 7d36ba732e0..6a142d11154 100644 --- a/src/Metadata/Util/IriHelper.php +++ b/src/Metadata/Util/IriHelper.php @@ -39,7 +39,7 @@ public static function parseIri(string $iri, string $pageParameterName): array { $parts = parse_url($iri); if (false === $parts) { - throw new InvalidArgumentException(sprintf('The request URI "%s" is malformed.', $iri)); + throw new InvalidArgumentException(\sprintf('The request URI "%s" is malformed.', $iri)); } $parameters = []; diff --git a/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php b/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php index ba3f0867df4..5e4fc475fa1 100644 --- a/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php +++ b/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php @@ -106,7 +106,7 @@ public static function createTypeFromLegacyValues(string $builtinType, bool $nul try { $type = null !== $class ? Type::object($class) : Type::builtin(TypeIdentifier::from($builtinType)); } catch (\ValueError) { - throw new InvalidArgumentException(sprintf('"%s" is not a valid PHP type.', $builtinType)); + throw new InvalidArgumentException(\sprintf('"%s" is not a valid PHP type.', $builtinType)); } if (\count($variableTypes)) { diff --git a/src/OpenApi/Command/OpenApiCommand.php b/src/OpenApi/Command/OpenApiCommand.php index b79f43d988e..6f32b9a57ea 100644 --- a/src/OpenApi/Command/OpenApiCommand.php +++ b/src/OpenApi/Command/OpenApiCommand.php @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $filename = $input->getOption('output'); if ($filename && \is_string($filename)) { $filesystem->dumpFile($filename, $content); - $io->success(sprintf('Data written to %s.', $filename)); + $io->success(\sprintf('Data written to %s.', $filename)); return \defined(Command::class.'::SUCCESS') ? Command::SUCCESS : 0; } diff --git a/src/OpenApi/Factory/OpenApiFactory.php b/src/OpenApi/Factory/OpenApiFactory.php index 83ac102cb5a..3b6007ab9a2 100644 --- a/src/OpenApi/Factory/OpenApiFactory.php +++ b/src/OpenApi/Factory/OpenApiFactory.php @@ -274,12 +274,12 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection switch ($method) { case 'GET': $successStatus = (string) $operation->getStatus() ?: 200; - $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, sprintf('%s %s', $resourceShortName, $operation instanceof CollectionOperationInterface ? 'collection' : 'resource'), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas); + $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s %s', $resourceShortName, $operation instanceof CollectionOperationInterface ? 'collection' : 'resource'), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas); break; case 'POST': $successStatus = (string) $operation->getStatus() ?: 201; - $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, sprintf('%s resource created', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection); + $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource created', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection); $openapiOperation = $this->buildOpenApiResponse($existingResponses, '400', 'Invalid input', $openapiOperation); @@ -288,7 +288,7 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection case 'PATCH': case 'PUT': $successStatus = (string) $operation->getStatus() ?: 200; - $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, sprintf('%s resource updated', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection); + $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource updated', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection); $openapiOperation = $this->buildOpenApiResponse($existingResponses, '400', 'Invalid input', $openapiOperation); if (!isset($existingResponses[400])) { $openapiOperation = $openapiOperation->withResponse(400, new Response('Invalid input')); @@ -298,7 +298,7 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection case 'DELETE': $successStatus = (string) $operation->getStatus() ?: 204; - $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, sprintf('%s resource deleted', $resourceShortName), $openapiOperation); + $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource deleted', $resourceShortName), $openapiOperation); break; } @@ -330,7 +330,7 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection } $openapiOperation = $openapiOperation->withRequestBody(new RequestBody( - description: $openapiOperation->getRequestBody()?->getDescription() ?? sprintf('The %s %s resource', 'POST' === $method ? 'new' : 'updated', $resourceShortName), + description: $openapiOperation->getRequestBody()?->getDescription() ?? \sprintf('The %s %s resource', 'POST' === $method ? 'new' : 'updated', $resourceShortName), content: $content, required: $openapiOperation->getRequestBody()?->getRequired() ?? true, )); @@ -438,7 +438,7 @@ private function getPathDescription(string $resourceShortName, string $method, b return $resourceShortName; } - return sprintf($pathSummary, $resourceShortName); + return \sprintf($pathSummary, $resourceShortName); } /** @@ -598,7 +598,7 @@ private function getPaginationParameters(CollectionOperationInterface|HttpOperat private function getOauthSecurityScheme(): SecurityScheme { $oauthFlow = new OAuthFlow($this->openApiOptions->getOAuthAuthorizationUrl(), $this->openApiOptions->getOAuthTokenUrl() ?: null, $this->openApiOptions->getOAuthRefreshUrl() ?: null, new \ArrayObject($this->openApiOptions->getOAuthScopes())); - $description = sprintf( + $description = \sprintf( 'OAuth 2.0 %s Grant', strtolower(preg_replace('/[A-Z]/', ' \\0', lcfirst($this->openApiOptions->getOAuthFlow()))) ); @@ -635,7 +635,7 @@ private function getSecuritySchemes(): array } foreach ($this->openApiOptions->getApiKeys() as $key => $apiKey) { - $description = sprintf('Value for the %s %s parameter.', $apiKey['name'], $apiKey['type']); + $description = \sprintf('Value for the %s %s parameter.', $apiKey['name'], $apiKey['type']); $securitySchemes[$key] = new SecurityScheme('apiKey', $description, $apiKey['name'], $apiKey['type']); } diff --git a/src/Serializer/AbstractItemNormalizer.php b/src/Serializer/AbstractItemNormalizer.php index a9695cb135b..ad35cfee0cc 100644 --- a/src/Serializer/AbstractItemNormalizer.php +++ b/src/Serializer/AbstractItemNormalizer.php @@ -226,12 +226,12 @@ public function denormalize(mixed $data, string $class, ?string $format = null, } catch (ItemNotFoundException $e) { throw new UnexpectedValueException($e->getMessage(), $e->getCode(), $e); } catch (InvalidArgumentException $e) { - throw new UnexpectedValueException(sprintf('Invalid IRI "%s".', $data), $e->getCode(), $e); + throw new UnexpectedValueException(\sprintf('Invalid IRI "%s".', $data), $e->getCode(), $e); } } if (!\is_array($data)) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" resource must be "array" (nested document) or "string" (IRI), "%s" given.', $resourceClass, \gettype($data)), $data, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" resource must be "array" (nested document) or "string" (IRI), "%s" given.', $resourceClass, \gettype($data)), $data, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null); } $previousObject = $this->clone($objectToPopulate); @@ -304,7 +304,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex if ($constructorParameter->isVariadic()) { if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) { if (!\is_array($data[$paramName])) { - throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name)); + throw new RuntimeException(\sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name)); } $params[] = $data[$paramName]; @@ -332,13 +332,13 @@ protected function instantiateObject(array &$data, string $class, array &$contex $missingConstructorArguments[] = $constructorParameter->name; } - $exception = NotNormalizableValueException::createForUnexpectedDataType(sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name), $data, ['unknown'], $context['deserialization_path'] ?? null, true); + $exception = NotNormalizableValueException::createForUnexpectedDataType(\sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name), $data, ['unknown'], $context['deserialization_path'] ?? null, true); $context['not_normalizable_value_exceptions'][] = $exception; } } if ($missingConstructorArguments) { - throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$%s".', $class, implode('", "$', $missingConstructorArguments)), 0, null, $missingConstructorArguments, $class); + throw new MissingConstructorArgumentsException(\sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$%s".', $class, implode('", "$', $missingConstructorArguments)), 0, null, $missingConstructorArguments, $class); } if (\count($context['not_normalizable_value_exceptions'] ?? []) > 0) { @@ -362,12 +362,12 @@ protected function getClassDiscriminatorResolvedClass(array $data, string $class } if (!isset($data[$mapping->getTypeProperty()])) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Type property "%s" not found for the abstract object "%s".', $mapping->getTypeProperty(), $class), null, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty()); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('Type property "%s" not found for the abstract object "%s".', $mapping->getTypeProperty(), $class), null, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty()); } $type = $data[$mapping->getTypeProperty()]; if (null === ($mappedClass = $mapping->getClassForType($type))) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type "%s" is not a valid value.', $type), $type, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty(), true); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type "%s" is not a valid value.', $type), $type, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty(), true); } return $mappedClass; @@ -503,7 +503,7 @@ protected function validateType(string $attribute, Type $type, mixed $value, ?st } if (!$isValid) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $attribute, $builtinType, \gettype($value)), $value, [$builtinType], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $attribute, $builtinType, \gettype($value)), $value, [$builtinType], $context['deserialization_path'] ?? null); } } @@ -515,7 +515,7 @@ protected function validateType(string $attribute, Type $type, mixed $value, ?st protected function denormalizeCollection(string $attribute, ApiProperty $propertyMetadata, Type $type, string $className, mixed $value, ?string $format, array $context): array { if (!\is_array($value)) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute must be "array", "%s" given.', $attribute, \gettype($value)), $value, [Type::BUILTIN_TYPE_ARRAY], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute must be "array", "%s" given.', $attribute, \gettype($value)), $value, [Type::BUILTIN_TYPE_ARRAY], $context['deserialization_path'] ?? null); } $values = []; @@ -538,7 +538,7 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert $values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $childContext); continue 2; } - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the key "%s" must be "%s", "%s" given.', $index, $collectionKeyTypes[0]->getBuiltinType(), \gettype($index)), $index, [$collectionKeyTypes[0]->getBuiltinType()], ($context['deserialization_path'] ?? false) ? sprintf('key(%s)', $context['deserialization_path']) : null, true); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the key "%s" must be "%s", "%s" given.', $index, $collectionKeyTypes[0]->getBuiltinType(), \gettype($index)), $index, [$collectionKeyTypes[0]->getBuiltinType()], ($context['deserialization_path'] ?? false) ? \sprintf('key(%s)', $context['deserialization_path']) : null, true); } return $values; @@ -573,7 +573,7 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope return null; } catch (InvalidArgumentException $e) { if (!isset($context['not_normalizable_value_exceptions'])) { - throw new UnexpectedValueException(sprintf('Invalid IRI "%s".', $value), $e->getCode(), $e); + throw new UnexpectedValueException(\sprintf('Invalid IRI "%s".', $value), $e->getCode(), $e); } $context['not_normalizable_value_exceptions'][] = NotNormalizableValueException::createForUnexpectedDataType( $e->getMessage(), @@ -593,7 +593,7 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope $context['api_allow_update'] = true; if (!$this->serializer instanceof DenormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); } $item = $this->serializer->denormalize($value, $className, $format, $context); @@ -605,10 +605,10 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope } if (!\is_array($value)) { - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute must be "array" (nested document) or "string" (IRI), "%s" given.', $attributeName, \gettype($value)), $value, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null, true); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute must be "array" (nested document) or "string" (IRI), "%s" given.', $attributeName, \gettype($value)), $value, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null, true); } - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Nested documents for attribute "%s" are not allowed. Use IRIs instead.', $attributeName), $value, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null, true); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('Nested documents for attribute "%s" are not allowed. Use IRIs instead.', $attributeName), $value, [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null, true); } /** @@ -732,7 +732,7 @@ protected function getAttributeValue(object $object, string $attribute, ?string } if (!$this->serializer instanceof NormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); } unset( @@ -766,7 +766,7 @@ protected function getAttributeValue(object $object, string $attribute, ?string } if (!$this->serializer instanceof NormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); } unset( @@ -816,7 +816,7 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel { if (null === $relatedObject || !empty($context['attributes']) || $propertyMetadata->isReadableLink()) { if (!$this->serializer instanceof NormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); } $relatedContext = $this->createOperationContext($context, $resourceClass); @@ -911,7 +911,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value && \is_array($value) ) { if (!$this->serializer instanceof DenormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); } unset($context['resource_class'], $context['uri_variables']); @@ -921,7 +921,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value if (null !== $className = $type->getClassName()) { if (!$this->serializer instanceof DenormalizerInterface) { - throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); + throw new LogicException(\sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class)); } unset($context['resource_class'], $context['uri_variables']); @@ -950,7 +950,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value if ($isMultipleTypes) { break 2; } - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute for class "%s" must be bool ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_BOOL], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute for class "%s" must be bool ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_BOOL], $context['deserialization_path'] ?? null); } break; case Type::BUILTIN_TYPE_INT: @@ -961,7 +961,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value if ($isMultipleTypes) { break 2; } - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute for class "%s" must be int ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_INT], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute for class "%s" must be int ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_INT], $context['deserialization_path'] ?? null); } break; case Type::BUILTIN_TYPE_FLOAT: @@ -981,7 +981,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value if ($isMultipleTypes) { break 3; } - throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the "%s" attribute for class "%s" must be float ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_FLOAT], $context['deserialization_path'] ?? null); + throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute for class "%s" must be float ("%s" given).', $attribute, $className, $value), $value, [Type::BUILTIN_TYPE_FLOAT], $context['deserialization_path'] ?? null); } } } diff --git a/src/Serializer/Filter/PropertyFilter.php b/src/Serializer/Filter/PropertyFilter.php index aa94bdea1bc..b8327e449e7 100644 --- a/src/Serializer/Filter/PropertyFilter.php +++ b/src/Serializer/Filter/PropertyFilter.php @@ -158,7 +158,7 @@ public function apply(Request $request, bool $normalization, array $attributes, */ public function getDescription(string $resourceClass): array { - $example = sprintf('%1$s[]={propertyName}&%1$s[]={anotherPropertyName}&%1$s[{nestedPropertyParent}][]={nestedProperty}', + $example = \sprintf('%1$s[]={propertyName}&%1$s[]={anotherPropertyName}&%1$s[{nestedPropertyParent}][]={nestedProperty}', $this->parameterName ); diff --git a/src/Serializer/Tests/AbstractItemNormalizerTest.php b/src/Serializer/Tests/AbstractItemNormalizerTest.php index 3b18e6c3ce3..07c964ec2ce 100644 --- a/src/Serializer/Tests/AbstractItemNormalizerTest.php +++ b/src/Serializer/Tests/AbstractItemNormalizerTest.php @@ -1341,7 +1341,7 @@ public function testCacheKey(): void ])); $operationCacheKey = (new \ReflectionClass($normalizer))->getProperty('localFactoryOptionsCache')->getValue($normalizer); - $this->assertEquals(array_keys($operationCacheKey), [sprintf('%s%s%s%s', Dummy::class, 'operation_name', 'root_operation_name', 'n')]); + $this->assertEquals(array_keys($operationCacheKey), [\sprintf('%s%s%s%s', Dummy::class, 'operation_name', 'root_operation_name', 'n')]); $this->assertEquals(current($operationCacheKey), ['serializer_groups' => ['group']]); } } diff --git a/src/State/CallableProcessor.php b/src/State/CallableProcessor.php index e913283ca2a..b75f851c849 100644 --- a/src/State/CallableProcessor.php +++ b/src/State/CallableProcessor.php @@ -43,7 +43,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = } if (!$this->locator->has($processor)) { - throw new RuntimeException(sprintf('Processor "%s" not found on operation "%s"', $processor, $operation->getName())); + throw new RuntimeException(\sprintf('Processor "%s" not found on operation "%s"', $processor, $operation->getName())); } /** @var ProcessorInterface $processorInstance */ diff --git a/src/State/CallableProvider.php b/src/State/CallableProvider.php index f668447ce85..fa48d8685df 100644 --- a/src/State/CallableProvider.php +++ b/src/State/CallableProvider.php @@ -34,7 +34,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c if ($this->locator && \is_string($provider)) { if (!$this->locator->has($provider)) { - throw new ProviderNotFoundException(sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName())); + throw new ProviderNotFoundException(\sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName())); } /** @var ProviderInterface $providerInstance */ @@ -43,6 +43,6 @@ public function provide(Operation $operation, array $uriVariables = [], array $c return $providerInstance->provide($operation, $uriVariables, $context); } - throw new ProviderNotFoundException(sprintf('Provider not found on operation "%s"', $operation->getName())); + throw new ProviderNotFoundException(\sprintf('Provider not found on operation "%s"', $operation->getName())); } } diff --git a/src/State/CreateProvider.php b/src/State/CreateProvider.php index 4cb0117ef53..d10a1d6fb42 100644 --- a/src/State/CreateProvider.php +++ b/src/State/CreateProvider.php @@ -68,7 +68,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c try { $resource = new ($operation->getClass()); } catch (\Throwable $e) { - throw new RuntimeException(sprintf('An error occurred while trying to create an instance of the "%s" resource. Consider writing your own "%s" implementation and setting it as `provider` on your operation instead.', $operation->getClass(), ProviderInterface::class), 0, $e); + throw new RuntimeException(\sprintf('An error occurred while trying to create an instance of the "%s" resource. Consider writing your own "%s" implementation and setting it as `provider` on your operation instead.', $operation->getClass(), ProviderInterface::class), 0, $e); } $property = $operationUriVariables[$key]->getToProperty() ?? $key; diff --git a/src/State/ObjectProvider.php b/src/State/ObjectProvider.php index 740c310378a..308dbda9783 100644 --- a/src/State/ObjectProvider.php +++ b/src/State/ObjectProvider.php @@ -30,7 +30,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c try { return new ($operation->getClass()); } catch (\Throwable $e) { - throw new RuntimeException(sprintf('An error occurred while trying to create an instance of the "%s" resource. Consider writing your own "%s" implementation and setting it as `provider` on your operation instead.', $operation->getClass(), ProviderInterface::class), 0, $e); + throw new RuntimeException(\sprintf('An error occurred while trying to create an instance of the "%s" resource. Consider writing your own "%s" implementation and setting it as `provider` on your operation instead.', $operation->getClass(), ProviderInterface::class), 0, $e); } } } diff --git a/src/State/Processor/RespondProcessor.php b/src/State/Processor/RespondProcessor.php index 1cf28f6d2a2..15e9c030327 100644 --- a/src/State/Processor/RespondProcessor.php +++ b/src/State/Processor/RespondProcessor.php @@ -60,7 +60,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = } $headers = [ - 'Content-Type' => sprintf('%s; charset=utf-8', $request->getMimeType($request->getRequestFormat())), + 'Content-Type' => \sprintf('%s; charset=utf-8', $request->getMimeType($request->getRequestFormat())), 'Vary' => 'Accept', 'X-Content-Type-Options' => 'nosniff', 'X-Frame-Options' => 'deny', diff --git a/src/State/Provider/ContentNegotiationProvider.php b/src/State/Provider/ContentNegotiationProvider.php index 95d165be2e5..0ffd42607b6 100644 --- a/src/State/Provider/ContentNegotiationProvider.php +++ b/src/State/Provider/ContentNegotiationProvider.php @@ -116,7 +116,7 @@ private function getInputFormat(HttpOperation $operation, Request $request): ?st } if (!$request->isMethodSafe() && 'DELETE' !== $request->getMethod()) { - throw new UnsupportedMediaTypeHttpException(sprintf('The content-type "%s" is not supported. Supported MIME types are "%s".', $contentType, implode('", "', $supportedMimeTypes))); + throw new UnsupportedMediaTypeHttpException(\sprintf('The content-type "%s" is not supported. Supported MIME types are "%s".', $contentType, implode('", "', $supportedMimeTypes))); } return null; diff --git a/src/State/Provider/DeserializeProvider.php b/src/State/Provider/DeserializeProvider.php index 18db103f3bc..0e4010cc1e6 100644 --- a/src/State/Provider/DeserializeProvider.php +++ b/src/State/Provider/DeserializeProvider.php @@ -40,7 +40,7 @@ public function __construct( private ?TranslatorInterface $translator = null ) { if (null === $this->translator) { - $this->translator = new class() implements TranslatorInterface, LocaleAwareInterface { + $this->translator = new class implements TranslatorInterface, LocaleAwareInterface { use TranslatorTrait; }; $this->translator->setLocale('en'); diff --git a/src/State/Provider/ParameterProvider.php b/src/State/Provider/ParameterProvider.php index 28d7a1622bc..9a905d9497e 100644 --- a/src/State/Provider/ParameterProvider.php +++ b/src/State/Provider/ParameterProvider.php @@ -80,7 +80,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c } if (!\is_string($provider) || !$this->locator->has($provider)) { - throw new ProviderNotFoundException(sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName())); + throw new ProviderNotFoundException(\sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName())); } /** @var ParameterProviderInterface $providerInstance */ diff --git a/src/State/Tests/ParameterProviderTest.php b/src/State/Tests/ParameterProviderTest.php index a69b3f1ddfb..66d5d7a88ff 100644 --- a/src/State/Tests/ParameterProviderTest.php +++ b/src/State/Tests/ParameterProviderTest.php @@ -28,11 +28,11 @@ final class ParameterProviderTest extends TestCase { public function testExtractValues(): void { - $locator = new class() implements ContainerInterface { + $locator = new class implements ContainerInterface { public function get(string $id) { if ('test' === $id) { - return new class() implements ParameterProviderInterface { + return new class implements ParameterProviderInterface { public function provide(Parameter $parameter, array $parameters = [], array $context = []): ?Operation { return new Get(name: 'ok'); diff --git a/src/State/UriVariablesResolverTrait.php b/src/State/UriVariablesResolverTrait.php index 4f5b7be0658..0463041b1f2 100644 --- a/src/State/UriVariablesResolverTrait.php +++ b/src/State/UriVariablesResolverTrait.php @@ -37,7 +37,7 @@ private function getOperationUriVariables(?HttpOperation $operation = null, arra foreach ($operation->getUriVariables() ?? [] as $parameterName => $uriVariableDefinition) { if (!isset($parameters[$parameterName])) { if (!isset($parameters['id'])) { - throw new InvalidIdentifierException(sprintf('Parameter "%s" not found, check the identifiers configuration.', $parameterName)); + throw new InvalidIdentifierException(\sprintf('Parameter "%s" not found, check the identifiers configuration.', $parameterName)); } $parameterName = 'id'; @@ -47,7 +47,7 @@ private function getOperationUriVariables(?HttpOperation $operation = null, arra $currentIdentifiers = CompositeIdentifierParser::parse($parameters[$parameterName]); if (($foundNumIdentifiers = \count($currentIdentifiers)) !== $numIdentifiers) { - throw new InvalidIdentifierException(sprintf('We expected "%s" identifiers and got "%s".', $numIdentifiers, $foundNumIdentifiers)); + throw new InvalidIdentifierException(\sprintf('We expected "%s" identifiers and got "%s".', $numIdentifiers, $foundNumIdentifiers)); } foreach ($currentIdentifiers as $key => $value) { diff --git a/src/Symfony/Bundle/Command/DebugResourceCommand.php b/src/Symfony/Bundle/Command/DebugResourceCommand.php index 0b93b33ded4..343d7ddeb06 100644 --- a/src/Symfony/Bundle/Command/DebugResourceCommand.php +++ b/src/Symfony/Bundle/Command/DebugResourceCommand.php @@ -49,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $resourceCollection = $this->resourceMetadataCollectionFactory->create($resourceClass); if (0 === \count($resourceCollection)) { - $output->writeln(sprintf('No resources found for class %s', $resourceClass)); + $output->writeln(\sprintf('No resources found for class %s', $resourceClass)); return \defined(Command::class.'::INVALID') ? Command::INVALID : 2; } @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (\count($resourceCollection) > 1) { $questionResource = new ChoiceQuestion( - sprintf('There are %d resources declared on the class %s, which one do you want to debug ? ', \count($resourceCollection), $shortName).\PHP_EOL, + \sprintf('There are %d resources declared on the class %s, which one do you want to debug ? ', \count($resourceCollection), $shortName).\PHP_EOL, $resources ); @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $selectedResource = $resourceCollection[$resourceIndex]; } else { $selectedResource = $resourceCollection[0]; - $output->writeln(sprintf('Class %s declares 1 resource.', $shortName).\PHP_EOL); + $output->writeln(\sprintf('Class %s declares 1 resource.', $shortName).\PHP_EOL); } $operations = ['Debug the resource itself']; @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $questionOperation = new ChoiceQuestion( - sprintf('There are %d operation%s declared on the resource, which one do you want to debug ? ', $selectedResource->getOperations()->count(), $selectedResource->getOperations()->count() > 1 ? 's' : '').\PHP_EOL, + \sprintf('There are %d operation%s declared on the resource, which one do you want to debug ? ', $selectedResource->getOperations()->count(), $selectedResource->getOperations()->count() > 1 ? 's' : '').\PHP_EOL, $operations ); diff --git a/src/Symfony/Bundle/Command/GraphQlExportCommand.php b/src/Symfony/Bundle/Command/GraphQlExportCommand.php index 6bca2332007..b83cbd3e12b 100644 --- a/src/Symfony/Bundle/Command/GraphQlExportCommand.php +++ b/src/Symfony/Bundle/Command/GraphQlExportCommand.php @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $filename = $input->getOption('output'); if (\is_string($filename)) { file_put_contents($filename, $schemaExport); - $io->success(sprintf('Data written to %s.', $filename)); + $io->success(\sprintf('Data written to %s.', $filename)); } else { $output->writeln($schemaExport); } diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 1256b6542a3..44c4f0d8362 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -409,7 +409,7 @@ private function getResourcesToWatch(ContainerBuilder $container, array $config) if ($container->fileExists($path, false)) { if (!preg_match('/\.(xml|ya?ml)$/', (string) $path, $matches)) { - throw new RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & YAML.', $path)); + throw new RuntimeException(\sprintf('Unsupported mapping type in "%s", supported types are XML & YAML.', $path)); } $resources['yaml' === $matches[1] ? 'yml' : $matches[1]][] = $path; @@ -417,7 +417,7 @@ private function getResourcesToWatch(ContainerBuilder $container, array $config) continue; } - throw new RuntimeException(sprintf('Could not open file or directory "%s".', $path)); + throw new RuntimeException(\sprintf('Could not open file or directory "%s".', $path)); } $container->setParameter('api_platform.resource_class_directories', $resources['dir']); @@ -454,7 +454,7 @@ private function registerSwaggerConfiguration(ContainerBuilder $container, array { foreach (array_keys($config['swagger']['api_keys']) as $keyName) { if (!preg_match('/^[a-zA-Z0-9._-]+$/', $keyName)) { - trigger_deprecation('api-platform/core', '3.1', sprintf('The swagger api_keys key "%s" is not valid with OpenAPI 3.1 it should match "^[a-zA-Z0-9._-]+$"', $keyName)); + trigger_deprecation('api-platform/core', '3.1', \sprintf('The swagger api_keys key "%s" is not valid with OpenAPI 3.1 it should match "^[a-zA-Z0-9._-]+$"', $keyName)); } } @@ -582,7 +582,7 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array // @phpstan-ignore-next-line because PHPStan uses the container of the test env cache and in test the parameter kernel.bundles always contains the key TwigBundle if (!class_exists(Environment::class) || !isset($container->getParameter('kernel.bundles')['TwigBundle'])) { if ($graphiqlEnabled || $graphqlPlayGroundEnabled) { - throw new RuntimeException(sprintf('GraphiQL and GraphQL Playground interfaces depend on Twig. Please activate TwigBundle for the %s environnement or disable GraphiQL and GraphQL Playground.', $container->getParameter('kernel.environment'))); + throw new RuntimeException(\sprintf('GraphiQL and GraphQL Playground interfaces depend on Twig. Please activate TwigBundle for the %s environnement or disable GraphiQL and GraphQL Playground.', $container->getParameter('kernel.environment'))); } $container->removeDefinition('api_platform.graphql.action.graphiql'); $container->removeDefinition('api_platform.graphql.action.graphql_playground'); diff --git a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php index 866ffafb56d..45485824678 100644 --- a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php +++ b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php @@ -58,7 +58,7 @@ private function createFilterDefinitions(\ReflectionClass $resourceReflectionCla } if (null === $filterReflectionClass = $container->getReflectionClass($filterClass, false)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $filterClass, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $filterClass, $id)); } if ($container->has($filterClass) && ($parentDefinition = $container->findDefinition($filterClass))->isAbstract()) { @@ -84,7 +84,7 @@ private function createFilterDefinitions(\ReflectionClass $resourceReflectionCla foreach ($arguments as $key => $value) { if (!isset($parameterNames[$key])) { - throw new InvalidArgumentException(sprintf('Class "%s" does not have argument "$%s".', $filterClass, $key)); + throw new InvalidArgumentException(\sprintf('Class "%s" does not have argument "$%s".', $filterClass, $key)); } $definition->setArgument("$$key", $value); diff --git a/src/Symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php b/src/Symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php index 32199f170ba..05758146726 100644 --- a/src/Symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php +++ b/src/Symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php @@ -106,6 +106,6 @@ private function getPathAndMethod(array $swaggerData): array } } - throw new RuntimeException(sprintf('The operation "%s" cannot be found in the Swagger specification.', $swaggerData['operationId'])); + throw new RuntimeException(\sprintf('The operation "%s" cannot be found in the Swagger specification.', $swaggerData['operationId'])); } } diff --git a/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php b/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php index 4c7ab487b5b..ac6372f0103 100644 --- a/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php +++ b/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php @@ -202,7 +202,7 @@ private static function getHttpClient(?Client $newClient = null): ?Client } if (!$client instanceof Client) { - static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', self::class)); + static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', self::class)); } return $client; diff --git a/src/Symfony/Bundle/Test/ApiTestCase.php b/src/Symfony/Bundle/Test/ApiTestCase.php index 3d409051755..3302b15a58f 100644 --- a/src/Symfony/Bundle/Test/ApiTestCase.php +++ b/src/Symfony/Bundle/Test/ApiTestCase.php @@ -76,7 +76,7 @@ protected function findIriBy(string $resourceClass, array $criteria): ?string || null === $objectManager = $container->get('doctrine_mongodb')->getManagerForClass($resourceClass) ) ) { - throw new \RuntimeException(sprintf('"%s" only supports classes managed by Doctrine ORM or Doctrine MongoDB ODM. Override this method to implement your own retrieval logic if you don\'t use those libraries.', __METHOD__)); + throw new \RuntimeException(\sprintf('"%s" only supports classes managed by Doctrine ORM or Doctrine MongoDB ODM. Override this method to implement your own retrieval logic if you don\'t use those libraries.', __METHOD__)); } $item = $objectManager->getRepository($resourceClass)->findOneBy($criteria); diff --git a/src/Symfony/Bundle/Test/Client.php b/src/Symfony/Bundle/Test/Client.php index 88255a2a370..426c80ab055 100644 --- a/src/Symfony/Bundle/Test/Client.php +++ b/src/Symfony/Bundle/Test/Client.php @@ -89,7 +89,7 @@ public function request(string $method, string $url, array $options = []): Respo // Convert headers to a $_SERVER-like array foreach (self::extractHeaders($options) as $key => $value) { $normalizedHeaderName = strtoupper(str_replace('-', '_', $key)); - $header = \in_array($normalizedHeaderName, ['CONTENT_TYPE', 'REMOTE_ADDR'], true) ? $normalizedHeaderName : sprintf('HTTP_%s', $normalizedHeaderName); + $header = \in_array($normalizedHeaderName, ['CONTENT_TYPE', 'REMOTE_ADDR'], true) ? $normalizedHeaderName : \sprintf('HTTP_%s', $normalizedHeaderName); // BrowserKit doesn't support setting several headers with the same name $server[$header] = $value[0] ?? ''; } diff --git a/src/Symfony/Bundle/Test/Response.php b/src/Symfony/Bundle/Test/Response.php index 29ca0647ff0..3ac943beedf 100644 --- a/src/Symfony/Bundle/Test/Response.php +++ b/src/Symfony/Bundle/Test/Response.php @@ -46,7 +46,7 @@ public function __construct(private readonly HttpFoundationResponse $httpFoundat $responseHeaders = []; foreach ($this->headers as $key => $values) { foreach ($values as $value) { - $responseHeaders[] = sprintf('%s: %s', $key, $value); + $responseHeaders[] = \sprintf('%s: %s', $key, $value); } } @@ -133,7 +133,7 @@ public function toArray(bool $throw = true): array $contentType = $this->headers['content-type'][0] ?? 'application/json'; if (!preg_match('/\bjson\b/i', $contentType)) { - throw new JsonException(sprintf('Response content-type is "%s" while a JSON-compatible one was expected.', $contentType)); + throw new JsonException(\sprintf('Response content-type is "%s" while a JSON-compatible one was expected.', $contentType)); } try { @@ -143,7 +143,7 @@ public function toArray(bool $throw = true): array } if (!\is_array($content)) { - throw new JsonException(sprintf('JSON content was expected to decode to an array, %s returned.', \gettype($content))); + throw new JsonException(\sprintf('JSON content was expected to decode to an array, %s returned.', \gettype($content))); } return $this->jsonData = $content; diff --git a/src/Symfony/Routing/ApiLoader.php b/src/Symfony/Routing/ApiLoader.php index 2a3fefad1d8..f71206cbe51 100644 --- a/src/Symfony/Routing/ApiLoader.php +++ b/src/Symfony/Routing/ApiLoader.php @@ -71,7 +71,7 @@ public function load(mixed $data, ?string $type = null): RouteCollection continue; } - $path = str_replace(sprintf('{%s}', $parameterName), $expandedValue, $path); + $path = str_replace(\sprintf('{%s}', $parameterName), $expandedValue, $path); } // Within Symfony .{_format} is a special parameter but the rfc6570 specifies label expansion with a dot operator @@ -82,7 +82,7 @@ public function load(mixed $data, ?string $type = null): RouteCollection if ($controller = $operation->getController()) { $controllerId = explode('::', $controller, 2)[0]; if (!$this->container->has($controllerId)) { - throw new RuntimeException(sprintf('Operation "%s" is defining an unknown service as controller "%s". Make sure it is properly registered in the dependency injection container.', $operationName, $controllerId)); + throw new RuntimeException(\sprintf('Operation "%s" is defining an unknown service as controller "%s". Make sure it is properly registered in the dependency injection container.', $operationName, $controllerId)); } } diff --git a/src/Symfony/Routing/IriConverter.php b/src/Symfony/Routing/IriConverter.php index 55154a3c0b5..b1bb70a3d09 100644 --- a/src/Symfony/Routing/IriConverter.php +++ b/src/Symfony/Routing/IriConverter.php @@ -66,34 +66,34 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation 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); } $parameters['_api_operation_name'] ??= null; if (!isset($parameters['_api_resource_class'], $parameters['_api_operation_name'])) { - throw new InvalidArgumentException(sprintf('No resource associated to "%s".', $iri)); + throw new InvalidArgumentException(\sprintf('No resource associated to "%s".', $iri)); } // uri_variables come from the Request context and may not be available foreach ($context['uri_variables'] ?? [] as $key => $value) { if (!isset($parameters[$key]) || $parameters[$key] !== (string) $value) { - throw new InvalidArgumentException(sprintf('The iri "%s" does not reference the correct resource.', $iri)); + throw new InvalidArgumentException(\sprintf('The iri "%s" does not reference the correct resource.', $iri)); } } if ($operation && !is_a($parameters['_api_resource_class'], $operation->getClass(), true)) { - throw new InvalidArgumentException(sprintf('The iri "%s" does not reference the correct resource.', $iri)); + throw new InvalidArgumentException(\sprintf('The iri "%s" does not reference the correct resource.', $iri)); } $operation = $parameters['_api_operation'] = $this->resourceMetadataCollectionFactory->create($parameters['_api_resource_class'])->getOperation($parameters['_api_operation_name']); if ($operation instanceof CollectionOperationInterface) { - throw new InvalidArgumentException(sprintf('The iri "%s" references a collection not an item.', $iri)); + throw new InvalidArgumentException(\sprintf('The iri "%s" references a collection not an item.', $iri)); } if (!$operation instanceof HttpOperation) { - throw new RuntimeException(sprintf('The iri "%s" does not reference an HTTP operation.', $iri)); + throw new RuntimeException(\sprintf('The iri "%s" does not reference an HTTP operation.', $iri)); } $attributes = AttributesExtractor::extractAttributes($parameters); @@ -107,7 +107,7 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation return $item; } - throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri)); + throw new ItemNotFoundException(\sprintf('Item not found for "%s".', $iri)); } /** @@ -171,7 +171,7 @@ public function getIriFromResource(object|string $resource, int $referenceType = private function generateSkolemIri(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = [], ?string $resourceClass = null): string { if (!$this->decorated) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass)); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $resourceClass)); } // Use a skolem iri, the route is defined in genid.xml @@ -188,7 +188,7 @@ private function generateSymfonyRoute(object|string $resource, int $referenceTyp } catch (InvalidArgumentException|RuntimeException $e) { // We can try using context uri variables if any if (!$identifiers) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); } } } @@ -198,7 +198,7 @@ private function generateSymfonyRoute(object|string $resource, int $referenceTyp return $this->router->generate($routeName, $identifiers, $operation->getUrlGenerationStrategy() ?? $referenceType); } catch (RoutingExceptionInterface $e) { - throw new InvalidArgumentException(sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e); } } } diff --git a/src/Symfony/Routing/SkolemIriConverter.php b/src/Symfony/Routing/SkolemIriConverter.php index 3bc84955fe9..d8b21061bae 100644 --- a/src/Symfony/Routing/SkolemIriConverter.php +++ b/src/Symfony/Routing/SkolemIriConverter.php @@ -43,7 +43,7 @@ public function __construct(RouterInterface $router) */ public function getResourceFromIri(string $iri, array $context = [], ?Operation $operation = null): object { - throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri)); + throw new ItemNotFoundException(\sprintf('Item not found for "%s".', $iri)); } /** diff --git a/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php b/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php index 7ae44319567..feb2238a900 100644 --- a/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php +++ b/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php @@ -26,7 +26,7 @@ final class ExpressionLanguageProvider implements ExpressionFunctionProviderInte public function getFunctions(): array { return [ - new ExpressionFunction('is_granted', static fn ($attributes, $object = 'null'): string => sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), static fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)), + new ExpressionFunction('is_granted', static fn ($attributes, $object = 'null'): string => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), static fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)), ]; } } diff --git a/src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index 25db47b4df3..a33e121c6f5 100644 --- a/src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -140,7 +140,7 @@ protected function setUp(): void private function assertContainerHas(array $services, array $aliases = []): void { foreach ($services as $service) { - $this->assertTrue($this->container->hasDefinition($service), sprintf('Definition "%s" not found.', $service)); + $this->assertTrue($this->container->hasDefinition($service), \sprintf('Definition "%s" not found.', $service)); } foreach ($aliases as $alias) { @@ -150,12 +150,12 @@ private function assertContainerHas(array $services, array $aliases = []): void private function assertNotContainerHasService(string $service): void { - $this->assertFalse($this->container->hasDefinition($service), sprintf('Service "%s" found.', $service)); + $this->assertFalse($this->container->hasDefinition($service), \sprintf('Service "%s" found.', $service)); } private function assertContainerHasAlias(string $alias): void { - $this->assertTrue($this->container->hasAlias($alias), sprintf('Alias "%s" not found.', $alias)); + $this->assertTrue($this->container->hasAlias($alias), \sprintf('Alias "%s" not found.', $alias)); } private function assertServiceHasTags(string $service, array $tags = []): void @@ -163,7 +163,7 @@ private function assertServiceHasTags(string $service, array $tags = []): void $serviceTags = $this->container->getDefinition($service)->getTags(); foreach ($tags as $tag) { - $this->assertArrayHasKey($tag, $serviceTags, sprintf('Tag "%s" not found on the service "%s".', $tag, $service)); + $this->assertArrayHasKey($tag, $serviceTags, \sprintf('Tag "%s" not found on the service "%s".', $tag, $service)); } } diff --git a/src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php b/src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php index cfb709151a0..7002226e2be 100644 --- a/src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php +++ b/src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php @@ -101,7 +101,7 @@ public function create(string $resourceClass, string $property, array $options = $validatorClassMetadata = $this->validatorMetadataFactory->getMetadataFor($resourceClass); if (!$validatorClassMetadata instanceof ValidatorClassMetadataInterface) { - throw new \UnexpectedValueException(sprintf('Validator class metadata expected to be of type "%s".', ValidatorClassMetadataInterface::class)); + throw new \UnexpectedValueException(\sprintf('Validator class metadata expected to be of type "%s".', ValidatorClassMetadataInterface::class)); } $validationGroups = $this->getValidationGroups($validatorClassMetadata, $options); @@ -156,7 +156,7 @@ private function getValidationGroups(ValidatorClassMetadataInterface $classMetad } if (!method_exists($classMetadata, 'getDefaultGroup')) { - throw new \UnexpectedValueException(sprintf('Validator class metadata expected to have method "%s".', 'getDefaultGroup')); + throw new \UnexpectedValueException(\sprintf('Validator class metadata expected to have method "%s".', 'getDefaultGroup')); } return [$classMetadata->getDefaultGroup()]; diff --git a/src/Validator/Exception/ValidationException.php b/src/Validator/Exception/ValidationException.php index 8dad5009b23..315dcde3abf 100644 --- a/src/Validator/Exception/ValidationException.php +++ b/src/Validator/Exception/ValidationException.php @@ -78,7 +78,7 @@ public function __construct(string|ConstraintViolationListInterface $message = ' return; } - trigger_deprecation('api_platform/core', '3.3', sprintf('The "%s" exception will have a "%s" first argument in 4.x.', self::class, ConstraintViolationListInterface::class)); + trigger_deprecation('api_platform/core', '3.3', \sprintf('The "%s" exception will have a "%s" first argument in 4.x.', self::class, ConstraintViolationListInterface::class)); parent::__construct($message ?: $this->__toString(), $code ?? 0, $previous); } diff --git a/tests/Behat/DoctrineContext.php b/tests/Behat/DoctrineContext.php index 90c9d183dcf..899a224e8e2 100644 --- a/tests/Behat/DoctrineContext.php +++ b/tests/Behat/DoctrineContext.php @@ -895,7 +895,7 @@ public function thereAreDummyObjectsWithDummyDate(int $nb): void $descriptions = ['Smart dummy.', 'Not so smart dummy.']; for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummy(); $dummy->setName('Dummy #'.$i); @@ -926,11 +926,11 @@ public function thereAreDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string $bool = false; } else { $expected = ['true', 'false', '1', '0']; - throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); + throw new \InvalidArgumentException(\sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); } for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummy(); $dummy->setName('Dummy #'.$i); @@ -955,7 +955,7 @@ public function thereAreDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string public function thereAreDummyObjectsWithDummyDateAndRelatedDummy(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $relatedDummy = $this->buildRelatedDummy(); $relatedDummy->setName('RelatedDummy #'.$i); @@ -983,7 +983,7 @@ public function thereAreDummyObjectsWithDummyDateAndRelatedDummy(int $nb): void public function thereAreDummyObjectsWithDummyDateAndEmbeddedDummy(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $embeddableDummy = $this->buildEmbeddableDummy(); $embeddableDummy->setDummyName('Embeddable #'.$i); @@ -1010,7 +1010,7 @@ public function thereAreconvertedDateObjectsWith(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { $convertedDate = $this->buildConvertedDate(); - $convertedDate->nameConverted = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $convertedDate->nameConverted = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $this->manager->persist($convertedDate); } @@ -1096,7 +1096,7 @@ public function thereAreDummyObjectsWithDummyBoolean(int $nb, string $bool): voi $bool = false; } else { $expected = ['true', 'false', '1', '0']; - throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); + throw new \InvalidArgumentException(\sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); } $descriptions = ['Smart dummy.', 'Not so smart dummy.']; @@ -1124,7 +1124,7 @@ public function thereAreDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bo $bool = false; } else { $expected = ['true', 'false', '1', '0']; - throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); + throw new \InvalidArgumentException(\sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); } for ($i = 1; $i <= $nb; ++$i) { @@ -1151,7 +1151,7 @@ public function thereAreDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, st $bool = false; } else { $expected = ['true', 'false', '1', '0']; - throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); + throw new \InvalidArgumentException(\sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected))); } for ($i = 1; $i <= $nb; ++$i) { @@ -1473,7 +1473,7 @@ public function thereArePrograms(int $nb): void for ($i = $count + 1; $i <= $nb; ++$i) { $program = $this->isOrm() ? new Program() : new ProgramDocument(); $program->name = "Lorem ipsum $i"; - $program->date = new \DateTimeImmutable(sprintf('2015-03-0%dT10:00:00+00:00', $i)); + $program->date = new \DateTimeImmutable(\sprintf('2015-03-0%dT10:00:00+00:00', $i)); $program->author = $author; $this->manager->persist($program); @@ -1521,7 +1521,7 @@ public function thereAreComments(int $nb): void for ($i = $count + 1; $i <= $nb; ++$i) { $comment = $this->isOrm() ? new Comment() : new CommentDocument(); $comment->comment = "Lorem ipsum dolor sit amet $i"; - $comment->date = new \DateTimeImmutable(sprintf('2015-03-0%dT10:00:00+00:00', $i)); + $comment->date = new \DateTimeImmutable(\sprintf('2015-03-0%dT10:00:00+00:00', $i)); $comment->author = $author; $this->manager->persist($comment); @@ -1607,7 +1607,7 @@ public function createPeopleWithPets(): void public function thereAreDummyDateObjectsWithDummyDate(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummyDate(); $dummy->dummyDate = $date; @@ -1625,7 +1625,7 @@ public function thereAreDummyDateObjectsWithDummyDate(int $nb): void public function thereAreDummyDateObjectsWithNullableDateIncludeNullAfter(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummyDate(); $dummy->dummyDate = $date; @@ -1644,7 +1644,7 @@ public function thereAreDummyDateObjectsWithNullableDateIncludeNullAfter(int $nb public function thereAreDummyDateObjectsWithNullableDateIncludeNullBefore(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummyDate(); $dummy->dummyDate = $date; @@ -1663,7 +1663,7 @@ public function thereAreDummyDateObjectsWithNullableDateIncludeNullBefore(int $n public function thereAreDummyDateObjectsWithNullableDateIncludeNullBeforeAndAfter(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTime(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummyDate(); $dummy->dummyDate = $date; @@ -1681,7 +1681,7 @@ public function thereAreDummyDateObjectsWithNullableDateIncludeNullBeforeAndAfte public function thereAreDummyImmutableDateObjectsWithDummyDate(int $nb): void { for ($i = 1; $i <= $nb; ++$i) { - $date = new \DateTimeImmutable(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); + $date = new \DateTimeImmutable(\sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = $this->buildDummyImmutableDate(); $dummy->dummyDate = $date; diff --git a/tests/Behat/GraphqlContext.php b/tests/Behat/GraphqlContext.php index 4d02b8c9345..ca644baaff9 100644 --- a/tests/Behat/GraphqlContext.php +++ b/tests/Behat/GraphqlContext.php @@ -154,7 +154,7 @@ public function theGraphQLFieldIsDeprecatedForTheReason(string $fieldName, strin } } - throw new ExpectationFailedException(sprintf('The field "%s" is not deprecated.', $fieldName)); + throw new ExpectationFailedException(\sprintf('The field "%s" is not deprecated.', $fieldName)); } /** diff --git a/tests/Behat/HttpCacheContext.php b/tests/Behat/HttpCacheContext.php index 31dbd8ff341..0a70a5eea12 100644 --- a/tests/Behat/HttpCacheContext.php +++ b/tests/Behat/HttpCacheContext.php @@ -55,7 +55,7 @@ public function irisShouldBePurged(string $iris): void $purger->clear(); if ($iris !== $purgedIris) { - throw new ExpectationFailedException(sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris)); + throw new ExpectationFailedException(\sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris)); } } diff --git a/tests/Behat/HydraContext.php b/tests/Behat/HydraContext.php index bb84cffd466..1a208159690 100644 --- a/tests/Behat/HydraContext.php +++ b/tests/Behat/HydraContext.php @@ -55,7 +55,7 @@ public function assertTheHydraClassExist(string $className): void try { $this->getClassInfo($className); } catch (\InvalidArgumentException $e) { - throw new ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e); + throw new ExpectationFailedException(\sprintf('The class "%s" doesn\'t exist.', $className), null, $e); } } @@ -70,7 +70,7 @@ public function assertTheHydraClassNotExist(string $className): void return; } - throw new ExpectationFailedException(sprintf('The class "%s" exists.', $className)); + throw new ExpectationFailedException(\sprintf('The class "%s" exists.', $className)); } /** @@ -167,7 +167,7 @@ public function assertPropertyNotExist(string $propertyName, string $className): return; } - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" exists.', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" exists.', $propertyName, $className)); } /** @@ -176,7 +176,7 @@ public function assertPropertyNotExist(string $propertyName, string $className): public function assertPropertyIsReadable(string $propertyName, string $className): void { if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:readable'}) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not readable', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" is not readable', $propertyName, $className)); } } @@ -186,7 +186,7 @@ public function assertPropertyIsReadable(string $propertyName, string $className public function assertPropertyIsNotReadable(string $propertyName, string $className): void { if ($this->getPropertyInfo($propertyName, $className)->{'hydra:readable'}) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is readable', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" is readable', $propertyName, $className)); } } @@ -196,7 +196,7 @@ public function assertPropertyIsNotReadable(string $propertyName, string $classN public function assertPropertyIsWritable(string $propertyName, string $className): void { if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:writeable'}) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not writable', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" is not writable', $propertyName, $className)); } } @@ -206,7 +206,7 @@ public function assertPropertyIsWritable(string $propertyName, string $className public function assertPropertyIsRequired(string $propertyName, string $className): void { if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:required'}) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not required', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" is not required', $propertyName, $className)); } } @@ -216,7 +216,7 @@ public function assertPropertyIsRequired(string $propertyName, string $className public function assertPropertyIsNotRequired(string $propertyName, string $className): void { if ($this->getPropertyInfo($propertyName, $className)->{'hydra:required'}) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is required', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" is required', $propertyName, $className)); } } @@ -233,7 +233,7 @@ private function getPropertyInfo(string $propertyName, string $className): \stdC } } - throw new \InvalidArgumentException(sprintf('Property "%s" of class "%s" doesn\'t exist', $propertyName, $className)); + throw new \InvalidArgumentException(\sprintf('Property "%s" of class "%s" doesn\'t exist', $propertyName, $className)); } /** @@ -249,7 +249,7 @@ private function getOperation(string $method, string $className): \stdClass } } - throw new \InvalidArgumentException(sprintf('Operation "%s" of class "%s" doesn\'t exist.', $method, $className)); + throw new \InvalidArgumentException(\sprintf('Operation "%s" of class "%s" doesn\'t exist.', $method, $className)); } /** @@ -285,7 +285,7 @@ private function getClassInfo(string $className): \stdClass } } - throw new \InvalidArgumentException(sprintf('Class %s cannot be found in the vocabulary', $className)); + throw new \InvalidArgumentException(\sprintf('Class %s cannot be found in the vocabulary', $className)); } /** diff --git a/tests/Behat/JsonApiContext.php b/tests/Behat/JsonApiContext.php index 8037f06efda..3d95b2fba03 100644 --- a/tests/Behat/JsonApiContext.php +++ b/tests/Behat/JsonApiContext.php @@ -89,7 +89,7 @@ public function theJsonNodeShouldBeAnEmptyArray(string $node): void { $actual = $this->getValueOfNode($node); if (null !== $actual && [] !== $actual) { - throw new ExpectationFailedException(sprintf('The node value is `%s`', json_encode($actual, \JSON_THROW_ON_ERROR))); + throw new ExpectationFailedException(\sprintf('The node value is `%s`', json_encode($actual, \JSON_THROW_ON_ERROR))); } } @@ -99,7 +99,7 @@ public function theJsonNodeShouldBeAnEmptyArray(string $node): void public function theJsonNodeShouldBeANumber(string $node): void { if (!is_numeric($actual = $this->getValueOfNode($node))) { - throw new ExpectationFailedException(sprintf('The node value is `%s`', json_encode($actual, \JSON_THROW_ON_ERROR))); + throw new ExpectationFailedException(\sprintf('The node value is `%s`', json_encode($actual, \JSON_THROW_ON_ERROR))); } } @@ -109,7 +109,7 @@ public function theJsonNodeShouldBeANumber(string $node): void public function theJsonNodeShouldNotBeAnEmptyString(string $node): void { if ('' === $actual = $this->getValueOfNode($node)) { - throw new ExpectationFailedException(sprintf('The node value is `%s`', json_encode($actual))); + throw new ExpectationFailedException(\sprintf('The node value is `%s`', json_encode($actual))); } } @@ -122,14 +122,14 @@ public function theJsonNodeShouldBeSorted(string $node = ''): void $actual = (array) $this->getValueOfNode($node); if (!\is_array($actual)) { - throw new \Exception(sprintf('The "%s" node value is not an array', $node)); + throw new \Exception(\sprintf('The "%s" node value is not an array', $node)); } $expected = $actual; ksort($expected); if ($actual !== $expected) { - throw new ExpectationFailedException(sprintf('The json node "%s" is not sorted by keys', $node)); + throw new ExpectationFailedException(\sprintf('The json node "%s" is not sorted by keys', $node)); } } diff --git a/tests/Behat/JsonContext.php b/tests/Behat/JsonContext.php index 4a9ca3e1ce1..4450465fd08 100644 --- a/tests/Behat/JsonContext.php +++ b/tests/Behat/JsonContext.php @@ -44,7 +44,7 @@ public function theJsonNodeShouldContainContent(string $node, PyStringNode $cont $actualContent = $this->inspector->evaluate($actual, $node); if (!is_iterable($actualContent)) { - throw new ExpectationException(sprintf("The JSON is equal to:\n%s", json_encode($actualContent, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRETTY_PRINT)), $this->getSession()->getDriver()); + throw new ExpectationException(\sprintf("The JSON is equal to:\n%s", json_encode($actualContent, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRETTY_PRINT)), $this->getSession()->getDriver()); } foreach ($actualContent as $itemContent) { @@ -78,7 +78,7 @@ public function theJsonNodeShouldBeEqualToContent(string $node, PyStringNode $co $this->assertEquals( $expected->getContent(), $actualContent, - sprintf("The JSON node \"%s\" is equal to:\n%s", $node, json_encode($actualContent, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRETTY_PRINT)) + \sprintf("The JSON node \"%s\" is equal to:\n%s", $node, json_encode($actualContent, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRETTY_PRINT)) ); } diff --git a/tests/Behat/MercureContext.php b/tests/Behat/MercureContext.php index 6fd50e0ec4f..2dbd68f8775 100644 --- a/tests/Behat/MercureContext.php +++ b/tests/Behat/MercureContext.php @@ -45,7 +45,7 @@ public function mercureUpdatesShouldHaveBeenSent(int $number): void throw new \RuntimeException('No Mercure update has been sent.'); } - Assert::assertEquals($number, $total, sprintf('Expected %d Mercure updates to be sent, got %d.', $number, $total)); + Assert::assertEquals($number, $total, \sprintf('Expected %d Mercure updates to be sent, got %d.', $number, $total)); } /** @@ -79,7 +79,7 @@ public function mercureUpdateShouldHaveTopics(int $index, TableNode $table): voi } if (!isset($updates[$index - 1])) { - throw new \RuntimeException(sprintf('Mercure update #%d does not exist.', $index)); + throw new \RuntimeException(\sprintf('Mercure update #%d does not exist.', $index)); } /** @var Update $update */ $update = $updates[$index - 1]; @@ -99,7 +99,7 @@ public function mercureUpdateShouldHaveData(int $index, PyStringNode $data): voi } if (!isset($updates[$index - 1])) { - throw new \RuntimeException(sprintf('Mercure update #%d does not exist.', $index)); + throw new \RuntimeException(\sprintf('Mercure update #%d does not exist.', $index)); } /** @var Update $update */ $update = $updates[$index - 1]; diff --git a/tests/Behat/OpenApiContext.php b/tests/Behat/OpenApiContext.php index c651149e3ff..7b3fbf73ed4 100644 --- a/tests/Behat/OpenApiContext.php +++ b/tests/Behat/OpenApiContext.php @@ -52,7 +52,7 @@ public function assertTheOpenApiClassExist(string $className): void try { $this->getClassInfo($className); } catch (\InvalidArgumentException $e) { - throw new ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e); + throw new ExpectationFailedException(\sprintf('The class "%s" doesn\'t exist.', $className), null, $e); } } @@ -67,7 +67,7 @@ public function assertTheOpenAPIClassNotExist(string $className): void return; } - throw new ExpectationFailedException(sprintf('The class "%s" exists.', $className)); + throw new ExpectationFailedException(\sprintf('The class "%s" exists.', $className)); } /** @@ -88,7 +88,7 @@ public function assertThePropertyExistForTheOpenApiClass(string $propertyName, s try { $this->getPropertyInfo($propertyName, $className); } catch (\InvalidArgumentException $e) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" doesn\'t exist.', $propertyName, $className), null, $e); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" doesn\'t exist.', $propertyName, $className), null, $e); } } @@ -98,7 +98,7 @@ public function assertThePropertyExistForTheOpenApiClass(string $propertyName, s public function assertThePropertyIsRequiredForTheOpenAPIClass(string $propertyName, string $className): void { if (!\in_array($propertyName, $this->getClassInfo($className)->required, true)) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" should be required', $propertyName, $className)); } } @@ -109,7 +109,7 @@ public function assertThePropertyIsNotReadOnlyForTheOpenAPIClass(string $propert { $propertyInfo = $this->getPropertyInfo($propertyName, $className); if (property_exists($propertyInfo, 'readOnly') && $propertyInfo->readOnly) { - throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" should not be read only', $propertyName, $className)); + throw new ExpectationFailedException(\sprintf('Property "%s" of class "%s" should not be read only', $propertyName, $className)); } } @@ -122,7 +122,7 @@ public function assertThePropertyForTheOpenAPIClassShouldBeEqualTo(string $prope $propertyInfoJson = new Json(json_encode($propertyInfo)); if (new Json($propertyContent) != $propertyInfoJson) { - throw new ExpectationFailedException(sprintf("Property \"%s\" of class \"%s\" is '%s'", $propertyName, $className, $propertyInfoJson)); + throw new ExpectationFailedException(\sprintf("Property \"%s\" of class \"%s\" is '%s'", $propertyName, $className, $propertyInfoJson)); } } @@ -141,7 +141,7 @@ private function getPropertyInfo(string $propertyName, string $className): \stdC } } - throw new \InvalidArgumentException(sprintf('The property "%s" for the class "%s" doesn\'t exist.', $propertyName, $className)); + throw new \InvalidArgumentException(\sprintf('The property "%s" for the class "%s" doesn\'t exist.', $propertyName, $className)); } /** @@ -166,7 +166,7 @@ private function getClassInfo(string $className): \stdClass } } - throw new \InvalidArgumentException(sprintf('Class %s cannot be found in the vocabulary', $className)); + throw new \InvalidArgumentException(\sprintf('Class %s cannot be found in the vocabulary', $className)); } /** diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue5648/CustomFilter.php b/tests/Fixtures/TestBundle/ApiResource/Issue5648/CustomFilter.php index ec914a66b4f..87ae28ed3ce 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue5648/CustomFilter.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue5648/CustomFilter.php @@ -30,9 +30,9 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB $alias = $queryBuilder->getRootAliases()[0]; $secondAlias = $queryNameGenerator->generateJoinAlias('relatedDummies'); - $joinCondition = $queryBuilder->expr()->like(sprintf('%s.name', $secondAlias), ':param'); + $joinCondition = $queryBuilder->expr()->like(\sprintf('%s.name', $secondAlias), ':param'); - $queryBuilder->join(sprintf('%s.relatedDummies', $alias), $secondAlias, Join::WITH, $joinCondition) + $queryBuilder->join(\sprintf('%s.relatedDummies', $alias), $secondAlias, Join::WITH, $joinCondition) ->setParameter('param', '%'.$value.'%') ->andWhere('1=1'); // problem only gets triggered when there is a where part. } diff --git a/tests/Fixtures/TestBundle/Controller/CustomController.php b/tests/Fixtures/TestBundle/Controller/CustomController.php index 37f094af3fb..6222d315f0b 100644 --- a/tests/Fixtures/TestBundle/Controller/CustomController.php +++ b/tests/Fixtures/TestBundle/Controller/CustomController.php @@ -25,6 +25,6 @@ class CustomController extends AbstractController { public function customAction(int $id): JsonResponse { - return new JsonResponse(sprintf('This is a custom action for %d.', $id), 200, ['Content-Type' => 'application/ld+json; charset=utf-8']); + return new JsonResponse(\sprintf('This is a custom action for %d.', $id), 200, ['Content-Type' => 'application/ld+json; charset=utf-8']); } } diff --git a/tests/Fixtures/TestBundle/Document/Content.php b/tests/Fixtures/TestBundle/Document/Content.php index 5327513dc8c..7a8d1b242ef 100644 --- a/tests/Fixtures/TestBundle/Document/Content.php +++ b/tests/Fixtures/TestBundle/Document/Content.php @@ -74,7 +74,7 @@ public function hasField(string $fieldName): bool public function addField(Field $field): void { if ($this->hasField($field->getName())) { - throw new \InvalidArgumentException(sprintf("Content already has '%s' field", $field->getName())); + throw new \InvalidArgumentException(\sprintf("Content already has '%s' field", $field->getName())); } $this->fields[$field->getName()] = $field; $field->setContent($this); diff --git a/tests/Fixtures/TestBundle/Document/Product.php b/tests/Fixtures/TestBundle/Document/Product.php index 82416485676..ac10d37a5cc 100644 --- a/tests/Fixtures/TestBundle/Document/Product.php +++ b/tests/Fixtures/TestBundle/Document/Product.php @@ -65,7 +65,7 @@ public function getMainTaxon(): ?TaxonInterface public function setMainTaxon(?TaxonInterface $mainTaxon): void { if (!$mainTaxon instanceof Taxon) { - throw new \InvalidArgumentException(sprintf('$mainTaxon must be of type "%s".', Taxon::class)); + throw new \InvalidArgumentException(\sprintf('$mainTaxon must be of type "%s".', Taxon::class)); } $this->mainTaxon = $mainTaxon; diff --git a/tests/Fixtures/TestBundle/Entity/Content.php b/tests/Fixtures/TestBundle/Entity/Content.php index 4b2142a8989..e76c089f518 100644 --- a/tests/Fixtures/TestBundle/Entity/Content.php +++ b/tests/Fixtures/TestBundle/Entity/Content.php @@ -78,7 +78,7 @@ public function hasField(string $fieldName): bool public function addField(Field $field): void { if ($this->hasField($field->getName())) { - throw new \InvalidArgumentException(sprintf("Content already has '%s' field", $field->getName())); + throw new \InvalidArgumentException(\sprintf("Content already has '%s' field", $field->getName())); } $this->fields[$field->getName()] = $field; $field->setContent($this); diff --git a/tests/Fixtures/TestBundle/Entity/Product.php b/tests/Fixtures/TestBundle/Entity/Product.php index 7d7300ee89b..3d3ef3135ce 100644 --- a/tests/Fixtures/TestBundle/Entity/Product.php +++ b/tests/Fixtures/TestBundle/Entity/Product.php @@ -67,7 +67,7 @@ public function getMainTaxon(): ?TaxonInterface public function setMainTaxon(?TaxonInterface $mainTaxon): void { if (!$mainTaxon instanceof Taxon) { - throw new \InvalidArgumentException(sprintf('$mainTaxon must be of type "%s".', Taxon::class)); + throw new \InvalidArgumentException(\sprintf('$mainTaxon must be of type "%s".', Taxon::class)); } $this->mainTaxon = $mainTaxon; diff --git a/tests/Fixtures/TestBundle/GraphQl/Type/Definition/DateTimeType.php b/tests/Fixtures/TestBundle/GraphQl/Type/Definition/DateTimeType.php index 0ac31b05708..27f7dc6f6b7 100644 --- a/tests/Fixtures/TestBundle/GraphQl/Type/Definition/DateTimeType.php +++ b/tests/Fixtures/TestBundle/GraphQl/Type/Definition/DateTimeType.php @@ -52,7 +52,7 @@ public function serialize($value): string } if (!($value instanceof \DateTime)) { - throw new Error(sprintf('Value must be an instance of DateTime to be represented by DateTime: %s', Utils::printSafe($value))); + throw new Error(\sprintf('Value must be an instance of DateTime to be represented by DateTime: %s', Utils::printSafe($value))); } return $value->format(\DateTime::ATOM); @@ -64,11 +64,11 @@ public function serialize($value): string public function parseValue($value): string { if (!\is_string($value)) { - throw new Error(sprintf('DateTime cannot represent non string value: %s', Utils::printSafeJson($value))); + throw new Error(\sprintf('DateTime cannot represent non string value: %s', Utils::printSafeJson($value))); } if (false === \DateTime::createFromFormat(\DateTime::ATOM, $value)) { - throw new Error(sprintf('DateTime cannot represent non date value: %s', Utils::printSafeJson($value))); + throw new Error(\sprintf('DateTime cannot represent non date value: %s', Utils::printSafeJson($value))); } // Will be denormalized into a \DateTime. diff --git a/tests/Fixtures/app/AppKernel.php b/tests/Fixtures/app/AppKernel.php index ab539644f84..5afd01a7a9e 100644 --- a/tests/Fixtures/app/AppKernel.php +++ b/tests/Fixtures/app/AppKernel.php @@ -69,7 +69,7 @@ public function registerBundles(): array new WebProfilerBundle(), new FrameworkBundle(), new MakerBundle(), - new class() extends Bundle { + new class extends Bundle { public function shutdown(): void { restore_exception_handler(); @@ -303,7 +303,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [ protected function build(ContainerBuilder $container): void { - $container->addCompilerPass(new class() implements CompilerPassInterface { + $container->addCompilerPass(new class implements CompilerPassInterface { public function process(ContainerBuilder $container): void { if ($container->hasDefinition(TailCursorDoctrineODMCommand::class)) { // @phpstan-ignore-line diff --git a/tests/Functional/Parameters/DoctrineTest.php b/tests/Functional/Parameters/DoctrineTest.php index a0f7541b1c6..3d1b577d5bf 100644 --- a/tests/Functional/Parameters/DoctrineTest.php +++ b/tests/Functional/Parameters/DoctrineTest.php @@ -45,7 +45,7 @@ public function testDoctrineEntitySearchFilter(): void $this->assertEquals('bar', $a['hydra:member'][1]['foo']); $this->assertArraySubset(['hydra:search' => [ - 'hydra:template' => sprintf('/%s{?foo,order[order[id]],order[order[foo]],searchPartial[foo],searchExact[foo],searchOnTextAndDate[foo],searchOnTextAndDate[createdAt][before],searchOnTextAndDate[createdAt][strictly_before],searchOnTextAndDate[createdAt][after],searchOnTextAndDate[createdAt][strictly_after],q}', $route), + 'hydra:template' => \sprintf('/%s{?foo,order[order[id]],order[order[foo]],searchPartial[foo],searchExact[foo],searchOnTextAndDate[foo],searchOnTextAndDate[createdAt][before],searchOnTextAndDate[createdAt][strictly_before],searchOnTextAndDate[createdAt][after],searchOnTextAndDate[createdAt][strictly_after],q}', $route), 'hydra:mapping' => [ ['@type' => 'IriTemplateMapping', 'variable' => 'foo', 'property' => 'foo'], ], @@ -73,22 +73,22 @@ public function testGraphQl(): void $this->loadFixtures($this->isMongoDB() ? SearchFilterParameterDocument::class : SearchFilterParameter::class); $object = 'searchFilterParameters'; $response = self::createClient()->request('POST', '/graphql', ['json' => [ - 'query' => sprintf('{ %s(foo: "bar") { edges { node { id foo createdAt } } } }', $object), + 'query' => \sprintf('{ %s(foo: "bar") { edges { node { id foo createdAt } } } }', $object), ]]); $this->assertEquals('bar', $response->toArray()['data'][$object]['edges'][0]['node']['foo']); $response = self::createClient()->request('POST', '/graphql', ['json' => [ - 'query' => sprintf('{ %s(searchPartial: {foo: "az"}) { edges { node { id foo createdAt } } } }', $object), + 'query' => \sprintf('{ %s(searchPartial: {foo: "az"}) { edges { node { id foo createdAt } } } }', $object), ]]); $this->assertEquals('baz', $response->toArray()['data'][$object]['edges'][0]['node']['foo']); $response = self::createClient()->request('POST', '/graphql', ['json' => [ - 'query' => sprintf('{ %s(searchExact: {foo: "baz"}) { edges { node { id foo createdAt } } } }', $object), + 'query' => \sprintf('{ %s(searchExact: {foo: "baz"}) { edges { node { id foo createdAt } } } }', $object), ]]); $this->assertEquals('baz', $response->toArray()['data'][$object]['edges'][0]['node']['foo']); $response = self::createClient()->request('POST', '/graphql', ['json' => [ - 'query' => sprintf('{ %s(searchOnTextAndDate: {foo: "bar", createdAt: {before: "2024-01-21"}}) { edges { node { id foo createdAt } } } }', $object), + 'query' => \sprintf('{ %s(searchOnTextAndDate: {foo: "bar", createdAt: {before: "2024-01-21"}}) { edges { node { id foo createdAt } } } }', $object), ]]); $this->assertArraySubset(['foo' => 'bar', 'createdAt' => '2024-01-21T00:00:00+00:00'], $response->toArray()['data'][$object]['edges'][0]['node']); } diff --git a/tests/Functional/Parameters/SecurityTest.php b/tests/Functional/Parameters/SecurityTest.php index 4aee454f263..0bb29dea66d 100644 --- a/tests/Functional/Parameters/SecurityTest.php +++ b/tests/Functional/Parameters/SecurityTest.php @@ -76,7 +76,7 @@ public function testSecurityHeaderValues(string $parameterValue, int $expectedSt #[\PHPUnit\Framework\Attributes\DataProvider('dataSecurityValues')] public function testSecurityQueryValues(string $parameterValue, int $expectedStatusCode): void { - self::createClient()->request('GET', sprintf('with_security_parameters_collection?secret=%s', $parameterValue)); + self::createClient()->request('GET', \sprintf('with_security_parameters_collection?secret=%s', $parameterValue)); $this->assertResponseStatusCodeSame($expectedStatusCode); } } diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPassTest.php index 0d66d1e75c3..cbbb8b23081 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPassTest.php @@ -60,7 +60,7 @@ public function testProcess(): void public function testProcessInvalidFilterClass(): void { $this->expectException(DependencyInjectionInvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Class "%s" used for service "annotated_api_platform_tests_fixtures_test_bundle_entity_converted_boolean_api_platform_doctrine_orm_filter_boolean_filter" cannot be found.', BooleanFilter::class)); + $this->expectExceptionMessage(\sprintf('Class "%s" used for service "annotated_api_platform_tests_fixtures_test_bundle_entity_converted_boolean_api_platform_doctrine_orm_filter_boolean_filter" cannot be found.', BooleanFilter::class)); $containerBuilderProphecy = $this->prophesize(ContainerBuilder::class); $containerBuilderProphecy->getParameter('api_platform.resource_class_directories')->willReturn([ diff --git a/tests/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php b/tests/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php index f37d5e8ca71..f7dfaa0a24c 100644 --- a/tests/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php +++ b/tests/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php @@ -82,7 +82,7 @@ public function testEvaluateFailMessage(): void try { $constraint->evaluate(['baz' => 'bar'], '', false); - $this->fail(sprintf('Expected %s to be thrown.', ExpectationFailedException::class)); + $this->fail(\sprintf('Expected %s to be thrown.', ExpectationFailedException::class)); } catch (ExpectationFailedException $expectedException) { $comparisonFailure = $expectedException->getComparisonFailure(); $this->assertNotNull($comparisonFailure); @@ -97,7 +97,7 @@ public function testIsCountable(): void $this->assertTrue( $reflection->implementsInterface(\Countable::class), - sprintf( + \sprintf( 'Failed to assert that ArraySubset implements "%s".', \Countable::class ) @@ -110,7 +110,7 @@ public function testIsSelfDescribing(): void $this->assertTrue( $reflection->implementsInterface(SelfDescribing::class), - sprintf( + \sprintf( 'Failed to assert that Array implements "%s".', SelfDescribing::class ) diff --git a/tests/Symfony/Bundle/Test/Constraint/MatchesJsonSchemaTest.php b/tests/Symfony/Bundle/Test/Constraint/MatchesJsonSchemaTest.php index d6381cb5025..48cb8fe3e2e 100644 --- a/tests/Symfony/Bundle/Test/Constraint/MatchesJsonSchemaTest.php +++ b/tests/Symfony/Bundle/Test/Constraint/MatchesJsonSchemaTest.php @@ -31,7 +31,7 @@ public function testAdditionalFailureDescription(): void try { $constraint->evaluate(['foo' => 'bar']); - $this->fail(sprintf('Expected %s to be thrown.', ExpectationFailedException::class)); + $this->fail(\sprintf('Expected %s to be thrown.', ExpectationFailedException::class)); } catch (ExpectationFailedException $expectedException) { $this->assertStringContainsString('notexist: The property notexist is required', $expectedException->getMessage()); } diff --git a/tests/Symfony/Maker/MakeStateProcessorTest.php b/tests/Symfony/Maker/MakeStateProcessorTest.php index 20e3e11742e..b88cbbce43c 100644 --- a/tests/Symfony/Maker/MakeStateProcessorTest.php +++ b/tests/Symfony/Maker/MakeStateProcessorTest.php @@ -74,6 +74,6 @@ private static function tempDir(): string private static function tempFile(string $path): string { - return sprintf('%s/%s', self::tempDir(), $path); + return \sprintf('%s/%s', self::tempDir(), $path); } } diff --git a/tests/Symfony/Maker/MakeStateProviderTest.php b/tests/Symfony/Maker/MakeStateProviderTest.php index 6497870ce94..101dc080082 100644 --- a/tests/Symfony/Maker/MakeStateProviderTest.php +++ b/tests/Symfony/Maker/MakeStateProviderTest.php @@ -74,6 +74,6 @@ private static function tempDir(): string private static function tempFile(string $path): string { - return sprintf('%s/%s', self::tempDir(), $path); + return \sprintf('%s/%s', self::tempDir(), $path); } } diff --git a/tests/Symfony/Routing/IriConverterTest.php b/tests/Symfony/Routing/IriConverterTest.php index f6aad1909e5..41d860718b5 100644 --- a/tests/Symfony/Routing/IriConverterTest.php +++ b/tests/Symfony/Routing/IriConverterTest.php @@ -112,7 +112,7 @@ public function testGetIriFromItemWithContextOperation(): void public function testGetIriFromItemWithNoOperations(): void { - $this->expectExceptionMessage(sprintf('Unable to generate an IRI for the item of type "%s"', Dummy::class)); + $this->expectExceptionMessage(\sprintf('Unable to generate an IRI for the item of type "%s"', Dummy::class)); $item = new Dummy(); $item->setId(1); @@ -131,7 +131,7 @@ public function testGetIriFromItemWithNoOperations(): void public function testGetIriFromItemWithBadIdentifiers(): void { - $this->expectExceptionMessage(sprintf('Unable to generate an IRI for the item of type "%s"', Dummy::class)); + $this->expectExceptionMessage(\sprintf('Unable to generate an IRI for the item of type "%s"', Dummy::class)); $item = new Dummy(); $item->setId(1); diff --git a/tests/Symfony/Validator/ValidatorTest.php b/tests/Symfony/Validator/ValidatorTest.php index 3e557c2ec03..c678469a66e 100644 --- a/tests/Symfony/Validator/ValidatorTest.php +++ b/tests/Symfony/Validator/ValidatorTest.php @@ -90,7 +90,7 @@ public function testValidateGetGroupsFromService(): void $containerProphecy = $this->prophesize(ContainerInterface::class); $containerProphecy->has('groups_builder')->willReturn(true); - $containerProphecy->get('groups_builder')->willReturn(new class() implements ValidationGroupsGeneratorInterface { + $containerProphecy->get('groups_builder')->willReturn(new class implements ValidationGroupsGeneratorInterface { public function __invoke(object $object): array { return $object instanceof DummyEntity ? ['a', 'b', 'c'] : []; diff --git a/tests/WithResourcesTrait.php b/tests/WithResourcesTrait.php index 519c2d7dd1f..1b4b8756e29 100644 --- a/tests/WithResourcesTrait.php +++ b/tests/WithResourcesTrait.php @@ -20,7 +20,7 @@ trait WithResourcesTrait */ protected static function writeResources(array $resources): void { - file_put_contents(__DIR__.'/Fixtures/app/var/resources.php', sprintf(' $v.'::class', $resources)))); + file_put_contents(__DIR__.'/Fixtures/app/var/resources.php', \sprintf(' $v.'::class', $resources)))); } protected static function removeResources(): void