Skip to content

Commit

Permalink
Fix for classes what vimeo#8503 fixed for functions (as some issues d…
Browse files Browse the repository at this point in the history
…idn't report for other reasons, which were solved since then)
  • Loading branch information
kkmuffme committed Nov 16, 2023
1 parent 2d197f0 commit 29e87b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -176,6 +176,15 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool
if ($this->codebase->classlike_storage_provider->has($fq_classlike_name_lc)) {
$duplicate_storage = $this->codebase->classlike_storage_provider->get($fq_classlike_name_lc);

// don't override data from files that are getting analyzed with data from stubs
// if the stubs contain the same class
if (!$duplicate_storage->stubbed
&& $this->codebase->register_stub_files
&& $duplicate_storage->stmt_location
&& $this->config->isInProjectDirs($duplicate_storage->stmt_location->file_path)) {
return false;
}

if (!$this->codebase->register_stub_files) {
if (!$duplicate_storage->stmt_location
|| $duplicate_storage->stmt_location->file_path !== $this->file_path
Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php
Expand Up @@ -152,13 +152,13 @@ public function enterNode(PhpParser\Node $node): ?int
$this->namespace_name,
);

$this->classlike_node_scanners[] = $classlike_node_scanner;

if ($classlike_node_scanner->start($node) === false) {
$this->bad_classes[spl_object_id($node)] = true;
return PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
return PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

$this->classlike_node_scanners[] = $classlike_node_scanner;

$this->type_aliases = array_merge($this->type_aliases, $classlike_node_scanner->type_aliases);
} elseif ($node instanceof PhpParser\Node\Stmt\TryCatch) {
foreach ($node->catches as $catch) {
Expand Down

0 comments on commit 29e87b0

Please sign in to comment.