Skip to content

Commit

Permalink
Use better return type for SimpleXMLElement::offsetGet
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 18, 2020
1 parent 38cccb8 commit 6e80887
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
$plugin_config = $plugin->children();
}

$config->addPluginClass($plugin_class_name, $plugin_config);
$config->addPluginClass((string) $plugin_class_name, $plugin_config);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ public static function getArrayAccessTypeGivenOffset(

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;

Expand Down
6 changes: 6 additions & 0 deletions tests/ArrayAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,12 @@ public function pop(): void {
}
}'
],
'simpleXmlArrayFetch' => [
'<?php
function foo(SimpleXMLElement $s) : SimpleXMLElement {
return $s["a"];
}',
],
];
}

Expand Down

0 comments on commit 6e80887

Please sign in to comment.