1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #166 - return instead of looping infinitely

This commit is contained in:
Matthew Brown 2017-06-05 21:46:04 +01:00
parent b79b9e9b8c
commit 81223c45e0
3 changed files with 20 additions and 14 deletions

View File

@ -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;

View File

@ -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)) {

View File

@ -8,9 +8,8 @@ class IncludeTest extends TestCase
/**
* @dataProvider providerTestValidIncludes
*
* @param array $files_to_check
* @param array $files
* @param array<string,string> $includes
* @param array<int, string> $files_to_check
* @param array<string, string> $files
*
* @return void
*/
@ -136,16 +135,6 @@ class IncludeTest extends TestCase
],
'noInfiniteRequireLoop' => [
'files' => [
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
require_once("file1.php");
class A{
public function fooFoo() : void {
}
}
new C();',
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
require_once("file2.php");
@ -156,9 +145,18 @@ class IncludeTest extends TestCase
}
class C {}',
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
require_once("file1.php");
class A{
public function fooFoo() : void { }
}
new C();',
],
'files_to_check' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
getcwd() . DIRECTORY_SEPARATOR . 'file2.php',
],
],
];