diff --git a/generated/functionsList.php b/generated/functionsList.php index 5a60cafc..6a900132 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -422,6 +422,7 @@ 'imap_unsubscribe', 'imap_utf8_to_mutf7', 'inet_ntop', + 'inet_pton', 'inflate_add', 'inflate_get_read_len', 'inflate_init', diff --git a/generated/network.php b/generated/network.php index 523ea19c..6c8fc9d5 100644 --- a/generated/network.php +++ b/generated/network.php @@ -415,6 +415,30 @@ function inet_ntop(string $ip): string } +/** + * This function converts a human readable IPv4 or IPv6 address (if PHP + * was built with IPv6 support enabled) into an address family appropriate + * 32bit or 128bit binary structure. + * + * @param string $ip A human readable IPv4 or IPv6 address. + * @return string Returns the in_addr representation of the given + * ip, or FALSE if a syntactically invalid + * ip is given (for example, an IPv4 address + * without dots or an IPv6 address without colons). + * @throws NetworkException + * + */ +function inet_pton(string $ip): string +{ + error_clear_last(); + $safeResult = \inet_pton($ip); + if ($safeResult === false) { + throw NetworkException::createFromPhpError(); + } + return $safeResult; +} + + /** * Returns an enumeration of network interfaces (adapters) on the local machine. * diff --git a/generator/src/DocPage.php b/generator/src/DocPage.php index 1207bf7d..f0aa002c 100644 --- a/generator/src/DocPage.php +++ b/generator/src/DocPage.php @@ -131,6 +131,11 @@ public function detectFalsyFunction(): bool return true; } + //used to detect inet_pton + if (preg_match("/&false; if a syntactically invalid/m", $returnValuesSection)) { + return true; + } + return false; } diff --git a/rector-migrate.php b/rector-migrate.php index 8d3758b4..e2f8e0f4 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -429,6 +429,7 @@ 'imap_unsubscribe' => 'Safe\imap_unsubscribe', 'imap_utf8_to_mutf7' => 'Safe\imap_utf8_to_mutf7', 'inet_ntop' => 'Safe\inet_ntop', + 'inet_pton' => 'Safe\inet_pton', 'inflate_add' => 'Safe\inflate_add', 'inflate_get_read_len' => 'Safe\inflate_get_read_len', 'inflate_init' => 'Safe\inflate_init',