Skip to content

MixedArgumentTypeCoercion when passing childNodes to a DomNodeList param #5291

@theodorejb

Description

@theodorejb

Psalm 4.4.1 didn't produce an error for this code, but in 4.6.2 I get a the following error whenever I try to pass DomElement->childNodes to a function that takes a DOMNodeList:

MixedArgumentTypeCoercion - 6:14 - Argument 1 of processNodes expects DOMNodeList<DOMNode>, parent type DOMNodeList|null provided

Per the PHP documentation childNodes is never null as the error implies, but even if I call the function inside a "childNodes !== null" block, I still get a MixedArgumentTypeCoercion error saying "Argument 1 of processNodes expects DOMNodeList<DOMNode>, parent type DOMNodeList provided".

Is this a bug in Psalm?

https://psalm.dev/r/22880b1fa7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions