Skip to content

Commit

Permalink
Update TestBuilder.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Jan 23, 2024
1 parent 913bc24 commit 7e448ac
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/TestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psalm\Aliases;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider\ClassLikeStorageProvider;
use RuntimeException;

use Throwable;
use function array_key_exists;
use function array_key_first;
use function array_key_last;
Expand Down Expand Up @@ -202,15 +205,11 @@ public function build(string $file): string

private function check(string $file): array
{
$codebase = $this->projectAnalyzer->getCodebase();

$this->projectAnalyzer->checkFile($file);

$codebase->addFilesToAnalyze([
$file => $file,
]);

$namespace = null;
$codebase = $this->projectAnalyzer->getCodebase();
foreach ($codebase->file_storage_provider->get($file)->namespace_aliases as $aliases) {
if (! $aliases instanceof Aliases) {
continue;
Expand Down Expand Up @@ -299,11 +298,16 @@ private function check(string $file): array
}
$classes[$namespace][$className]['Imports'] = array_unique($imports);
$classes[$namespace][$className]['Methods'] = $methods;

unset($imports, $methods, $className, $fullyQualifiedClassName, $lastSlash, $location, $params);
}

$codebase->invalidateInformationForFile($file);
// try {
// $codebase->invalidateInformationForFile($file);
// } catch (Throwable) {}

// dump(gc_collect_cycles());

// FileAnalyzer::clearCache();
// ClassLikeStorageProvider::deleteAll();

return $classes;
}
Expand Down

0 comments on commit 7e448ac

Please sign in to comment.