From c68209b8f3b5ba9143b2c1d293d4f578bb35bb41 Mon Sep 17 00:00:00 2001 From: Brown Date: Fri, 8 Feb 2019 17:41:03 -0500 Subject: [PATCH] Fix #1300 - add functions mentioned in class file where class is used --- src/Psalm/Internal/Codebase/Populator.php | 23 +++++++++++++++++++++++ tests/DummyProject/Bar.php | 7 ++++++- tests/DummyProject/Bat.php | 4 +++- tests/ProjectCheckerTest.php | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Codebase/Populator.php b/src/Psalm/Internal/Codebase/Populator.php index f5b34219a..c92747696 100644 --- a/src/Psalm/Internal/Codebase/Populator.php +++ b/src/Psalm/Internal/Codebase/Populator.php @@ -764,6 +764,29 @@ class Populator ); } + foreach ($storage->referenced_classlikes as $fq_class_name) { + try { + $classlike_storage = $this->classlike_storage_provider->get($fq_class_name); + } catch (\InvalidArgumentException $e) { + continue; + } + + if (!$classlike_storage->location) { + continue; + } + + try { + $included_file_storage = $this->file_storage_provider->get($classlike_storage->location->file_path); + } catch (\InvalidArgumentException $e) { + continue; + } + + $storage->declaring_function_ids = array_merge( + $included_file_storage->declaring_function_ids, + $storage->declaring_function_ids + ); + } + $storage->required_file_paths = $all_required_file_paths; foreach ($all_required_file_paths as $required_file_path) { diff --git a/tests/DummyProject/Bar.php b/tests/DummyProject/Bar.php index 3bc52ca1f..5794c8e81 100644 --- a/tests/DummyProject/Bar.php +++ b/tests/DummyProject/Bar.php @@ -1,6 +1,6 @@ x = "hello"; } } + +function someFunction() : void +{ + echo "here"; +} diff --git a/tests/DummyProject/Bat.php b/tests/DummyProject/Bat.php index 54b682c0a..d6e566c32 100644 --- a/tests/DummyProject/Bat.php +++ b/tests/DummyProject/Bat.php @@ -1,11 +1,13 @@