diff --git a/src/Exceptions/MediaUpload/ConfigurationException.php b/src/Exceptions/MediaUpload/ConfigurationException.php index c67a5f7..aabc80f 100644 --- a/src/Exceptions/MediaUpload/ConfigurationException.php +++ b/src/Exceptions/MediaUpload/ConfigurationException.php @@ -33,7 +33,7 @@ public static function unrecognizedSource($source): self return new self("Could not recognize source, `{$source}` provided."); } - public static function invalidSource(string $message, \Throwable $original = null): self + public static function invalidSource(string $message, ?\Throwable $original= null): self { return new self("Invalid source provided. {$message}", 0, $original); } diff --git a/src/Exceptions/MediaUpload/FileNotFoundException.php b/src/Exceptions/MediaUpload/FileNotFoundException.php index 275e73e..4470a20 100644 --- a/src/Exceptions/MediaUpload/FileNotFoundException.php +++ b/src/Exceptions/MediaUpload/FileNotFoundException.php @@ -7,7 +7,7 @@ class FileNotFoundException extends MediaUploadException { - public static function fileNotFound(string $path, \Throwable $original = null): self + public static function fileNotFound(string $path, ?\Throwable $original = null): self { return new self("File `{$path}` does not exist.", 0, $original); } diff --git a/src/Helpers/File.php b/src/Helpers/File.php index ede7dd4..ef55961 100644 --- a/src/Helpers/File.php +++ b/src/Helpers/File.php @@ -30,7 +30,7 @@ public static function cleanDirname(string $path): string * @param string $path * @return string */ - public static function sanitizePath(string $path, string $language = null): string + public static function sanitizePath(string $path, ?string $language = null): string { $language = $language ?: App::currentLocale(); return trim( @@ -48,7 +48,7 @@ public static function sanitizePath(string $path, string $language = null): stri * @param string $file * @return string */ - public static function sanitizeFileName(string $file, string $language = null): string + public static function sanitizeFileName(string $file, ?string $language = null): string { $language = $language ?: App::currentLocale(); return trim( diff --git a/src/Media.php b/src/Media.php index 8a50f7e..c4c9987 100644 --- a/src/Media.php +++ b/src/Media.php @@ -47,7 +47,7 @@ * @method static Builder forPathOnDisk(string $disk, string $path) * @method static Builder unordered() * @method static Builder whereIsOriginal() - * @method static Builder whereIsVariant(string $variant_name = null) + * @method static Builder whereIsVariant(?string $variant_name = null) */ class Media extends Model { @@ -305,7 +305,7 @@ public function scopeWhereIsOriginal(Builder $q): void $q->whereNull('original_media_id'); } - public function scopeWhereIsVariant(Builder $q, string $variant_name = null): void + public function scopeWhereIsVariant(Builder $q, ?string $variant_name = null): void { $q->whereNotNull('original_media_id'); if ($variant_name) { @@ -431,7 +431,7 @@ public function isOriginal(): bool * @param string|null $variantName if specified, will check if the model if a specific kind of variant * @return bool */ - public function isVariant(string $variantName = null): bool + public function isVariant(?string $variantName = null): bool { return $this->original_media_id !== null && (!$variantName || $this->variant_name === $variantName); @@ -482,7 +482,7 @@ public function makeVariantOf($media, string $variantName): self * @return void * @throws MediaMoveException */ - public function move(string $destination, string $filename = null): void + public function move(string $destination, ?string $filename = null): void { $this->getMediaMover()->move($this, $destination, $filename); } @@ -507,7 +507,7 @@ public function rename(string $filename): void * @return Media * @throws MediaMoveException */ - public function copyTo(string $destination, string $filename = null): self + public function copyTo(string $destination, ?string $filename = null): self { return $this->getMediaMover()->copyTo($this, $destination, $filename); } @@ -525,7 +525,7 @@ public function copyTo(string $destination, string $filename = null): self public function moveToDisk( string $disk, string $destination, - string $filename = null, + ?string $filename = null, array $options = [] ): void { $this->getMediaMover() @@ -547,7 +547,7 @@ public function moveToDisk( public function copyToDisk( string $disk, string $destination, - string $filename = null, + ?string $filename = null, array $options = [] ): self { return $this->getMediaMover() diff --git a/src/MediaMover.php b/src/MediaMover.php index 544d112..6966b08 100644 --- a/src/MediaMover.php +++ b/src/MediaMover.php @@ -30,7 +30,7 @@ public function __construct(FilesystemManager $filesystem) * @return void * @throws MediaMoveException If attempting to change the file extension or a file with the same name already exists at the destination */ - public function move(Media $media, string $directory, string $filename = null): void + public function move(Media $media, string $directory, ?string $filename = null): void { $storage = $this->filesystem->disk($media->disk); @@ -65,7 +65,7 @@ public function moveToDisk( Media $media, string $disk, string $directory, - string $filename = null, + ?string $filename = null, array $options = [] ): void { if ($media->disk === $disk) { @@ -113,7 +113,7 @@ public function moveToDisk( * @return Media * @throws MediaMoveException If a file with the same name already exists at the destination or it fails to copy the file */ - public function copyTo(Media $media, string $directory, string $filename = null): Media + public function copyTo(Media $media, string $directory, ?string $filename = null): Media { $storage = $this->filesystem->disk($media->disk); @@ -160,7 +160,7 @@ public function copyToDisk( Media $media, string $disk, string $directory, - string $filename = null, + ?string $filename = null, array $options = [] ): Media { if ($media->disk === $disk) { diff --git a/src/MediaUploader.php b/src/MediaUploader.php index d96b626..4902828 100644 --- a/src/MediaUploader.php +++ b/src/MediaUploader.php @@ -88,7 +88,7 @@ public function __construct( FileSystemManager $filesystem, SourceAdapterFactory $factory, ImageManipulator $imageManipulator, - array $config = null + ?array $config = null ) { $this->filesystem = $filesystem; $this->factory = $factory; diff --git a/tests/Integration/UrlGenerators/LocalUrlGeneratorTest.php b/tests/Integration/UrlGenerators/LocalUrlGeneratorTest.php index 83ff151..7d727d7 100644 --- a/tests/Integration/UrlGenerators/LocalUrlGeneratorTest.php +++ b/tests/Integration/UrlGenerators/LocalUrlGeneratorTest.php @@ -86,7 +86,7 @@ public function test_it_checks_public_visibility_mock_disk(): void protected function setupGenerator( $disk = 'uploads', - bool $public = null + ?bool $public = null ): LocalUrlGenerator { /** @var Media $media */ $media = factory(Media::class)->make(