Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PHP8's Nullsafe operator #64

Open
heldchen opened this issue Feb 1, 2021 · 1 comment
Open

Add support for PHP8's Nullsafe operator #64

heldchen opened this issue Feb 1, 2021 · 1 comment

Comments

@heldchen
Copy link

heldchen commented Feb 1, 2021

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

@voku
Copy link
Owner

voku commented Jan 27, 2022

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

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

No branches or pull requests

2 participants