diff --git a/composer.json b/composer.json index 97ad371..c8ab380 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "require-dev": { "ext-zend-opcache": "*", "ext-xdebug": "*", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^10.3", "mockery/mockery": "^1.6", "league/flysystem-adapter-test-utilities": "^3.15", diff --git a/src/CacheAdapter.php b/src/CacheAdapter.php index 93d0c4c..38dabef 100644 --- a/src/CacheAdapter.php +++ b/src/CacheAdapter.php @@ -2,6 +2,7 @@ namespace jgivoni\Flysystem\Cache; +use ErrorException; use League\Flysystem\CalculateChecksumFromStream; use League\Flysystem\ChecksumAlgoIsNotSupported; use League\Flysystem\ChecksumProvider; @@ -323,6 +324,11 @@ public function fileSize(string $path): FileAttributes public function checksum(string $path, Config $config): string { $algo = $config->get('checksum_algo'); + + if (isset($algo) && !is_string($algo)) { + throw new ErrorException('"checksum_algo" $config must be a string.'); + } + $metadataKey = isset($algo) ? 'checksum_' . $algo : 'checksum'; $attributeAccessor = function (StorageAttributes $storageAttributes) use ($metadataKey) { diff --git a/src/CacheItemsTrait.php b/src/CacheItemsTrait.php index d262d20..4cbdb64 100644 --- a/src/CacheItemsTrait.php +++ b/src/CacheItemsTrait.php @@ -128,7 +128,6 @@ protected function getFileAttributes( $item = $this->getCacheItem($path); if ($item->isHit()) { - /** @var FileAttributes $fileAttributes */ $fileAttributes = $item->get(); if (!$fileAttributes instanceof FileAttributes) {