Skip to content
Permalink
Browse files

Fix #1627 - don’t stub already-stubbed functions

  • Loading branch information...
muglug committed May 13, 2019
1 parent 7c2fe53 commit bfcf3cdc997c4559077ebbdc014994f2d3450f4c
Showing with 13 additions and 3 deletions.
  1. +5 −1 src/Psalm/Internal/Codebase/Scanner.php
  2. +8 −2 src/Psalm/Internal/Visitor/ReflectorVisitor.php
@@ -632,7 +632,11 @@ private function scanFile(
if ($this->codebase->register_autoload_files) {
foreach ($file_storage->functions as $function_storage) {
$this->codebase->functions->addGlobalFunction($function_storage->cased_name, $function_storage);
if ($this->codebase->register_stub_files
|| $this->codebase->functions->hasStubbedFunction($function_storage->cased_name)
) {
$this->codebase->functions->addGlobalFunction($function_storage->cased_name, $function_storage);
}
}
foreach ($file_storage->constants as $name => $type) {
@@ -1279,7 +1279,10 @@ private function registerFunctionLike(PhpParser\Node\FunctionLike $stmt, $fake_m
$storage = new FunctionLikeStorage();
if ($this->codebase->register_stub_files || $this->codebase->register_autoload_files) {
if (isset($this->file_storage->functions[$function_id])) {
if (isset($this->file_storage->functions[$function_id])
&& ($this->codebase->register_stub_files
|| !$this->codebase->functions->hasStubbedFunction($function_id))
) {
$this->codebase->functions->addGlobalFunction(
$function_id,
$this->file_storage->functions[$function_id]
@@ -1331,7 +1334,10 @@ private function registerFunctionLike(PhpParser\Node\FunctionLike $stmt, $fake_m
}
}
if ($this->codebase->register_stub_files || $this->codebase->register_autoload_files) {
if ($this->codebase->register_stub_files
|| ($this->codebase->register_autoload_files
&& !$this->codebase->functions->hasStubbedFunction($function_id))
) {
$this->codebase->functions->addGlobalFunction($function_id, $storage);
}

0 comments on commit bfcf3cd

Please sign in to comment.
You can’t perform that action at this time.