Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 8, 2024
1 parent 7b00257 commit ff44cf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 15 additions & 0 deletions tests/PHPStan/Analyser/nsrt/DOMLegacyNamedNodeNap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ public function checkAttributes(DOMNode $node): void {
}
}
}

function basic_node(\DOMNode $node): void {
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
};

function element_node(\DOMElement $node): void
{
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
$attribute = $node->attributes->getNamedItem('class');
if ($attribute === null) {
return;
}
assertType(DOMAttr::class, $attribute);
assertType('string', $attribute->value);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?php

use function PHPStan\Testing\assertType;
namespace DOMNodeStubsAccessProperties;

function basic_node(\DOMNode $node): void {
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
var_dump($node->attributes);
};

function element_node(\DOMElement $node): void
{
assertType(DOMNamedNodeMap::class . '<' . DOMAttr::class . '>', $node->attributes);
$attribute = $node->attributes->getNamedItem('class');
if ($attribute === null) {
return;
}
assertType(DOMAttr::class, $attribute);
assertType('string', $attribute->value);
echo $attribute->value;
}

0 comments on commit ff44cf0

Please sign in to comment.