From 22b77fa5c31ec739e994cfe37197913da4b90ad4 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij Date: Sat, 18 Nov 2023 15:00:00 +0100 Subject: [PATCH] Replace various string-references to config options with consts --- src/AsyncAwsS3/AsyncAwsS3Adapter.php | 4 ++-- src/AwsS3V3/AwsS3V3Adapter.php | 4 ++-- src/Ftp/FtpAdapter.php | 2 +- src/MountManager.php | 4 ++-- src/PhpseclibV2/SftpAdapter.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/AsyncAwsS3/AsyncAwsS3Adapter.php b/src/AsyncAwsS3/AsyncAwsS3Adapter.php index 0fd541aa7..cfa11910c 100644 --- a/src/AsyncAwsS3/AsyncAwsS3Adapter.php +++ b/src/AsyncAwsS3/AsyncAwsS3Adapter.php @@ -197,8 +197,8 @@ public function deleteDirectory(string $path): void public function createDirectory(string $path, Config $config): void { - $defaultVisibility = $config->get('directory_visibility', $this->visibility->defaultForDirectories()); - $config = $config->withDefaults(['visibility' => $defaultVisibility]); + $defaultVisibility = $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $this->visibility->defaultForDirectories()); + $config = $config->withDefaults([Config::OPTION_VISIBILITY => $defaultVisibility]); $this->upload(rtrim($path, '/') . '/', '', $config); } diff --git a/src/AwsS3V3/AwsS3V3Adapter.php b/src/AwsS3V3/AwsS3V3Adapter.php index fefa3bb8e..479332121 100644 --- a/src/AwsS3V3/AwsS3V3Adapter.php +++ b/src/AwsS3V3/AwsS3V3Adapter.php @@ -244,8 +244,8 @@ public function deleteDirectory(string $path): void public function createDirectory(string $path, Config $config): void { - $defaultVisibility = $config->get('directory_visibility', $this->visibility->defaultForDirectories()); - $config = $config->withDefaults(['visibility' => $defaultVisibility]); + $defaultVisibility = $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $this->visibility->defaultForDirectories()); + $config = $config->withDefaults([Config::OPTION_VISIBILITY => $defaultVisibility]); $this->upload(rtrim($path, '/') . '/', '', $config); } diff --git a/src/Ftp/FtpAdapter.php b/src/Ftp/FtpAdapter.php index 219a1b147..079dd010a 100644 --- a/src/Ftp/FtpAdapter.php +++ b/src/Ftp/FtpAdapter.php @@ -251,7 +251,7 @@ public function deleteDirectory(string $path): void public function createDirectory(string $path, Config $config): void { - $this->ensureDirectoryExists($path, $config->get('directory_visibility', $config->get('visibility'))); + $this->ensureDirectoryExists($path, $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $config->get(Config::OPTION_VISIBILITY))); } public function setVisibility(string $path, string $visibility): void diff --git a/src/MountManager.php b/src/MountManager.php index 6474eeeee..0fa7d8903 100644 --- a/src/MountManager.php +++ b/src/MountManager.php @@ -374,7 +374,7 @@ private function copyAcrossFilesystem( ): void { $config = $this->config->extend($config); $retainVisibility = (bool) $config->get(Config::OPTION_RETAIN_VISIBILITY, true); - $visibility = $config->get('visibility'); + $visibility = $config->get(Config::OPTION_VISIBILITY); try { if ($visibility == null && $retainVisibility) { @@ -382,7 +382,7 @@ private function copyAcrossFilesystem( } $stream = $sourceFilesystem->readStream($sourcePath); - $destinationFilesystem->writeStream($destinationPath, $stream, $visibility ? compact('visibility') : []); + $destinationFilesystem->writeStream($destinationPath, $stream, $visibility ? compact(Config::OPTION_VISIBILITY) : []); } catch (UnableToRetrieveMetadata | UnableToReadFile | UnableToWriteFile $exception) { throw UnableToCopyFile::fromLocationTo($source, $destination, $exception); } diff --git a/src/PhpseclibV2/SftpAdapter.php b/src/PhpseclibV2/SftpAdapter.php index a9560f843..e41f29c73 100644 --- a/src/PhpseclibV2/SftpAdapter.php +++ b/src/PhpseclibV2/SftpAdapter.php @@ -348,7 +348,7 @@ public function copy(string $source, string $destination, Config $config): void try { $readStream = $this->readStream($source); $visibility = $this->visibility($source)->visibility(); - $this->writeStream($destination, $readStream, new Config(compact('visibility'))); + $this->writeStream($destination, $readStream, new Config(compact(Config::OPTION_VISIBILITY))); } catch (Throwable $exception) { if (isset($readStream) && is_resource($readStream)) { @fclose($readStream);