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

Chained find() on empty resultset returns inconsistent results #63

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

Chained find() on empty resultset returns inconsistent results #63

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)?

->find() returns an object even when no match is found... unless you chain it more than 2 times. it would be beneficial if the empty resultset would be consistent no matter how many times you query on an blank result.

How can I reproduce it?

$dom = (new voku\helper\HtmlDomParser())->loadHtml('<div> foo bar </div>');
var_dump($dom->find('span', 0));
var_dump($dom->find('span', 0)->find('span', 0));
var_dump($dom->find('span', 0)->find('span', 0)->find('span', 0));
var_dump($dom->find('span', 0)->find('span', 0)->find('span', 0)->find('span', 0));

output:

object(voku\helper\SimpleHtmlDomBlank)[173]
  protected 'node' => null
  private 'classListCache' (voku\helper\AbstractSimpleHtmlDom) => null

object(voku\helper\SimpleHtmlDomNodeBlank)[184]
  private 'storage' (ArrayObject) => 
    array (size=0)
      empty

null

Fatal error: Uncaught Error: Call to a member function find() on null

Does it take minutes, hours or days to fix?

hours

@voku
Copy link
Owner

voku commented Jan 28, 2022

What do you think of this: 6b9fb4a

@voku voku closed this as completed Feb 25, 2022
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