diff --git a/extension.neon b/extension.neon index aa90e9d..6a5a290 100644 --- a/extension.neon +++ b/extension.neon @@ -65,6 +65,7 @@ services: class: bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage arguments: directory: %tmpDir%/cache/PHPStan + magentoRoot: %magento.magentoRoot% autoloaderCache: autowired: false class: PHPStan\Cache\Cache diff --git a/src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php b/src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php index 1447081..4d59462 100644 --- a/src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php +++ b/src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php @@ -21,14 +21,20 @@ class FileCacheStorage implements CacheStorage */ private $directory; + /** + * @var string + */ + private $magentoRoot; + /** * FileCacheStorage constructor. * * @param string $directory */ - public function __construct(string $directory) + public function __construct(string $directory, string $magentoRoot) { $this->directory = $directory; + $this->magentoRoot = $magentoRoot; } /** @@ -73,7 +79,7 @@ public function save(string $key, string $variableKey, $data): void */ private function getCacheDir(string $key): string { - $keyHash = sha1($key); + $keyHash = sha1(sprintf('%s/%s', $this->magentoRoot, $key)); $firstDirectory = sprintf('%s/%s', $this->directory, substr($keyHash, 0, 2)); return sprintf('%s/%s', $firstDirectory, substr($keyHash, 2, 2)); }