diff --git a/src/Supportive/DependencyInjection/ServiceContainerBuilder.php b/src/Supportive/DependencyInjection/ServiceContainerBuilder.php index 6a852a70a..9d39447d3 100644 --- a/src/Supportive/DependencyInjection/ServiceContainerBuilder.php +++ b/src/Supportive/DependencyInjection/ServiceContainerBuilder.php @@ -129,18 +129,21 @@ private static function loadServices(ContainerBuilder $container, ?SplFileInfo $ return; } - $dirname = $cacheFile->getPath() ?: '.'; - - if (( - !is_dir($dirname) - && mkdir($dirname.'/', 0777, true) - && !is_dir($dirname) - ) || ( - !file_exists($cacheFile->getPathname()) - && !touch($cacheFile->getPathname()) - && !is_writable($cacheFile->getPathname()) - )) { - throw CacheFileException::notWritable($cacheFile); + if (!file_exists($cacheFile->getPathname())) { + $dirname = $cacheFile->getPath() ?: '.'; + + if (!is_dir($dirname) + && mkdir($dirname.'/', 0777, true) + && !is_dir($dirname) + ) { + throw CacheFileException::notWritable($cacheFile); + } + + if (!touch($cacheFile->getPathname()) + && !is_writable($cacheFile->getPathname()) + ) { + throw CacheFileException::notWritable($cacheFile); + } } $container->setParameter('deptrac.cache_file', $cacheFile->getPathname());