diff --git a/.gitignore b/.gitignore index f47ea8a..7b30ee3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ composer.lock index.php .phpunit.result.cache .php-cs-fixer.cache +cghooks.lock diff --git a/src/CosAdapter.php b/src/CosAdapter.php index d4da6c6..5846297 100644 --- a/src/CosAdapter.php +++ b/src/CosAdapter.php @@ -201,7 +201,7 @@ public function visibility(string $path): FileAttributes $meta = $this->getObjectClient()->getObjectACL($prefixedPath); foreach ($meta['AccessControlPolicy']['AccessControlList']['Grant'] ?? [] as $grant) { - if ('READ' === $grant['Permission'] && str_contains($grant['Grantee']['URI'] ?? '', 'global/AllUsers')) { + if ($grant['Permission'] === 'READ' && str_contains($grant['Grantee']['URI'] ?? '', 'global/AllUsers')) { return new FileAttributes($path, null, Visibility::PUBLIC); } } @@ -423,10 +423,10 @@ protected function listObjects(string $directory = '', bool $recursive = false) { $result = $this->getBucketClient()->getObjects( [ - 'prefix' => ('' === (string) $directory) ? '' : ($directory.'/'), + 'prefix' => empty($directory) ? '' : ($directory.'/'), 'delimiter' => $recursive ? '' : '/', ] - )['ListBucketResult']; + )->toArray(); foreach (['CommonPrefixes', 'Contents'] as $key) { $result[$key] = $result[$key] ?? [];