1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

add ArrayAccess to SimpleXmlElement (#4934)

* add ArrayAccess to SimpleXmlElement

* add test
This commit is contained in:
orklah 2021-01-06 15:44:12 +01:00 committed by Daniil Gentili
parent d8fea8aabb
commit c2c25ada84
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 25 additions and 1 deletions

View File

@ -2215,7 +2215,7 @@ final class WeakReference
public function get(): ?object;
}
class SimpleXMLElement implements \Stringable, \Countable, \RecursiveIterator
class SimpleXMLElement implements \Stringable, \Countable, \RecursiveIterator, \ArrayAccess
{
/** @return array */
public function getNamespaces(bool $recursive = false)
@ -2284,6 +2284,22 @@ class SimpleXMLElement implements \Stringable, \Countable, \RecursiveIterator
public function getChildren()
{
}
public function offsetExists($offset)
{
}
public function offsetGet($offset)
{
}
public function offsetSet($offset, $value)
{
}
public function offsetUnset($offset)
{
}
}
interface Serializable {

View File

@ -835,6 +835,14 @@ class ArrayAccessTest extends TestCase
return $s["a"];
}',
],
'simpleXmlArrayFetchChildren' => [
'<?php
function iterator(SimpleXMLElement $xml): iterable {
foreach ($xml->children() as $img) {
yield $img["src"] ?? "";
}
}',
],
'assertOnArrayAccess' => [
'<?php
class A {