diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php index ca882a0c6dd..a05723d923f 100644 --- a/src/Psalm/Internal/Codebase/Functions.php +++ b/src/Psalm/Internal/Codebase/Functions.php @@ -84,8 +84,9 @@ public function getStorage( $function_id = substr($function_id, 1); } + $from_stubs = false; if (isset(self::$stubbed_functions[$function_id])) { - return self::$stubbed_functions[$function_id]; + $from_stubs = self::$stubbed_functions[$function_id]; } $file_storage = null; @@ -117,6 +118,10 @@ public function getStorage( return $this->reflection->getFunctionStorage($function_id); } + if ($from_stubs) { + return $from_stubs; + } + throw new UnexpectedValueException( 'Expecting non-empty $root_file_path and $checked_file_path' ); @@ -135,6 +140,10 @@ public function getStorage( } } + if ($from_stubs) { + return $from_stubs; + } + throw new UnexpectedValueException( 'Expecting ' . $function_id . ' to have storage in ' . $checked_file_path ); @@ -145,6 +154,10 @@ public function getStorage( $declaring_file_storage = $this->file_storage_provider->get($declaring_file_path); if (!isset($declaring_file_storage->functions[$function_id])) { + if ($from_stubs) { + return $from_stubs; + } + throw new UnexpectedValueException( 'Not expecting ' . $function_id . ' to not have storage in ' . $declaring_file_path );