We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 493e2de commit ba4a7cfCopy full SHA for ba4a7cf
tests/PHPStan/Analyser/nsrt/bug-9575.php
@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+namespace Bug9575;
4
5
+use SimpleXMLElement;
6
+use function PHPStan\Testing\assertType;
7
8
+$string = <<<XML
9
+<a>
10
+ <foo name="one" game="lonely">1</foo>
11
+</a>
12
+XML;
13
14
+$xml = new SimpleXMLElement($string);
15
+foreach($xml->foo[0]->attributes() as $a => $b) {
16
+ echo $a,'="',$b,"\"\n";
17
+}
18
19
+assertType('(SimpleXMLElement|null)', $xml->foo);
20
+assertType('(SimpleXMLElement|null)', $xml->foo[0]);
21
+assertType('(SimpleXMLElement|null)', $xml->foobar);
22
+assertType('(SimpleXMLElement|null)', $xml->foo->attributes());
0 commit comments