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:
parent
b79b9e9b8c
commit
81223c45e0
@ -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;
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user