From 4fad8e41338988e7b7d001b971bb670687fa8315 Mon Sep 17 00:00:00 2001 From: Alexander Hofbauer Date: Fri, 29 Nov 2024 08:41:23 +0100 Subject: [PATCH] Use explicit nullables types --- src/Exception/MissingPackageException.php | 2 +- src/Form/Type/VichFileType.php | 2 +- src/Form/Type/VichImageType.php | 2 +- src/Handler/DownloadHandler.php | 2 +- src/Metadata/CacheWarmer.php | 2 +- src/Metadata/Driver/AbstractYamlDriver.php | 2 +- src/Metadata/Driver/XmlDriver.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Exception/MissingPackageException.php b/src/Exception/MissingPackageException.php index faa0069c..836cdaa2 100644 --- a/src/Exception/MissingPackageException.php +++ b/src/Exception/MissingPackageException.php @@ -4,7 +4,7 @@ final class MissingPackageException extends \RuntimeException implements VichUploaderExceptionInterface { - public function __construct(string $message = '', \Throwable $previous = null) + public function __construct(string $message = '', ?\Throwable $previous = null) { parent::__construct($message, 0, $previous); } diff --git a/src/Form/Type/VichFileType.php b/src/Form/Type/VichFileType.php index 7eb2ec05..e199352f 100644 --- a/src/Form/Type/VichFileType.php +++ b/src/Form/Type/VichFileType.php @@ -31,7 +31,7 @@ public function __construct( protected readonly StorageInterface $storage, protected readonly UploadHandler $handler, protected readonly PropertyMappingFactory $factory, - PropertyAccessorInterface $propertyAccessor = null + ?PropertyAccessorInterface $propertyAccessor = null ) { $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); } diff --git a/src/Form/Type/VichImageType.php b/src/Form/Type/VichImageType.php index 725d2951..1b03598d 100644 --- a/src/Form/Type/VichImageType.php +++ b/src/Form/Type/VichImageType.php @@ -29,7 +29,7 @@ public function __construct( StorageInterface $storage, UploadHandler $handler, PropertyMappingFactory $factory, - PropertyAccessorInterface $propertyAccessor = null, + ?PropertyAccessorInterface $propertyAccessor = null, private readonly ?CacheManager $cacheManager = null ) { parent::__construct($storage, $handler, $factory, $propertyAccessor); diff --git a/src/Handler/DownloadHandler.php b/src/Handler/DownloadHandler.php index c04b09b0..e684da63 100644 --- a/src/Handler/DownloadHandler.php +++ b/src/Handler/DownloadHandler.php @@ -21,7 +21,7 @@ final class DownloadHandler extends AbstractHandler * @throws NoFileFoundException * @throws \InvalidArgumentException */ - public function downloadObject(object|array $object, string $field, ?string $className = null, string|bool $fileName = null, bool $forceDownload = true): StreamedResponse + public function downloadObject(object|array $object, string $field, ?string $className = null, string|bool|null $fileName = null, bool $forceDownload = true): StreamedResponse { $mapping = $this->getMapping($object, $field, $className); $stream = $this->storage->resolveStream($object, $field, $className); diff --git a/src/Metadata/CacheWarmer.php b/src/Metadata/CacheWarmer.php index df3d74e6..ab164008 100644 --- a/src/Metadata/CacheWarmer.php +++ b/src/Metadata/CacheWarmer.php @@ -13,7 +13,7 @@ public function __construct(private readonly string $dir, private readonly Metad { } - public function warmUp(string $cacheDir, string $buildDir = null): array + public function warmUp(string $cacheDir, ?string $buildDir = null): array { if (empty($this->dir)) { return []; diff --git a/src/Metadata/Driver/AbstractYamlDriver.php b/src/Metadata/Driver/AbstractYamlDriver.php index f5fad81d..b952378b 100644 --- a/src/Metadata/Driver/AbstractYamlDriver.php +++ b/src/Metadata/Driver/AbstractYamlDriver.php @@ -49,7 +49,7 @@ protected function loadMappingFile(string $file) return YmlParser::parse(\file_get_contents($file)); } - protected function guessClassName(string $file, array $config, \ReflectionClass $class = null): string + protected function guessClassName(string $file, array $config, ?\ReflectionClass $class = null): string { if (null === $class) { return \current(\array_keys($config)); diff --git a/src/Metadata/Driver/XmlDriver.php b/src/Metadata/Driver/XmlDriver.php index 47365a10..90e6af8f 100644 --- a/src/Metadata/Driver/XmlDriver.php +++ b/src/Metadata/Driver/XmlDriver.php @@ -48,7 +48,7 @@ protected function getExtension(): string return 'xml'; } - protected function guessClassName(string $file, \SimpleXMLElement $elem, \ReflectionClass $class = null): string + protected function guessClassName(string $file, \SimpleXMLElement $elem, ?\ReflectionClass $class = null): string { if (null === $class) { return (string) $elem->attributes()->class;