mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Merge pull request #65 from Fleshgrinder/feature/auto-creation-of-cache-directory
Auto-create cache directory
This commit is contained in:
commit
4073986844
@ -245,27 +245,16 @@ class Config
|
||||
}
|
||||
|
||||
if (isset($config_xml['cacheDirectory'])) {
|
||||
$path = (string)$config_xml['cacheDirectory'];
|
||||
|
||||
if ($path[0] !== '/') {
|
||||
if (realpath(dirname($path)) !== dirname($path)) {
|
||||
$cache_base_dir = realpath(dirname($config->base_dir . $path));
|
||||
|
||||
if (!$cache_base_dir) {
|
||||
die('Could not locate cache parent directory ' . dirname($config->base_dir . $path) . PHP_EOL);
|
||||
}
|
||||
|
||||
$path = $cache_base_dir . DIRECTORY_SEPARATOR . basename($path);
|
||||
}
|
||||
} elseif (realpath(dirname($path)) === false) {
|
||||
die('Could not locate cache parent directory ' . dirname($path) . PHP_EOL);
|
||||
}
|
||||
|
||||
$config->cache_directory = $path;
|
||||
$config->cache_directory = (string)$config_xml['cacheDirectory'];
|
||||
} else {
|
||||
$config->cache_directory = sys_get_temp_dir() . '/psalm';
|
||||
}
|
||||
|
||||
if (@mkdir($config->cache_directory, 0777, true) === false && is_dir($config->cache_directory) === false) {
|
||||
trigger_error('Could not create cache directory: ' . $config->cache_directory, E_USER_ERROR);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
if (isset($config_xml['usePropertyDefaultForType'])) {
|
||||
$attribute_text = (string) $config_xml['usePropertyDefaultForType'];
|
||||
$config->use_property_default_for_type = $attribute_text === 'true' || $attribute_text === '1';
|
||||
|
Loading…
x
Reference in New Issue
Block a user