Skip to content

Commit

Permalink
Merge pull request #76 from miken32/develop
Browse files Browse the repository at this point in the history
Resolve deprecation notices in modern PHP
  • Loading branch information
boenrobot committed Apr 21, 2022
2 parents a03e1ce + 82a45e8 commit 4046696
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"wiki": "https://github.com/pear2/Net_RouterOS/wiki"
},
"require": {
"php": ">=5.3.0",
"php": ">=5.3",
"pear2/net_transmitter": ">=1.0.0b1 || dev-develop@dev"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions src/PEAR2/Net/RouterOS/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ protected function getAttribute($name)
* @see getArgument()
* @see setArgument()
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayObject($this->attributes);
Expand All @@ -190,6 +191,7 @@ public function getIterator()
*
* @return int The number of attributes.
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->attributes);
Expand Down
2 changes: 1 addition & 1 deletion src/PEAR2/Net/RouterOS/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private function _receive(
$word = $com->getNextWordAsStream();
$ind = fread($word, 1);
if ('=' === $ind || '.' === $ind) {
$prefix = stream_get_line($word, null, '=');
$prefix = stream_get_line($word, 0, '=');
}
if ('=' === $ind) {
$value = fopen('php://temp', 'r+b');
Expand Down
24 changes: 16 additions & 8 deletions src/PEAR2/Net/RouterOS/ResponseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public function __debugInfo()
*
* @return int The number of responses in the collection.
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->responses);
Expand All @@ -308,6 +309,7 @@ public function count()
*
* @return bool TRUE if the offset exists, FALSE otherwise.
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return is_int($offset)
Expand Down Expand Up @@ -379,21 +381,21 @@ public function rewind()
/**
* Moves the position pointer to a specified position.
*
* @param int|string $position The position to move to. If the collection is
* @param int|string $offset The position to move to. If the collection is
* indexed, you can also supply a value to move the pointer to.
* A non-existent index will move the pointer to "-1".
*
* @return Response|false The {@link Response} at the specified position,
* or FALSE if the specified position is not valid.
*/
public function seek($position)
public function seek($offset)
{
$this->position = is_int($position)
? ($position >= 0
? $position
: count($this->responses) + $position)
: ($this->offsetExists($position)
? $this->responsesIndex[$this->index][$position]
$this->position = is_int($offset)
? ($offset >= 0
? $offset
: count($this->responses) + $offset)
: ($this->offsetExists($offset)
? $this->responsesIndex[$this->index][$offset]
: -1);
return $this->current();
}
Expand All @@ -404,6 +406,7 @@ public function seek($position)
* @return Response|false The next {@link Response} object,
* or FALSE if the position is not valid.
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->position;
Expand All @@ -416,6 +419,7 @@ public function next()
* @return Response|false The response at the current pointer position,
* or FALSE if the position is not valid.
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->valid() ? $this->responses[$this->position] : false;
Expand All @@ -427,6 +431,7 @@ public function current()
* @return Response|false The next {@link Response} object,
* or FALSE if the position is not valid.
*/
#[\ReturnTypeWillChange]
public function prev()
{
--$this->position;
Expand All @@ -440,6 +445,7 @@ public function prev()
* @return Response|false The last response in the collection,
* or FALSE if the collection is empty.
*/
#[\ReturnTypeWillChange]
public function end()
{
$this->position = count($this->responses) - 1;
Expand All @@ -453,6 +459,7 @@ public function end()
* i.e. the pointer position itself, or FALSE if the position
* is not valid.
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->valid() ? $this->position : false;
Expand All @@ -463,6 +470,7 @@ public function key()
*
* @return bool TRUE if the pointer is valid, FALSE otherwise.
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->offsetExists($this->position);
Expand Down
1 change: 1 addition & 0 deletions src/PEAR2/Net/RouterOS/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ public function move($numbers, $destination = null)
* @return int The number of items, or -1 on failure (e.g. if the
* current menu does not have a "print" command or items to be counted).
*/
#[\ReturnTypeWillChange]
public function count(Query $query = null, $from = null)
{
$countRequest = new Request(
Expand Down

0 comments on commit 4046696

Please sign in to comment.