mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Config for caching file hashes during run
This commit is contained in:
parent
0fbf8b5619
commit
ba4f47a41c
@ -25,6 +25,7 @@
|
||||
<xs:attribute name="strictBinaryOperands" type="xs:string" />
|
||||
<xs:attribute name="requireVoidReturnType" type="xs:string" />
|
||||
<xs:attribute name="useAssertForType" type="xs:string" />
|
||||
<xs:attribute name="cacheFileContentHashes" type="xs:string" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="ProjectFilesType">
|
||||
|
@ -253,7 +253,7 @@ class FileChecker extends SourceChecker implements StatementsSource
|
||||
|
||||
$this->interface_checkers_to_visit[$fq_class_name] = $class_checker;
|
||||
} elseif ($stmt instanceof PhpParser\Node\Stmt\Trait_) {
|
||||
new TraitChecker($stmt, $this, $stmt->name);
|
||||
$trait_checker = new TraitChecker($stmt, $this, $stmt->name);
|
||||
}
|
||||
} elseif ($stmt instanceof PhpParser\Node\Stmt\Namespace_) {
|
||||
$namespace_name = $stmt->name ? implode('\\', $stmt->name->parts) : '';
|
||||
@ -545,7 +545,9 @@ class FileChecker extends SourceChecker implements StatementsSource
|
||||
$file_content_hash = md5($version . $file_contents);
|
||||
$name_cache_key = self::getParserCacheKey($file_path);
|
||||
|
||||
if (self::$file_content_hashes === null) {
|
||||
$config = Config::getInstance();
|
||||
|
||||
if (self::$file_content_hashes === null || !$config->cache_file_hashes_during_run) {
|
||||
/** @var array<string, string> */
|
||||
self::$file_content_hashes = $root_cache_directory &&
|
||||
is_readable($root_cache_directory . DIRECTORY_SEPARATOR . self::FILE_HASHES)
|
||||
@ -1012,6 +1014,8 @@ class FileChecker extends SourceChecker implements StatementsSource
|
||||
$function_line = $file_lines[$line_number - 1];
|
||||
$left_padding = str_replace(ltrim($function_line), '', $function_line);
|
||||
|
||||
$line_before = $file_lines[$line_number - 2];
|
||||
|
||||
$parsed_docblock = [];
|
||||
$existing_line_count = $existing_docblock ? substr_count($existing_docblock, PHP_EOL) + 1 : 0;
|
||||
|
||||
|
@ -132,6 +132,11 @@ class Config
|
||||
*/
|
||||
protected $stub_files = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $cache_file_hashes_during_run = true;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
@ -305,6 +310,11 @@ class Config
|
||||
$config->use_assert_for_type = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml['cacheFileContentHashes'])) {
|
||||
$attribute_text = (string) $config_xml['cacheFileContentHashes'];
|
||||
$config->cache_file_hashes_during_run = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml->projectFiles)) {
|
||||
$config->project_files = ProjectFileFilter::loadFromXMLElement($config_xml->projectFiles, $config, true);
|
||||
}
|
||||
@ -441,7 +451,7 @@ class Config
|
||||
*/
|
||||
public function initializePlugins(ProjectChecker $project_checker)
|
||||
{
|
||||
foreach ($this->filetype_handlers as &$path) {
|
||||
foreach ($this->filetype_handlers as $extension_name => &$path) {
|
||||
$plugin_file_checker = new FileChecker($path, $project_checker);
|
||||
$plugin_file_checker->visit();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user