Skip to content

Commit

Permalink
Add test for InvalidComparisonOperationRule for offset accessing Simp…
Browse files Browse the repository at this point in the history
…leXMLElement.
  • Loading branch information
mad-briller committed Feb 6, 2024
1 parent 5fd5530 commit 1b5a7f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -168,4 +168,10 @@ public function testRuleWithNullsafeVariant(): void
]);
}


public function testRuleWithSimpleXml(): void
{
$this->analyse([__DIR__ . '/data/bug-9456-xml.php'], []);
}

}
19 changes: 19 additions & 0 deletions tests/PHPStan/Rules/Operators/data/bug-9456-xml.php
@@ -0,0 +1,19 @@
<?php

namespace Bug9456Xml;

use SimpleXMLElement;

/**
* @param SimpleXMLElement $xml
*/
function simplexml($xml): void
{
if (isset($xml->modules)) {
foreach ($xml->modules->module as $data) {
/** @var SimpleXMLElement $data */
$attributes = $data->attributes();
$install = ($attributes['install'] == 1) ? true : false;
}
}
}

0 comments on commit 1b5a7f8

Please sign in to comment.