Skip to content

Commit

Permalink
add hideAllErrorsExceptPassedFiles config option
Browse files Browse the repository at this point in the history
for files only (not directories, since that wouldn't make practical sense)
  • Loading branch information
kkmuffme committed Sep 21, 2022
1 parent 5bf59e4 commit cbe4ba8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Psalm/Config.php
Expand Up @@ -926,6 +926,7 @@ private static function fromXmlAndPaths(
'useDocblockPropertyTypes' => 'use_docblock_property_types',
'throwExceptionOnError' => 'throw_exception',
'hideExternalErrors' => 'hide_external_errors',
'hideAllErrorsExceptPassedFiles' => 'hide_all_errors_except_passed_files',
'resolveFromConfigFile' => 'resolve_from_config_file',
'allowFileIncludes' => 'allow_includes',
'strictBinaryOperands' => 'strict_binary_operands',
Expand Down Expand Up @@ -1567,6 +1568,11 @@ public function reportIssueInFile(string $issue_type, string $file_path): bool

$project_analyzer = ProjectAnalyzer::getInstance();

if ($this->hide_all_errors_except_passed_files
&& !in_array($file_path, $project_analyzer->check_paths_files, true)) {
return false;
}

$codebase = $project_analyzer->getCodebase();

if (!$this->hide_external_errors) {
Expand Down
6 changes: 6 additions & 0 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Expand Up @@ -204,6 +204,11 @@ class ProjectAnalyzer
*/
public $provide_completion = false;

/**
* @var list<string>
*/
public $check_paths_files = [];

/**
* @var array<string,string>
*/
Expand Down Expand Up @@ -1178,6 +1183,7 @@ public function checkPaths(array $paths_to_check): void
if (is_dir($path)) {
$this->checkDirWithConfig($path, $this->config, true);
} elseif (is_file($path)) {
$this->check_paths_files[] = $path;
$this->codebase->addFilesToAnalyze([$path => $path]);
$this->config->hide_external_errors = $this->config->isInProjectDirs($path);
}
Expand Down

0 comments on commit cbe4ba8

Please sign in to comment.