From a76ecb425828f4c9bc51c5c7eb7d367188ce2b85 Mon Sep 17 00:00:00 2001 From: Edwin Xu Date: Thu, 5 Mar 2020 22:18:54 +0800 Subject: [PATCH] destroy phpquery document object when destruct Query class --- src/Dom/Query.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Dom/Query.php b/src/Dom/Query.php index 21ca77a..6e1cb11 100644 --- a/src/Dom/Query.php +++ b/src/Dom/Query.php @@ -15,6 +15,9 @@ use Closure; class Query { protected $html; + /** + * @var \phpQueryObject + */ protected $document; protected $rules; protected $range = null; @@ -268,4 +271,15 @@ class Query } return $html; } -} \ No newline at end of file + + protected function destroyDocument() + { + $this->document->unloadDocument(); + unset($this->document); + } + + public function __destruct() + { + $this->destroyDocument(); + } +}