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

Undeclared "by reference" arguments are ignored #27

Merged
merged 2 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fixing code generation for optional "by reference" parameters.
Closes #26
  • Loading branch information
moufmouf committed Sep 14, 2018
commit 03998c2fcfe93de64d33bfad9465521d239551f3
12 changes: 2 additions & 10 deletions generated/apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ function apc_compile_file(string $filename, bool $atomic = true)
function apc_dec(string $key, int $step = 1, bool &$success = null): int
{
error_clear_last();
if ($success !== null) {
$result = \apc_dec($key, $step, $success);
} else {
$result = \apc_dec($key, $step);
}
$result = \apc_dec($key, $step, $success);
if ($result === false) {
throw ApcException::createFromPhpError();
}
Expand Down Expand Up @@ -164,11 +160,7 @@ function apc_delete(string $key)
function apc_inc(string $key, int $step = 1, bool &$success = null): int
{
error_clear_last();
if ($success !== null) {
$result = \apc_inc($key, $step, $success);
} else {
$result = \apc_inc($key, $step);
}
$result = \apc_inc($key, $step, $success);
if ($result === false) {
throw ApcException::createFromPhpError();
}
Expand Down
12 changes: 2 additions & 10 deletions generated/apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ function apcu_cas(string $key, int $old, int $new): void
function apcu_dec(string $key, int $step = 1, bool &$success = null): int
{
error_clear_last();
if ($success !== null) {
$result = \apcu_dec($key, $step, $success);
} else {
$result = \apcu_dec($key, $step);
}
$result = \apcu_dec($key, $step, $success);
if ($result === false) {
throw ApcuException::createFromPhpError();
}
Expand Down Expand Up @@ -88,11 +84,7 @@ function apcu_delete($key): void
function apcu_inc(string $key, int $step = 1, bool &$success = null): int
{
error_clear_last();
if ($success !== null) {
$result = \apcu_inc($key, $step, $success);
} else {
$result = \apcu_inc($key, $step);
}
$result = \apcu_inc($key, $step, $success);
if ($result === false) {
throw ApcuException::createFromPhpError();
}
Expand Down
6 changes: 1 addition & 5 deletions generated/ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
function ftp_alloc($ftp_stream, int $filesize, string &$result = null): void
{
error_clear_last();
if ($result !== null) {
$result = \ftp_alloc($ftp_stream, $filesize, $result);
} else {
$result = \ftp_alloc($ftp_stream, $filesize);
}
$result = \ftp_alloc($ftp_stream, $filesize, $result);
if ($result === false) {
throw FtpException::createFromPhpError();
}
Expand Down
28 changes: 3 additions & 25 deletions generated/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ function ldap_bind($link_identifier, string $bind_rdn = null, string $bind_passw
function ldap_control_paged_result_response($link, $result, string &$cookie = null, int &$estimated = null): void
{
error_clear_last();
if ($estimated !== null) {
$result = \ldap_control_paged_result_response($link, $result, $cookie, $estimated);
} elseif ($cookie !== null) {
$result = \ldap_control_paged_result_response($link, $result, $cookie);
} else {
$result = \ldap_control_paged_result_response($link, $result);
}
$result = \ldap_control_paged_result_response($link, $result, $cookie, $estimated);
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down Expand Up @@ -968,13 +962,7 @@ function ldap_next_attribute($link_identifier, $result_entry_identifier): string
function ldap_parse_exop($link, $result, string &$retdata = null, string &$retoid = null): void
{
error_clear_last();
if ($retoid !== null) {
$result = \ldap_parse_exop($link, $result, $retdata, $retoid);
} elseif ($retdata !== null) {
$result = \ldap_parse_exop($link, $result, $retdata);
} else {
$result = \ldap_parse_exop($link, $result);
}
$result = \ldap_parse_exop($link, $result, $retdata, $retoid);
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down Expand Up @@ -1003,17 +991,7 @@ function ldap_parse_exop($link, $result, string &$retdata = null, string &$retoi
function ldap_parse_result($link, $result, int &$errcode, string &$matcheddn = null, string &$errmsg = null, array &$referrals = null, array &$serverctrls = null): void
{
error_clear_last();
if ($serverctrls !== null) {
$result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls);
} elseif ($referrals !== null) {
$result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals);
} elseif ($errmsg !== null) {
$result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg);
} elseif ($matcheddn !== null) {
$result = \ldap_parse_result($link, $result, $errcode, $matcheddn);
} else {
$result = \ldap_parse_result($link, $result, $errcode);
}
$result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls);
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down
6 changes: 1 addition & 5 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,7 @@ function mb_ord(string $str, string $encoding = null): int
function mb_parse_str(string $encoded_string, array &$result = null): void
{
error_clear_last();
if ($result !== null) {
$result = \mb_parse_str($encoded_string, $result);
} else {
$result = \mb_parse_str($encoded_string);
}
$result = \mb_parse_str($encoded_string, $result);
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand Down
10 changes: 1 addition & 9 deletions generated/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,7 @@ function closelog(): void
function dns_get_record(string $hostname, int $type = DNS_ANY, array &$authns = null, array &$addtl = null, bool $raw = false): array
{
error_clear_last();
if ($raw !== false) {
$result = \dns_get_record($hostname, $type, $authns, $addtl, $raw);
} elseif ($addtl !== null) {
$result = \dns_get_record($hostname, $type, $authns, $addtl);
} elseif ($authns !== null) {
$result = \dns_get_record($hostname, $type, $authns);
} else {
$result = \dns_get_record($hostname, $type);
}
$result = \dns_get_record($hostname, $type, $authns, $addtl, $raw);
if ($result === false) {
throw NetworkException::createFromPhpError();
}
Expand Down
12 changes: 2 additions & 10 deletions generated/openssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,7 @@ function openssl_public_encrypt(string $data, string &$crypted, $key, int $paddi
function openssl_random_pseudo_bytes(int $length, bool &$crypto_strong = null): string
{
error_clear_last();
if ($crypto_strong !== null) {
$result = \openssl_random_pseudo_bytes($length, $crypto_strong);
} else {
$result = \openssl_random_pseudo_bytes($length);
}
$result = \openssl_random_pseudo_bytes($length, $crypto_strong);
if ($result === false) {
throw OpensslException::createFromPhpError();
}
Expand Down Expand Up @@ -929,11 +925,7 @@ function openssl_random_pseudo_bytes(int $length, bool &$crypto_strong = null):
function openssl_seal(string $data, string &$sealed_data, array &$env_keys, array $pub_key_ids, string $method = "RC4", string &$iv = null): int
{
error_clear_last();
if ($iv !== null) {
$result = \openssl_seal($data, $sealed_data, $env_keys, $pub_key_ids, $method, $iv);
} else {
$result = \openssl_seal($data, $sealed_data, $env_keys, $pub_key_ids, $method);
}
$result = \openssl_seal($data, $sealed_data, $env_keys, $pub_key_ids, $method, $iv);
if ($result === false) {
throw OpensslException::createFromPhpError();
}
Expand Down
6 changes: 1 addition & 5 deletions generated/pcntl.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ function pcntl_signal_dispatch(): void
function pcntl_sigprocmask(int $how, array $set, array &$oldset = null): void
{
error_clear_last();
if ($oldset !== null) {
$result = \pcntl_sigprocmask($how, $set, $oldset);
} else {
$result = \pcntl_sigprocmask($how, $set);
}
$result = \pcntl_sigprocmask($how, $set, $oldset);
if ($result === false) {
throw PcntlException::createFromPhpError();
}
Expand Down
20 changes: 2 additions & 18 deletions generated/pcre.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,7 @@
function preg_match_all(string $pattern, string $subject, array &$matches = null, int $flags = PREG_PATTERN_ORDER, int $offset = 0): int
{
error_clear_last();
if ($offset !== 0) {
$result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
} elseif ($flags !== PREG_PATTERN_ORDER) {
$result = \preg_match_all($pattern, $subject, $matches, $flags);
} elseif ($matches !== null) {
$result = \preg_match_all($pattern, $subject, $matches);
} else {
$result = \preg_match_all($pattern, $subject);
}
$result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
if ($result === false) {
throw PcreException::createFromPhpError();
}
Expand Down Expand Up @@ -596,15 +588,7 @@ function preg_match_all(string $pattern, string $subject, array &$matches = null
function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int
{
error_clear_last();
if ($offset !== 0) {
$result = \preg_match($pattern, $subject, $matches, $flags, $offset);
} elseif ($flags !== 0) {
$result = \preg_match($pattern, $subject, $matches, $flags);
} elseif ($matches !== null) {
$result = \preg_match($pattern, $subject, $matches);
} else {
$result = \preg_match($pattern, $subject);
}
$result = \preg_match($pattern, $subject, $matches, $flags, $offset);
if ($result === false) {
throw PcreException::createFromPhpError();
}
Expand Down
12 changes: 2 additions & 10 deletions generated/sem.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ function msg_queue_exists(int $key): void
function msg_receive($queue, int $desiredmsgtype, int &$msgtype, int $maxsize, &$message, bool $unserialize = true, int $flags = 0, int &$errorcode = null): void
{
error_clear_last();
if ($errorcode !== null) {
$result = \msg_receive($queue, $desiredmsgtype, $msgtype, $maxsize, $message, $unserialize, $flags, $errorcode);
} else {
$result = \msg_receive($queue, $desiredmsgtype, $msgtype, $maxsize, $message, $unserialize, $flags);
}
$result = \msg_receive($queue, $desiredmsgtype, $msgtype, $maxsize, $message, $unserialize, $flags, $errorcode);
if ($result === false) {
throw SemException::createFromPhpError();
}
Expand Down Expand Up @@ -158,11 +154,7 @@ function msg_remove_queue($queue): void
function msg_send($queue, int $msgtype, $message, bool $serialize = true, bool $blocking = true, int &$errorcode = null): void
{
error_clear_last();
if ($errorcode !== null) {
$result = \msg_send($queue, $msgtype, $message, $serialize, $blocking, $errorcode);
} else {
$result = \msg_send($queue, $msgtype, $message, $serialize, $blocking);
}
$result = \msg_send($queue, $msgtype, $message, $serialize, $blocking, $errorcode);
if ($result === false) {
throw SemException::createFromPhpError();
}
Expand Down
14 changes: 2 additions & 12 deletions generated/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,7 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void
function stream_socket_accept($server_socket, float $timeout = null, string &$peername = null)
{
error_clear_last();
if ($peername !== null) {
$result = \stream_socket_accept($server_socket, $timeout, $peername);
} else {
$result = \stream_socket_accept($server_socket, $timeout);
}
$result = \stream_socket_accept($server_socket, $timeout, $peername);
if ($result === false) {
throw StreamException::createFromPhpError();
}
Expand Down Expand Up @@ -410,14 +406,8 @@ function stream_socket_server(string $local_socket, int &$errno = null, string &
error_clear_last();
if ($context !== null) {
$result = \stream_socket_server($local_socket, $errno, $errstr, $flags, $context);
} elseif ($flags !== STREAM_SERVER_BIND | STREAM_SERVER_LISTEN) {
$result = \stream_socket_server($local_socket, $errno, $errstr, $flags);
} elseif ($errstr !== null) {
$result = \stream_socket_server($local_socket, $errno, $errstr);
} elseif ($errno !== null) {
$result = \stream_socket_server($local_socket, $errno);
} else {
$result = \stream_socket_server($local_socket);
$result = \stream_socket_server($local_socket, $errno, $errstr, $flags);
}
if ($result === false) {
throw StreamException::createFromPhpError();
Expand Down
24 changes: 3 additions & 21 deletions generated/yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@
function yaml_parse_file(string $filename, int $pos = 0, int &$ndocs = null, array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$result = \yaml_parse_file($filename, $pos, $ndocs, $callbacks);
} elseif ($ndocs !== null) {
$result = \yaml_parse_file($filename, $pos, $ndocs);
} else {
$result = \yaml_parse_file($filename, $pos);
}
$result = \yaml_parse_file($filename, $pos, $ndocs, $callbacks);
if ($result === false) {
throw YamlException::createFromPhpError();
}
Expand Down Expand Up @@ -65,13 +59,7 @@ function yaml_parse_file(string $filename, int $pos = 0, int &$ndocs = null, arr
function yaml_parse_url(string $url, int $pos = 0, int &$ndocs = null, array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$result = \yaml_parse_url($url, $pos, $ndocs, $callbacks);
} elseif ($ndocs !== null) {
$result = \yaml_parse_url($url, $pos, $ndocs);
} else {
$result = \yaml_parse_url($url, $pos);
}
$result = \yaml_parse_url($url, $pos, $ndocs, $callbacks);
if ($result === false) {
throw YamlException::createFromPhpError();
}
Expand Down Expand Up @@ -101,13 +89,7 @@ function yaml_parse_url(string $url, int $pos = 0, int &$ndocs = null, array $ca
function yaml_parse(string $input, int $pos = 0, int &$ndocs = null, array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$result = \yaml_parse($input, $pos, $ndocs, $callbacks);
} elseif ($ndocs !== null) {
$result = \yaml_parse($input, $pos, $ndocs);
} else {
$result = \yaml_parse($input, $pos);
}
$result = \yaml_parse($input, $pos, $ndocs, $callbacks);
if ($result === false) {
throw YamlException::createFromPhpError();
}
Expand Down
6 changes: 1 addition & 5 deletions generated/yaz.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,7 @@ function yaz_search($id, string $type, string $query): void
function yaz_wait(array &$options = null)
{
error_clear_last();
if ($options !== null) {
$result = \yaz_wait($options);
} else {
$result = \yaz_wait();
}
$result = \yaz_wait($options);
if ($result === false) {
throw YazException::createFromPhpError();
}
Expand Down
4 changes: 2 additions & 2 deletions generator/src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ public function getModuleName(): string
}

/**
* The function is overloaded if at least one parameter optional with no default value.
* The function is overloaded if at least one parameter is optional with no default value and this parameter is not by reference.
*
* @return bool
*/
public function isOverloaded(): bool
{
foreach ($this->getFunctionParam() as $parameter) {
if ($parameter->isOptionalWithNoDefault()) {
if ($parameter->isOptionalWithNoDefault() && !$parameter->isByReference()) {
return true;
}
}
Expand Down