From d5d4702438d0b53a9907a1eac0449b9a119b2ae6 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Fri, 24 Sep 2021 09:57:55 -0500 Subject: [PATCH] Avoid PHP 8.1 deprecation notices. --- lib/Document.php | 6 +++++- lib/XPath.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Document.php b/lib/Document.php index 594b872..61f47a8 100644 --- a/lib/Document.php +++ b/lib/Document.php @@ -31,7 +31,11 @@ class Document extends \DOMDocument implements XPathAware */ public function __construct($version = '1.0', $encoding = null) { - parent::__construct($version, $encoding); + if ($encoding) { + parent::__construct($version, $encoding); + } else { + parent::__construct($version); + } $this->registerNodeClass('DOMElement', 'PhpBench\Dom\Element'); } diff --git a/lib/XPath.php b/lib/XPath.php index 6a8fa96..8ef3483 100644 --- a/lib/XPath.php +++ b/lib/XPath.php @@ -23,6 +23,7 @@ class XPath extends \DOMXPath /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function evaluate($expression, $contextnode = null, $registerNodeNS = true) { $result = $this->execute('evaluate', 'expression', $expression, $contextnode, $registerNodeNS); @@ -33,6 +34,7 @@ public function evaluate($expression, $contextnode = null, $registerNodeNS = tru /** * @return DOMNodeList */ + #[\ReturnTypeWillChange] public function query($expression, $contextnode = null, $registerNodeNS = true) { return $this->execute('query', 'query', $expression, $contextnode, $registerNodeNS); @@ -64,6 +66,7 @@ public function queryOne(string $expr, DOMNode $contextEl = null, bool $register * * @return mixed */ + #[\ReturnTypeWillChange] private function execute(string $method, string $context, string $query, DOMNode $contextEl = null, bool $registerNodeNs = false) { libxml_use_internal_errors(true);