Skip to content

Commit

Permalink
PHP 8.4 deprecates implicit nullable types. This PR fixes the depreca…
Browse files Browse the repository at this point in the history
…tion warnings in the package.

PHP 8.4 RC1 releast notes: https://github.com/php/php-src/blob/php-8.4.0RC1/UPGRADING#L497
  . Implicitly nullable parameter types are now deprecated.
    RFC: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
  • Loading branch information
selfsimilar committed Sep 27, 2024
1 parent 4795faf commit 7776c34
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Exceptions/MediaUpload/ConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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): self
{
return new self("Invalid source provided. {$message}", 0, $original);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/MediaUpload/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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): self
{
return new self("File `{$path}` does not exist.", 0, $original);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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): string
{
$language = $language ?: App::currentLocale();
return trim(
Expand All @@ -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): string
{
$language = $language ?: App::currentLocale();
return trim(
Expand Down
14 changes: 7 additions & 7 deletions src/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
class Media extends Model
{
Expand Down Expand Up @@ -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): void
{
$q->whereNotNull('original_media_id');
if ($variant_name) {
Expand Down Expand Up @@ -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): bool
{
return $this->original_media_id !== null
&& (!$variantName || $this->variant_name === $variantName);
Expand Down Expand Up @@ -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): void
{
$this->getMediaMover()->move($this, $destination, $filename);
}
Expand All @@ -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): self
{
return $this->getMediaMover()->copyTo($this, $destination, $filename);
}
Expand All @@ -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,
array $options = []
): void {
$this->getMediaMover()
Expand All @@ -547,7 +547,7 @@ public function moveToDisk(
public function copyToDisk(
string $disk,
string $destination,
string $filename = null,
?string $filename,
array $options = []
): self {
return $this->getMediaMover()
Expand Down
8 changes: 4 additions & 4 deletions src/MediaMover.php
Original file line number Diff line number Diff line change
Expand Up @@ -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): void
{
$storage = $this->filesystem->disk($media->disk);

Expand Down Expand Up @@ -65,7 +65,7 @@ public function moveToDisk(
Media $media,
string $disk,
string $directory,
string $filename = null,
?string $filename,
array $options = []
): void {
if ($media->disk === $disk) {
Expand Down Expand Up @@ -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): Media
{
$storage = $this->filesystem->disk($media->disk);

Expand Down Expand Up @@ -160,7 +160,7 @@ public function copyToDisk(
Media $media,
string $disk,
string $directory,
string $filename = null,
?string $filename,
array $options = []
): Media {
if ($media->disk === $disk) {
Expand Down
2 changes: 1 addition & 1 deletion src/MediaUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function __construct(
FileSystemManager $filesystem,
SourceAdapterFactory $factory,
ImageManipulator $imageManipulator,
array $config = null
?array $config
) {
$this->filesystem = $filesystem;
$this->factory = $factory;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/UrlGenerators/LocalUrlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function test_it_checks_public_visibility_mock_disk(): void

protected function setupGenerator(
$disk = 'uploads',
bool $public = null
?bool $public
): LocalUrlGenerator {
/** @var Media $media */
$media = factory(Media::class)->make(
Expand Down

0 comments on commit 7776c34

Please sign in to comment.