mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #10134 from weirdan/fix-10132
This commit is contained in:
commit
e085b73f2f
@ -1737,8 +1737,10 @@ class ArrayFetchAnalyzer
|
||||
?Union &$array_access_type,
|
||||
bool &$has_array_access
|
||||
): void {
|
||||
$codebase = $statements_analyzer->getCodebase();
|
||||
if (strtolower($type->value) === 'simplexmlelement'
|
||||
|| $statements_analyzer->getCodebase()->classExtendsOrImplements($type->value, 'SimpleXMLElement')
|
||||
|| ($codebase->classExists($type->value)
|
||||
&& $codebase->classExtendsOrImplements($type->value, 'SimpleXMLElement'))
|
||||
) {
|
||||
$call_array_access_type = new Union([new TNull(), new TNamedObject('SimpleXMLElement')]);
|
||||
} elseif (strtolower($type->value) === 'domnodelist' && $stmt->dim) {
|
||||
|
@ -1199,6 +1199,27 @@ class ArrayAccessTest extends TestCase
|
||||
',
|
||||
'assertions' => ['$a===' => "array{1: 'b'}"],
|
||||
],
|
||||
'noCrashOnUnknownClassArrayAccess' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
|
||||
namespace Psalmtest\Psalmtest;
|
||||
|
||||
use SomeMissingClass;
|
||||
|
||||
class Test
|
||||
{
|
||||
public function f(): void {
|
||||
/** @var SomeMissingClass */
|
||||
$result = null;
|
||||
|
||||
if ($result['errors'] === true) {}
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
'assertions' => [],
|
||||
'ignored_issues' => ['UndefinedDocblockClass'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user