From 123eda2af91016bf4d003e90ebc45b44a45cbc62 Mon Sep 17 00:00:00 2001 From: Guy Cohen Date: Sun, 7 Jul 2024 18:52:34 +0000 Subject: [PATCH] fix: deprecated in php8.1 --- composer.json | 4 ++-- gan_node_html.php | 2 +- pQuery.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index aee5edf..0ed2d31 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "tburry/pquery", + "name": "guyavatrade/pquery", "type": "library", - "description": "A jQuery like html dom parser written in php.", + "description": "A jQuery like html dom parser written in php. This fork add fixes for php 8.1", "keywords": ["php", "dom", "ganon"], "license": "LGPL-2.1", "authors": [ diff --git a/gan_node_html.php b/gan_node_html.php index f103dcb..65f768a 100644 --- a/gan_node_html.php +++ b/gan_node_html.php @@ -2352,7 +2352,7 @@ public function before($content) { return $this; } - public function count() { + public function count(): int{ return 1; } diff --git a/pQuery.php b/pQuery.php index 7d451e8..2b3b6a9 100644 --- a/pQuery.php +++ b/pQuery.php @@ -78,7 +78,7 @@ public function clear() { * * @return int Returns the count of matched elements. */ - public function count() { + public function count(): int { return count($this->nodes); } @@ -94,7 +94,7 @@ public function count() { // return $formatter->format($dom); // } - public function getIterator() { + public function getIterator(): Traversable { return new ArrayIterator($this->nodes); } @@ -118,15 +118,15 @@ public function html($value = null) { return $this; } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->nodes[$offset]); } - public function offsetGet($offset) { + public function offsetGet($offset): mixed { return isset($this->nodes[$offset]) ? $this->nodes[$offset] : null; } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { if (is_null($offset) || !isset($this->nodes[$offset])) { throw new \BadMethodCallException("You are not allowed to add new nodes to the pQuery object."); @@ -135,7 +135,7 @@ public function offsetSet($offset, $value) { } } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { if (isset($this->nodes[$offset])) { $this->nodes[$offset]->remove(); unset($this->nodes[$offset]);