Skip to content

Fix PHPStan property.notFound on DOMNameSpaceNode in HasXPath#103

Merged
aik099 merged 1 commit into
hamcrest:masterfrom
pscheit:fix-phpstan-domnode-textcontent
Jun 17, 2026
Merged

Fix PHPStan property.notFound on DOMNameSpaceNode in HasXPath#103
aik099 merged 1 commit into
hamcrest:masterfrom
pscheit:fix-phpstan-domnode-textcontent

Conversation

@pscheit

@pscheit pscheit commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

PHPStan 2.2.x updated its bundled DOM stubs so that iterating a \DOMNodeList now yields DOMNameSpaceNode|DOMNode. DOMNameSpaceNode has no $textContent property, which triggered property.notFound errors at HasXPath::matchesContent() (lines 128 and 134).

Guard the textContent access with an instanceof \DOMNode check so only real DOM nodes are matched/collected.

PHPStan 2.2.x updated its bundled DOM stubs so that iterating a
\DOMNodeList now yields DOMNameSpaceNode|DOMNode. DOMNameSpaceNode has
no $textContent property, which triggered property.notFound errors at
HasXPath::matchesContent() (lines 128 and 134).

Guard the textContent access with an instanceof \DOMNode check so only
real DOM nodes are matched/collected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread hamcrest/Hamcrest/Xml/HasXPath.php
@aik099 aik099 merged commit aa726ae into hamcrest:master Jun 17, 2026
8 checks passed
@aik099

aik099 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Merged. Thank you @pscheit .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants