mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #797 - check backup included file for defined function
This commit is contained in:
parent
7c2ec06de8
commit
fb3bc2661e
@ -53,6 +53,7 @@ class Functions
|
||||
}
|
||||
|
||||
$file_path = $statements_checker->getRootFilePath();
|
||||
$checked_file_path = $statements_checker->getFilePath();
|
||||
$file_storage = $this->file_storage_provider->get($file_path);
|
||||
|
||||
$function_checkers = $statements_checker->getFunctionCheckers();
|
||||
@ -71,6 +72,14 @@ class Functions
|
||||
}
|
||||
|
||||
if (!isset($file_storage->declaring_function_ids[$function_id])) {
|
||||
if ($checked_file_path !== $file_path) {
|
||||
$file_storage = $this->file_storage_provider->get($checked_file_path);
|
||||
|
||||
if (isset($file_storage->functions[$function_id])) {
|
||||
return $file_storage->functions[$function_id];
|
||||
}
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException(
|
||||
'Expecting ' . $function_id . ' to have storage in ' . $file_path
|
||||
);
|
||||
|
@ -386,6 +386,17 @@ class IncludeTest extends TestCase
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
|
||||
],
|
||||
],
|
||||
'closureInIncludedFile' => [
|
||||
'files' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
|
||||
require_once("file2.php");',
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
|
||||
return function(): string { return "asd"; };',
|
||||
],
|
||||
'files_to_check' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
|
||||
],
|
||||
],
|
||||
'hoistConstants' => [
|
||||
'files' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
|
||||
|
Loading…
Reference in New Issue
Block a user