Skip to content

Commit

Permalink
Fixed PHP 7.4 compatibility issue where the type hint "mixed" was not…
Browse files Browse the repository at this point in the history
… introduced until PHP 8.

Added #[\ReturnTypeWillChange] hint to htmldoc::offsetGet() and htmldoc::__get().
  • Loading branch information
hexydec committed May 19, 2022
1 parent 0ed8476 commit 8e061cf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/htmldoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
* @param string $var The name of the property to retrieve, currently 'length' and output
* @return mixed The number of children in the object for length, the output config, or null if the parameter doesn't exist
*/
public function __get(string $var) : mixed {
#[\ReturnTypeWillChange]
public function __get(string $var) {
if ($var === 'config') {
return $this->config;
} elseif ($var === 'length') {
Expand All @@ -91,7 +92,7 @@ public function toArray() : array {
* @param mixed $i The key to be updated, can be a string or integer
* @param mixed $value The value of the array key in the children array to be updated
*/
public function offsetSet(mixed $i, mixed $value) : void {
public function offsetSet($i, $value) : void {
$this->children[$i] = $value;
}

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

Expand All @@ -110,7 +111,7 @@ public function offsetExists(mixed $i) : bool {
*
* @param mixed $i The key to be removed
*/
public function offsetUnset(mixed $i) : void {
public function offsetUnset($i) : void {
unset($this->children[$i]);
}

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

0 comments on commit 8e061cf

Please sign in to comment.