diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index 58bbc488a..bbf835382 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -143,7 +143,11 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo $context->vars_possibly_in_scope['$this'] = true; } - $declaring_method_id = (string)MethodChecker::getDeclaringMethodId($method_id); + $declaring_method_id = MethodChecker::getDeclaringMethodId($method_id); + + if (!is_string($declaring_method_id)) { + throw new \UnexpectedValueException('$declaring_method_id should be a string'); + } $fq_class_name = (string)$context->self; diff --git a/src/Psalm/Checker/StatementsChecker.php b/src/Psalm/Checker/StatementsChecker.php index 4c2c87b78..c75c32a5b 100644 --- a/src/Psalm/Checker/StatementsChecker.php +++ b/src/Psalm/Checker/StatementsChecker.php @@ -804,6 +804,10 @@ class StatementsChecker extends SourceChecker implements StatementsSource return null; } + if ($this->getFilePath() === $path_to_file) { + return null; + } + $current_file_checker = $this->getFileChecker(); if ($this->getFileChecker()->fileExists($path_to_file)) { diff --git a/tests/IncludeTest.php b/tests/IncludeTest.php index c0b115527..4737dfd08 100644 --- a/tests/IncludeTest.php +++ b/tests/IncludeTest.php @@ -8,9 +8,8 @@ class IncludeTest extends TestCase /** * @dataProvider providerTestValidIncludes * - * @param array $files_to_check - * @param array $files - * @param array $includes + * @param array $files_to_check + * @param array $files * * @return void */ @@ -136,16 +135,6 @@ class IncludeTest extends TestCase ], 'noInfiniteRequireLoop' => [ 'files' => [ - getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => ' ' ' [ getcwd() . DIRECTORY_SEPARATOR . 'file1.php', + getcwd() . DIRECTORY_SEPARATOR . 'file2.php', ], ], ];