1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Use better return type for SimpleXMLElement::offsetGet

This commit is contained in:
Brown 2020-02-18 10:58:56 -05:00
parent 38cccb8aaf
commit 6e8088776d
3 changed files with 8 additions and 2 deletions

View File

@ -962,7 +962,7 @@ class Config
$plugin_config = $plugin->children();
}
$config->addPluginClass($plugin_class_name, $plugin_config);
$config->addPluginClass((string) $plugin_class_name, $plugin_config);
}
}
}

View File

@ -1111,7 +1111,7 @@ class ArrayFetchAnalyzer
if ($type instanceof TNamedObject) {
if (strtolower($type->value) === 'simplexmlelement') {
$array_access_type = Type::getMixed();
$array_access_type = new Type\Union([new TNamedObject('SimpleXMLElement')]);
} elseif (strtolower($type->value) === 'domnodelist' && $stmt->dim) {
$old_data_provider = $statements_analyzer->node_data;

View File

@ -895,6 +895,12 @@ class ArrayAccessTest extends TestCase
}
}'
],
'simpleXmlArrayFetch' => [
'<?php
function foo(SimpleXMLElement $s) : SimpleXMLElement {
return $s["a"];
}',
],
];
}