diff --git a/src/Qossmic/DataMapper/DataMapper.php b/src/Qossmic/DataMapper/DataMapper.php index ac3666b..7cb91f5 100644 --- a/src/Qossmic/DataMapper/DataMapper.php +++ b/src/Qossmic/DataMapper/DataMapper.php @@ -143,7 +143,7 @@ public function mapFormsToData(\Traversable $forms, mixed &$data): void if (1 === \count($forms)) { $this->propertyAccessor->setValue($data, $writePropertyPath, reset($forms)->getData()); } elseif (!\is_object($data)) { - throw new LogicException(sprintf('Mapping multiple forms to a single method requires the form data to be an object but is "%s".', \gettype($data))); + throw new LogicException(\sprintf('Mapping multiple forms to a single method requires the form data to be an object but is "%s".', \gettype($data))); } else { $formData = []; diff --git a/src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php b/src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php index 94d8900..5965c0c 100644 --- a/src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php +++ b/src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php @@ -43,7 +43,7 @@ public function has(string $strategy): bool public function get(string $strategy): ExceptionHandlerInterface { if (!isset($this->strategies[$strategy])) { - throw new \InvalidArgumentException(sprintf('The exception handling strategy "%s" is not registered (use one of ["%s"]).', $strategy, implode(', ', array_keys($this->strategies)))); + throw new \InvalidArgumentException(\sprintf('The exception handling strategy "%s" is not registered (use one of ["%s"]).', $strategy, implode(', ', array_keys($this->strategies)))); } /* @phpstan-ignore-next-line */ diff --git a/src/Qossmic/Extension/RichModelFormsTypeExtension.php b/src/Qossmic/Extension/RichModelFormsTypeExtension.php index b4168a7..99a3bc5 100644 --- a/src/Qossmic/Extension/RichModelFormsTypeExtension.php +++ b/src/Qossmic/Extension/RichModelFormsTypeExtension.php @@ -123,7 +123,7 @@ public function configureOptions(OptionsResolver $resolver): void foreach ($value as $strategy) { if (!$this->exceptionHandlerRegistry->has($strategy)) { - throw new InvalidConfigurationException(sprintf('The "%s" error handling strategy is not registered.', $strategy)); + throw new InvalidConfigurationException(\sprintf('The "%s" error handling strategy is not registered.', $strategy)); } } @@ -134,7 +134,7 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('factory', ['string', 'array', 'null', \Closure::class]); $resolver->setNormalizer('factory', function (Options $options, $value) { if (\is_string($value) && !class_exists($value)) { - throw new InvalidConfigurationException(sprintf('The configured value for the "factory" option is not a valid class name ("%s" given).', $value)); + throw new InvalidConfigurationException(\sprintf('The configured value for the "factory" option is not a valid class name ("%s" given).', $value)); } if (\is_array($value) && !\is_callable($value)) { diff --git a/src/Qossmic/Instantiator/ObjectInstantiator.php b/src/Qossmic/Instantiator/ObjectInstantiator.php index 7b53cb2..e4b5ed9 100644 --- a/src/Qossmic/Instantiator/ObjectInstantiator.php +++ b/src/Qossmic/Instantiator/ObjectInstantiator.php @@ -35,19 +35,19 @@ public function instantiateObject(): ?object $factoryMethod = (new \ReflectionClass($this->factory))->getConstructor(); if (null === $factoryMethod) { - throw new TransformationFailedException(sprintf('The class "%s" used as a factory does not have a constructor.', $this->factory)); + throw new TransformationFailedException(\sprintf('The class "%s" used as a factory does not have a constructor.', $this->factory)); } $factoryMethodAsString = $this->factory.'::__construct'; if (!$factoryMethod->isPublic()) { - throw new TransformationFailedException(sprintf('The factory method %s() is not public.', $factoryMethodAsString)); + throw new TransformationFailedException(\sprintf('The factory method %s() is not public.', $factoryMethodAsString)); } } elseif (\is_array($this->factory) && \is_callable($this->factory)) { $class = \is_object($this->factory[0]) ? \get_class($this->factory[0]) : $this->factory[0]; $factoryMethod = (new \ReflectionMethod($class, $this->factory[1])); $factoryMethodAsString = $class.'::'.$this->factory[1]; if (!$factoryMethod->isPublic()) { - throw new TransformationFailedException(sprintf('The factory method %s() is not public.', $factoryMethodAsString)); + throw new TransformationFailedException(\sprintf('The factory method %s() is not public.', $factoryMethodAsString)); } } elseif ($this->factory instanceof \Closure) { $factoryMethod = new \ReflectionFunction($this->factory); diff --git a/tests/Fixtures/DependencyInjection/Kernel.php b/tests/Fixtures/DependencyInjection/Kernel.php index df31bac..9d82dba 100644 --- a/tests/Fixtures/DependencyInjection/Kernel.php +++ b/tests/Fixtures/DependencyInjection/Kernel.php @@ -49,11 +49,11 @@ public function registerContainerConfiguration(LoaderInterface $loader): void public function getCacheDir(): string { - return sprintf('%s/RichModelForms/%d/cache', sys_get_temp_dir(), self::VERSION_ID); + return \sprintf('%s/RichModelForms/%d/cache', sys_get_temp_dir(), self::VERSION_ID); } public function getLogDir(): string { - return sprintf('%s/RichModelForms/%d/log', sys_get_temp_dir(), self::VERSION_ID); + return \sprintf('%s/RichModelForms/%d/log', sys_get_temp_dir(), self::VERSION_ID); } } diff --git a/tests/Fixtures/Form/ChangeProductStockType.php b/tests/Fixtures/Form/ChangeProductStockType.php index 9a31db6..a5d4b91 100644 --- a/tests/Fixtures/Form/ChangeProductStockType.php +++ b/tests/Fixtures/Form/ChangeProductStockType.php @@ -29,7 +29,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('stock', IntegerType::class, [ 'handle_exception' => $options['expected_stock_exception'], ]) - ->setDataMapper(new class() implements DataMapperInterface { + ->setDataMapper(new class implements DataMapperInterface { public function mapDataToForms($data, $forms): void { foreach ($forms as $form) { diff --git a/tests/Fixtures/Form/GrossPriceType.php b/tests/Fixtures/Form/GrossPriceType.php index 6d8ccfe..068a87d 100644 --- a/tests/Fixtures/Form/GrossPriceType.php +++ b/tests/Fixtures/Form/GrossPriceType.php @@ -29,7 +29,7 @@ class GrossPriceType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { if (null === $options['factory']) { - throw new InvalidConfigurationException(sprintf('The %s requires a configured value for the "factory" option.', self::class)); + throw new InvalidConfigurationException(\sprintf('The %s requires a configured value for the "factory" option.', self::class)); } $builder diff --git a/tests/Fixtures/Form/PriceType.php b/tests/Fixtures/Form/PriceType.php index a82d730..7a82b5e 100644 --- a/tests/Fixtures/Form/PriceType.php +++ b/tests/Fixtures/Form/PriceType.php @@ -26,7 +26,7 @@ class PriceType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { if (null === $options['factory']) { - throw new InvalidConfigurationException(sprintf('The %s requires a configured value for the "factory" option.', self::class)); + throw new InvalidConfigurationException(\sprintf('The %s requires a configured value for the "factory" option.', self::class)); } } diff --git a/tests/Fixtures/Model/Category.php b/tests/Fixtures/Model/Category.php index 7a418a6..e3ecdd0 100644 --- a/tests/Fixtures/Model/Category.php +++ b/tests/Fixtures/Model/Category.php @@ -62,7 +62,7 @@ public function moveTo(self $parent): void private function validateName(string $name): void { if (\strlen($name) < 3) { - throw new \LengthException(sprintf('The name must have a length of at least three characters ("%s" given).', $name)); + throw new \LengthException(\sprintf('The name must have a length of at least three characters ("%s" given).', $name)); } } } diff --git a/tests/Fixtures/Model/GrossPrice.php b/tests/Fixtures/Model/GrossPrice.php index 0b7e235..db6e2b2 100644 --- a/tests/Fixtures/Model/GrossPrice.php +++ b/tests/Fixtures/Model/GrossPrice.php @@ -23,11 +23,11 @@ final class GrossPrice public function __construct(int $amount, int $taxRate) { if ($amount < 0) { - throw new \InvalidArgumentException(sprintf('A price cannot be less than 0 (%d given).', $amount)); + throw new \InvalidArgumentException(\sprintf('A price cannot be less than 0 (%d given).', $amount)); } if (!\in_array($taxRate, [7, 19], true)) { - throw new \InvalidArgumentException(sprintf('The tax rate must be 7%% or 19%% (%d%% given).', $taxRate)); + throw new \InvalidArgumentException(\sprintf('The tax rate must be 7%% or 19%% (%d%% given).', $taxRate)); } $this->amount = $amount; diff --git a/tests/Fixtures/Model/Price.php b/tests/Fixtures/Model/Price.php index 99262e7..d038caf 100644 --- a/tests/Fixtures/Model/Price.php +++ b/tests/Fixtures/Model/Price.php @@ -22,7 +22,7 @@ final class Price public function __construct(int $amount) { if ($amount < 0) { - throw new \InvalidArgumentException(sprintf('A price cannot be less than 0 (%d given).', $amount)); + throw new \InvalidArgumentException(\sprintf('A price cannot be less than 0 (%d given).', $amount)); } $this->amount = $amount;