From 007a254b5ac88529b7df4f18a8572e6d8cd863e3 Mon Sep 17 00:00:00 2001 From: Zing Date: Sat, 15 Jul 2023 10:47:16 +0800 Subject: [PATCH 1/3] Fix coding style --- src/ObsAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObsAdapter.php b/src/ObsAdapter.php index 98e37ee..e3a920c 100644 --- a/src/ObsAdapter.php +++ b/src/ObsAdapter.php @@ -41,7 +41,7 @@ class ObsAdapter implements FilesystemAdapter, PublicUrlGenerator, ChecksumProvi /** * @var string[] */ - private const EXTRA_METADATA_FIELDS = ['Metadata', 'StorageClass', 'ETag', 'VersionId']; +private const EXTRA_METADATA_FIELDS = ['Metadata', 'StorageClass', 'ETag', 'VersionId']; /** * @var string From 67a97c41802a26d56822fffbf4d4cee6f4783ffe Mon Sep 17 00:00:00 2001 From: zingimmick Date: Sat, 15 Jul 2023 02:48:41 +0000 Subject: [PATCH 2/3] Rector Rectify --- src/ObsAdapter.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ObsAdapter.php b/src/ObsAdapter.php index e3a920c..51656c5 100644 --- a/src/ObsAdapter.php +++ b/src/ObsAdapter.php @@ -41,7 +41,7 @@ class ObsAdapter implements FilesystemAdapter, PublicUrlGenerator, ChecksumProvi /** * @var string[] */ -private const EXTRA_METADATA_FIELDS = ['Metadata', 'StorageClass', 'ETag', 'VersionId']; + private const EXTRA_METADATA_FIELDS = ['Metadata', 'StorageClass', 'ETag', 'VersionId']; /** * @var string @@ -403,9 +403,13 @@ private function extractExtraMetadata(array $metadata): array $extracted = []; foreach (self::EXTRA_METADATA_FIELDS as $field) { - if (isset($metadata[$field]) && $metadata[$field] !== '') { - $extracted[$field] = $metadata[$field]; + if (! isset($metadata[$field])) { + continue; + } + if ($metadata[$field] === '') { + continue; } + $extracted[$field] = $metadata[$field]; } return $extracted; @@ -467,7 +471,7 @@ protected function getObject(string $path): StreamInterface public function listDirObjects(string $dirname = '', bool $recursive = false): array { $prefix = trim($this->pathPrefixer->prefixPath($dirname), '/'); - $prefix = empty($prefix) ? '' : $prefix . '/'; + $prefix = $prefix === '' ? '' : $prefix . '/'; $nextMarker = ''; @@ -511,7 +515,7 @@ public function listDirObjects(string $dirname = '', bool $recursive = false): a private function processObjects(array $result, ?array $objects, string $dirname): array { $result['objects'] = []; - if (! empty($objects)) { + if ($objects !== null && $objects !== []) { foreach ($objects as $object) { $object['Prefix'] = $dirname; $result['objects'][] = $object; @@ -529,7 +533,7 @@ private function processObjects(array $result, ?array $objects, string $dirname) */ private function processPrefixes(array $result, ?array $prefixes): array { - if (! empty($prefixes)) { + if ($prefixes !== null && $prefixes !== []) { foreach ($prefixes as $prefix) { $result['prefix'][] = $prefix['Prefix']; } From cdfb53f0177ce0959ca323c406b144d1fa905a11 Mon Sep 17 00:00:00 2001 From: zingimmick Date: Sat, 15 Jul 2023 02:50:25 +0000 Subject: [PATCH 3/3] Rector Rectify --- src/ObsAdapter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ObsAdapter.php b/src/ObsAdapter.php index 51656c5..2cb237c 100644 --- a/src/ObsAdapter.php +++ b/src/ObsAdapter.php @@ -406,9 +406,11 @@ private function extractExtraMetadata(array $metadata): array if (! isset($metadata[$field])) { continue; } + if ($metadata[$field] === '') { continue; } + $extracted[$field] = $metadata[$field]; }