Skip to content

Commit

Permalink
Ensure PluginRegistrationSocket::$$additionalFileExtensions are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Nov 1, 2021
1 parent ea5b9bb commit c1eb612
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Expand Up @@ -264,6 +264,8 @@ public function __construct(
int $threads = 1,
?Progress $progress = null
) {
self::$instance = $this;

if ($progress === null) {
$progress = new VoidProgress();
}
Expand All @@ -289,6 +291,7 @@ public function __construct(
$this->stdout_report_options = $stdout_report_options;
$this->generated_report_options = $generated_report_options;

$this->config->initializePlugins($this);
$file_extensions = $this->config->getFileExtensions();

foreach ($this->config->getProjectDirectories() as $dir_name) {
Expand All @@ -314,8 +317,6 @@ public function __construct(
foreach ($this->config->getProjectFiles() as $file_path) {
$this->addProjectFile($file_path);
}

self::$instance = $this;
}

private function clearCacheDirectoryIfConfigOrComposerLockfileChanged() : void
Expand Down Expand Up @@ -435,7 +436,7 @@ public function server(?string $address = '127.0.0.1:12345', bool $socket_server
}
}

$this->config->initializePlugins($this);
#$this->config->initializePlugins($this);

foreach ($this->config->getProjectDirectories() as $dir_name) {
$this->checkDirWithConfig($dir_name, $this->config);
Expand Down Expand Up @@ -589,7 +590,7 @@ public function check(string $base_dir, bool $is_diff = false): void
$this->codebase->scanner->addFilesToDeepScan($this->project_files);
$this->codebase->analyzer->addFilesToAnalyze($this->project_files);

$this->config->initializePlugins($this);
#$this->config->initializePlugins($this);

$this->codebase->scanFiles($this->threads);

Expand All @@ -612,7 +613,7 @@ public function check(string $base_dir, bool $is_diff = false): void

$this->checkDiffFilesWithConfig($this->config, $file_list);

$this->config->initializePlugins($this);
#$this->config->initializePlugins($this);

$this->codebase->scanFiles($this->threads);
} else {
Expand Down Expand Up @@ -994,7 +995,7 @@ public function checkDir(string $dir_name): void

$this->progress->startScanningFiles();

$this->config->initializePlugins($this);
#$this->config->initializePlugins($this);

$this->codebase->scanFiles($this->threads);

Expand Down Expand Up @@ -1125,7 +1126,7 @@ public function checkFile(string $file_path): void

$this->progress->startScanningFiles();

$this->config->initializePlugins($this);
#$this->config->initializePlugins($this);

$this->codebase->scanFiles($this->threads);

Expand Down Expand Up @@ -1166,8 +1167,7 @@ public function checkPaths(array $paths_to_check): void

$this->progress->startScanningFiles();

$this->config->initializePlugins($this);

#$this->config->initializePlugins($this);

$this->codebase->scanFiles($this->threads);

Expand Down
4 changes: 3 additions & 1 deletion src/Psalm/PluginRegistrationSocket.php
Expand Up @@ -204,7 +204,9 @@ public function getAdditionalFileExtensions(): array
*/
private function addFileExtension(string $fileExtension): void
{
if (!in_array($fileExtension, $this->config->getFileExtensions(), true)) {
if (!in_array($fileExtension, $this->additionalFileExtensions, true)
&& !in_array($fileExtension, $this->config->getFileExtensions(), true)
) {
$this->additionalFileExtensions[] = $fileExtension;
}
}
Expand Down

0 comments on commit c1eb612

Please sign in to comment.