Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect inet_pton #498

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
'imap_unsubscribe',
'imap_utf8_to_mutf7',
'inet_ntop',
'inet_pton',
'inflate_add',
'inflate_get_read_len',
'inflate_init',
Expand Down
24 changes: 24 additions & 0 deletions generated/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
5 changes: 5 additions & 0 deletions generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions rector-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down