From a0ea95e6396d5d68b47338d187de254ef8a1bea8 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij Date: Sat, 4 Nov 2023 14:30:44 +0100 Subject: [PATCH] Replace various short-ternary operators with null coalescing ones --- AwsS3V3Adapter.php | 10 +++++----- S3ClientStub.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AwsS3V3Adapter.php b/AwsS3V3Adapter.php index 9b87d8c..acd9f07 100644 --- a/AwsS3V3Adapter.php +++ b/AwsS3V3Adapter.php @@ -108,8 +108,8 @@ public function __construct( private array $multipartUploadOptions = self::MUP_AVAILABLE_OPTIONS, ) { $this->prefixer = new PathPrefixer($prefix); - $this->visibility = $visibility ?: new PortableVisibilityConverter(); - $this->mimeTypeDetector = $mimeTypeDetector ?: new FinfoMimeTypeDetector(); + $this->visibility = $visibility ?? new PortableVisibilityConverter(); + $this->mimeTypeDetector = $mimeTypeDetector ?? new FinfoMimeTypeDetector(); } public function fileExists(string $path): bool @@ -397,8 +397,8 @@ private function retrievePaginatedListing(array $options): Generator $resultPaginator = $this->client->getPaginator('ListObjectsV2', $options + $this->options); foreach ($resultPaginator as $result) { - yield from ($result->get('CommonPrefixes') ?: []); - yield from ($result->get('Contents') ?: []); + yield from ($result->get('CommonPrefixes') ?? []); + yield from ($result->get('Contents') ?? []); } } @@ -416,7 +416,7 @@ public function copy(string $source, string $destination, Config $config): void { try { /** @var string $visibility */ - $visibility = $config->get(Config::OPTION_VISIBILITY) ?: $this->visibility($source)->visibility(); + $visibility = $config->get(Config::OPTION_VISIBILITY) ?? $this->visibility($source)->visibility(); } catch (Throwable $exception) { throw UnableToCopyFile::fromLocationTo( $source, diff --git a/S3ClientStub.php b/S3ClientStub.php index 82a32ee..d056fb8 100644 --- a/S3ClientStub.php +++ b/S3ClientStub.php @@ -71,7 +71,7 @@ public function failOnNextCopy(): void public function throwExceptionWhenExecutingCommand(string $commandName, S3Exception $exception = null): void { - $this->stagedExceptions[$commandName] = $exception ?: new S3Exception($commandName, new Command($commandName)); + $this->stagedExceptions[$commandName] = $exception ?? new S3Exception($commandName, new Command($commandName)); } public function throw500ExceptionWhenExecutingCommand(string $commandName): void