Skip to content

Commit

Permalink
Wrap entrypoints into IIFE to protect their variables (#5366)
Browse files Browse the repository at this point in the history
* Wrap entrypoints into IIFE to protect their variables

Fixes #5359

* Add tests for Psalm variable isolation

* Capture environment before registering autoloader
  • Loading branch information
weirdan committed Mar 11, 2021
1 parent 0a4ad57 commit 205fdd1
Show file tree
Hide file tree
Showing 15 changed files with 1,552 additions and 1,428 deletions.
4 changes: 3 additions & 1 deletion src/Psalm/IssueBuffer.php
Expand Up @@ -23,6 +23,7 @@
use function sprintf;
use Psalm\Internal\Analyzer\IssueData;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\ExecutionEnvironment\BuildInfoCollector;
use Psalm\Issue\CodeIssue;
use Psalm\Issue\UnusedPsalmSuppress;
use Psalm\Report\CheckstyleReport;
Expand Down Expand Up @@ -440,6 +441,7 @@ public static function addIssues(array $issues_data): void
*/
public static function finish(
ProjectAnalyzer $project_analyzer,
BuildInfoCollector $build_info_collector,
bool $is_full,
float $start_time,
bool $add_stats = false,
Expand Down Expand Up @@ -542,7 +544,7 @@ function (IssueData $d1, IssueData $d2) : int {
}

$source_control_info = null;
$build_info = (new \Psalm\Internal\ExecutionEnvironment\BuildInfoCollector($_SERVER))->collect();
$build_info = $build_info_collector->collect();

if ($codebase->config->eventDispatcher->after_analysis
|| $codebase->config->eventDispatcher->legacy_after_analysis
Expand Down

0 comments on commit 205fdd1

Please sign in to comment.