mirror of
https://github.com/danog/psalm.git
synced 2024-11-29 20:28:59 +01:00
Fix #5108 - prevent crash on 0 type
This commit is contained in:
parent
5da816f160
commit
4627065d1f
@ -1144,7 +1144,7 @@ class Analyzer
|
||||
string $node_type,
|
||||
PhpParser\Node $parent_node = null
|
||||
): void {
|
||||
if (!$node_type) {
|
||||
if ($node_type === '') {
|
||||
throw new \UnexpectedValueException('non-empty node_type expected');
|
||||
}
|
||||
|
||||
@ -1161,8 +1161,8 @@ class Analyzer
|
||||
string $reference,
|
||||
int $argument_number
|
||||
): void {
|
||||
if (!$reference) {
|
||||
throw new \UnexpectedValueException('non-empty node_type expected');
|
||||
if ($reference === '') {
|
||||
throw new \UnexpectedValueException('non-empty reference expected');
|
||||
}
|
||||
|
||||
$this->argument_map[$file_path][$start_position] = [
|
||||
|
@ -798,4 +798,21 @@ class CompletionTest extends \Psalm\Tests\TestCase
|
||||
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
||||
$this->assertCount(2, $completion_items);
|
||||
}
|
||||
|
||||
public function testNoCrashOnLoopId(): void
|
||||
{
|
||||
$codebase = $this->project_analyzer->getCodebase();
|
||||
$config = $codebase->config;
|
||||
$config->throw_exception = false;
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
for ($x = 0; $x <= 10; $x++) {}'
|
||||
);
|
||||
|
||||
$codebase->file_provider->openFile('somefile.php');
|
||||
$codebase->scanFiles();
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user