Skip to content

Commit

Permalink
Use different psalm cache for different error levels
Browse files Browse the repository at this point in the history
  • Loading branch information
TysonAndre committed Aug 6, 2021
1 parent 457695e commit 3486490
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@ public static function loadFromXMLFile(string $file_path, string $current_dir):
return $config;
}

/**
* Computes the hash to use for a cache folder from CLI flags and from the config file's xml contents
*/
public function computeHash(): string
{
return sha1($this->hash . ':' . $this->level);
}

/**
* Creates a new config object from an XML string
* @param string|null $current_dir Current working directory, if different to $base_dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(Config $config)
$this->modified_timestamps .= ' ' . filemtime($dependent_file_path);
}

$this->modified_timestamps .= $this->config->hash;
$this->modified_timestamps .= $this->config->computeHash();
}

public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents): void
Expand Down
5 changes: 3 additions & 2 deletions src/Psalm/Internal/Provider/FileReferenceCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function __construct(Config $config)

public function hasConfigChanged() : bool
{
$has_changed = $this->config->hash !== $this->getConfigHashCache();
$this->setConfigHashCache($this->config->hash);
$new_hash = $this->config->computeHash();
$has_changed = $new_hash !== $this->getConfigHashCache();
$this->setConfigHashCache($new_hash);
return $has_changed;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/FileStorageCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(Config $config)
$this->modified_timestamps .= ' ' . filemtime($dependent_file_path);
}

$this->modified_timestamps .= $this->config->hash;
$this->modified_timestamps .= $this->config->computeHash();
}

public function writeToCache(FileStorage $storage, string $file_contents): void
Expand Down

0 comments on commit 3486490

Please sign in to comment.