$ip = self::sanitizeIP( $ip );
$n = ip2long( $ip );
if ( $n < 0 ) {
- $n += pow( 2, 32 );
+ $n += 2 ** 32;
# On 32-bit platforms (and on Windows), 2^32 does not fit into an int,
# so $n becomes a float. We convert it to string instead.
if ( is_float( $n ) ) {
* to an integer network and a number of bits
*
* @param string $range IP with CIDR prefix
- * @return array(int or string, int)
+ * @return array [int or string, int]
*/
public static function parseCIDR( $range ) {
if ( self::isIPv6( $range ) ) {
}
# Convert to unsigned
if ( $network < 0 ) {
- $network += pow( 2, 32 );
+ $network += 2 ** 32;
}
} else {
$network = false;
$start = $end = false;
} else {
$start = sprintf( '%08X', $network );
- $end = sprintf( '%08X', $network + pow( 2, ( 32 - $bits ) ) - 1 );
+ $end = sprintf( '%08X', $network + 2 ** ( 32 - $bits ) - 1 );
}
// Explicit range
} elseif ( strpos( $range, '-' ) !== false ) {
*
* @param string $range
*
- * @return array(string, int)
+ * @return array [string, int]
*/
private static function parseCIDR6( $range ) {
# Explode into <expanded IP,range>
*
* @param string $range
*
- * @return array(string, string)
+ * @return array [string, string]
*/
private static function parseRange6( $range ) {
# Expand any IPv6 IP