voku / simple_html_dom

📜 Modern Simple HTML DOM Parser for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for PHP8's Nullsafe operator

heldchen opened this issue · comments

What is this feature about (expected vs actual behaviour)?

PHP 8 added the Nullsafe operator (https://wiki.php.net/rfc/nullsafe_operator) - unfortunately none of the query functions currently return null. maybe you'll find the Nullsafe operator useful as well and might consider adding corresponding functions like findOrNull() & findOneOrNull()? thanks :-)

that would allow performant chaining of complex queries:

$text = $dom->findOneOrNull('something`)?->findOneOrNull('somethingelse`)?->findOneOrNull('somethingelse`)?->text();

accidentially this already partially works (due to #63) but I feel like having proper null returning functions might be more performant as the Nullsafe operator can abort early on.

Does it take minutes, hours or days to fix?

minutes

Please go for it, create a pull request, and we can take a look at it. 👍