Skip to content

Commit

Permalink
Fixed PHP 8.1 deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvanhoutte committed Dec 9, 2021
1 parent f6f8ab6 commit e1b7bd3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
22 changes: 15 additions & 7 deletions src/Network.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace IPTools;

use ReturnTypeWillChange;

/**
* @author Safarov Alisher <alisher.safarov@outlook.com>
* @link https://github.com/S1lentium/IPTools
Expand Down Expand Up @@ -51,7 +53,7 @@ public static function parse($data)
$ip = IP::parse($matches[1]);
$netmask = self::prefix2netmask((int)$matches[2], $ip->getVersion());
} elseif (strpos($data,' ')) {
list($ip, $netmask) = explode(' ', $data, 2);
[$ip, $netmask] = explode(' ', $data, 2);
$ip = IP::parse($ip);
$netmask = IP::parse($netmask);
} else {
Expand Down Expand Up @@ -323,41 +325,47 @@ public function moveTo($prefixLength)
/**
* @return IP
*/
public function current()
#[ReturnTypeWillChange]
public function current()
{
return $this->getFirstIP()->next($this->position);
}

/**
* @return int
*/
public function key()
#[ReturnTypeWillChange]
public function key()
{
return $this->position;
}

public function next()
#[ReturnTypeWillChange]
public function next()
{
++$this->position;
}

public function rewind()
#[ReturnTypeWillChange]
public function rewind()
{
$this->position = 0;
}

/**
* @return bool
*/
public function valid()
#[ReturnTypeWillChange]
public function valid()
{
return strcmp($this->getFirstIP()->next($this->position)->inAddr(), $this->getLastIP()->inAddr()) <= 0;
}

/**
* @return int
*/
public function count()
#[ReturnTypeWillChange]
public function count()
{
return (integer)$this->getBlockSize();
}
Expand Down
22 changes: 15 additions & 7 deletions src/Range.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace IPTools;

use ReturnTypeWillChange;

/**
* @author Safarov Alisher <alisher.safarov@outlook.com>
* @link https://github.com/S1lentium/IPTools
Expand Down Expand Up @@ -47,7 +49,7 @@ public static function parse($data)
$firstIP = IP::parse(str_replace('*', '0', $data));
$lastIP = IP::parse(str_replace('*', '255', $data));
} elseif (strpos($data, '-')) {
list($first, $last) = explode('-', $data, 2);
[$first, $last] = explode('-', $data, 2);
$firstIP = IP::parse($first);
$lastIP = IP::parse($last);
} else {
Expand Down Expand Up @@ -186,41 +188,47 @@ public function getSpanNetwork()
/**
* @return IP
*/
public function current()
#[ReturnTypeWillChange]
public function current()
{
return $this->firstIP->next($this->position);
}

/**
* @return int
*/
public function key()
#[ReturnTypeWillChange]
public function key()
{
return $this->position;
}

public function next()
#[ReturnTypeWillChange]
public function next()
{
++$this->position;
}

public function rewind()
#[ReturnTypeWillChange]
public function rewind()
{
$this->position = 0;
}

/**
* @return bool
*/
public function valid()
#[ReturnTypeWillChange]
public function valid()
{
return strcmp($this->firstIP->next($this->position)->inAddr(), $this->lastIP->inAddr()) <= 0;
}

/**
* @return int
*/
public function count()
#[ReturnTypeWillChange]
public function count()
{
return (integer)bcadd(bcsub($this->lastIP->toLong(), $this->firstIP->toLong()), 1);
}
Expand Down

0 comments on commit e1b7bd3

Please sign in to comment.