Skip to content

Commit 8e061cf

Browse files
committed
Fixed PHP 7.4 compatibility issue where the type hint "mixed" was not introduced until PHP 8.
Added #[\ReturnTypeWillChange] hint to htmldoc::offsetGet() and htmldoc::__get().
1 parent 0ed8476 commit 8e061cf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/htmldoc.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
6767
* @param string $var The name of the property to retrieve, currently 'length' and output
6868
* @return mixed The number of children in the object for length, the output config, or null if the parameter doesn't exist
6969
*/
70-
public function __get(string $var) : mixed {
70+
#[\ReturnTypeWillChange]
71+
public function __get(string $var) {
7172
if ($var === 'config') {
7273
return $this->config;
7374
} elseif ($var === 'length') {
@@ -91,7 +92,7 @@ public function toArray() : array {
9192
* @param mixed $i The key to be updated, can be a string or integer
9293
* @param mixed $value The value of the array key in the children array to be updated
9394
*/
94-
public function offsetSet(mixed $i, mixed $value) : void {
95+
public function offsetSet($i, $value) : void {
9596
$this->children[$i] = $value;
9697
}
9798

@@ -101,7 +102,7 @@ public function offsetSet(mixed $i, mixed $value) : void {
101102
* @param mixed $i The key to be checked
102103
* @return bool Whether the key exists in the config array
103104
*/
104-
public function offsetExists(mixed $i) : bool {
105+
public function offsetExists($i) : bool {
105106
return isset($this->children[$i]);
106107
}
107108

@@ -110,7 +111,7 @@ public function offsetExists(mixed $i) : bool {
110111
*
111112
* @param mixed $i The key to be removed
112113
*/
113-
public function offsetUnset(mixed $i) : void {
114+
public function offsetUnset($i) : void {
114115
unset($this->children[$i]);
115116
}
116117

@@ -120,7 +121,8 @@ public function offsetUnset(mixed $i) : void {
120121
* @param mixed $i The key to be accessed, can be a string or integer
121122
* @return mixed An HTMLdoc object containing the child node at the requested position or null if there is no child at the requested position
122123
*/
123-
public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array
124+
#[\ReturnTypeWillChange]
125+
public function offsetGet($i) { // return reference so you can set it like an array
124126
if (isset($this->children[$i])) {
125127
$obj = new htmldoc($this->config);
126128
$obj->collection([$this->children[$i]]);

0 commit comments

Comments
 (0)