Skip to content

Commit 29cf42c

Browse files
committed
Add test for InvalidComparisonOperationRule for offset accessing SimpleXMLElement.
1 parent 435f26d commit 29cf42c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/PHPStan/Rules/Operators/InvalidComparisonOperationRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,10 @@ public function testRuleWithNullsafeVariant(): void
168168
]);
169169
}
170170

171+
172+
public function testRuleWithSimpleXml(): void
173+
{
174+
$this->analyse([__DIR__ . '/data/bug-9456-xml.php'], []);
175+
}
176+
171177
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Bug9456Xml;
4+
5+
use SimpleXMLElement;
6+
7+
/**
8+
* @param SimpleXMLElement $xml
9+
*/
10+
function simplexml($xml): void
11+
{
12+
if (isset($xml->modules)) {
13+
foreach ($xml->modules->module as $data) {
14+
/** @var SimpleXMLElement $data */
15+
$attributes = $data->attributes();
16+
$install = ($attributes['install'] == 1) ? true : false;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)