Skip to content

Commit 527ece4

Browse files
committed
Add test
1 parent 7d7fd54 commit 527ece4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,4 +957,12 @@ public function testTraitMixin(): void
957957
$this->analyse([__DIR__ . '/data/trait-mixin.php'], []);
958958
}
959959

960+
public function testDomExtensionLegacyTemplateNodes(): void
961+
{
962+
$this->checkThisOnly = false;
963+
$this->checkUnionTypes = true;
964+
$this->checkDynamicProperties = true;
965+
$this->analyse([__DIR__ . '/data/dom-legacy-ext-template-nodes.php'], []);
966+
}
967+
960968
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
use function PHPStan\Testing\assertType;
4+
5+
function (\DOMNode $node): void {
6+
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
7+
};
8+
9+
function parse(\DOMElement $node): void
10+
{
11+
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
12+
$attribute = $node->attributes->getNamedItem('class');
13+
if ($attribute === null) {
14+
return;
15+
}
16+
assertType(DOMAttr::class, $attribute);
17+
assertType('string', $attribute->value);
18+
}

0 commit comments

Comments
 (0)