mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +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;
|
$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;
|
$fq_class_name = (string)$context->self;
|
||||||
|
|
||||||
|
@ -804,6 +804,10 @@ class StatementsChecker extends SourceChecker implements StatementsSource
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->getFilePath() === $path_to_file) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$current_file_checker = $this->getFileChecker();
|
$current_file_checker = $this->getFileChecker();
|
||||||
|
|
||||||
if ($this->getFileChecker()->fileExists($path_to_file)) {
|
if ($this->getFileChecker()->fileExists($path_to_file)) {
|
||||||
|
@ -8,9 +8,8 @@ class IncludeTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider providerTestValidIncludes
|
* @dataProvider providerTestValidIncludes
|
||||||
*
|
*
|
||||||
* @param array $files_to_check
|
* @param array<int, string> $files_to_check
|
||||||
* @param array $files
|
* @param array<string, string> $files
|
||||||
* @param array<string,string> $includes
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -136,16 +135,6 @@ class IncludeTest extends TestCase
|
|||||||
],
|
],
|
||||||
'noInfiniteRequireLoop' => [
|
'noInfiniteRequireLoop' => [
|
||||||
'files' => [
|
'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
|
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
|
||||||
require_once("file2.php");
|
require_once("file2.php");
|
||||||
|
|
||||||
@ -156,9 +145,18 @@ class IncludeTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
class C {}',
|
class C {}',
|
||||||
|
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
|
||||||
|
require_once("file1.php");
|
||||||
|
|
||||||
|
class A{
|
||||||
|
public function fooFoo() : void { }
|
||||||
|
}
|
||||||
|
|
||||||
|
new C();',
|
||||||
],
|
],
|
||||||
'files_to_check' => [
|
'files_to_check' => [
|
||||||
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
|
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
|
||||||
|
getcwd() . DIRECTORY_SEPARATOR . 'file2.php',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user