1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Create empty params by default for SplObjectStorage

Fixes #4055
This commit is contained in:
Brown 2020-08-25 11:52:21 -04:00
parent 2b060b75d3
commit 346d475f55
2 changed files with 12 additions and 1 deletions

View File

@ -595,7 +595,11 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
$template_result->upper_bounds
);
} else {
$generic_param_type = array_values($base_type)[0][0];
if ($fq_class_name === 'SplObjectStorage') {
$generic_param_type = Type::getEmpty();
} else {
$generic_param_type = array_values($base_type)[0][0];
}
}
$generic_param_type->had_template = true;

View File

@ -910,6 +910,13 @@ class MethodCallTest extends TestCase
echo strlen($a->getValue());
}',
],
'newSplObjectStorageDefaultEmpty' => [
'<?php
$a = new SplObjectStorage();',
[
'$a' => 'SplObjectStorage<empty, empty>',
]
],
];
}