Skip to content

Commit

Permalink
style: cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Aug 9, 2024
1 parent 1d13697 commit 3f48c6f
Show file tree
Hide file tree
Showing 176 changed files with 529 additions and 529 deletions.
4 changes: 2 additions & 2 deletions docs/src/DependencyInjection/Compiler/AttributeFilterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/BooleanFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Common/Filter/DateFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Common/Filter/ExistsFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Common/Filter/NumericFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/OrderFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/Doctrine/Common/Filter/RangeFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -104,15 +104,15 @@ 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 "<min>..<max>"', self::PARAMETER_BETWEEN)),
'exception' => new InvalidArgumentException(\sprintf('Invalid format for "[%s]", expected "<min>..<max>"', self::PARAMETER_BETWEEN)),
]);

return null;
}

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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/SearchFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/LinksHandlerLocatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/LinksHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions src/Doctrine/EventListener/PublishMercureUpdatesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
}

Expand Down Expand Up @@ -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)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Odm/Extension/PaginationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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'] ?? [];
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/Odm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/PropertyHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']];
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/State/CollectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/State/ItemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/Odm/State/LinksHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Tests/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 3f48c6f

Please sign in to comment.