olalav - 2022-12-09

Actually it has to be done something like this, because this function can be called from inside the library, and we want to get the first call that is outside the library.

PS! Is the maintainer active these days? Has been quiet for a while.

diff --git a/HtmlNode.php b/HtmlNode.php
index 9649d37..99dbda4 100644
--- a/HtmlNode.php
+++ b/HtmlNode.php
@@ -549,3 +554,12 @@ class HtmlNode
        {
-               return $this->find($selector, $idx, $lowercase) ?: null;
+               if(!$element = $this->find($selector, $idx, $lowercase)) {
+                       $stack = debug_backtrace();
+                       foreach($stack as $call) {
+                               if(!preg_match("~/simple_html_dom/~", $call["file"])) {
+                                       error_log(sprintf("%s(%s):Element not found: %s", $call["file"], $call["line"], $call["args"][0]));
+                                       break;
+                               }
+                       }
+               }
+               return $element;
        }