Skip to content

Commit

Permalink
Allow usage with PHP 8.x, fix a deprecation notice (#21)
Browse files Browse the repository at this point in the history
This declares compatibility with PHP 8.0/8.1 and fixes a deprecation notice I encountered.

Does not use real `mixed` type hints to avoid PHP 8.0 as a minimum requirement.

Closes #15.
  • Loading branch information
mpdude authored May 5, 2022
1 parent c8d1315 commit 481cc6c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},

"require": {
"php": "^7.2",
"php": "^7.2|8.0.*|8.1.*",
"ext-json": "*",
"psr/container": "^1.0",
"psr/log": "^1.1",
Expand Down
26 changes: 20 additions & 6 deletions src/Tree/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,40 @@ public function isActivePath()
return $this === $ap || $this->hasDescendant($ap);
}

public function offsetExists($offset)
/**
* @param mixed $offset
*/
public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}

/**
* @param mixed $offset
*
* @return mixed|null
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($offset);
}

public function offsetSet($offset, $value)
/**
* @param mixed $offset
* @param mixed $value
*/
public function offsetSet($offset, $value): void
{
return $this->set($offset, $value);
$this->set($offset, $value);
}

public function offsetUnset($offset)
/**
* @param mixed $offset
*/
public function offsetUnset($offset): void
{
unset($this->data[$offset]);

return $this;
}

protected function setParent(self $p)
Expand Down

0 comments on commit 481cc6c

Please sign in to comment.