Skip to content
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
46 changes: 42 additions & 4 deletions generated/datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,17 @@ function date_sun_info(int $time, float $latitude, float $longitude): array
function date_sunrise(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $gmt_offset = 0)
{
error_clear_last();
$result = \date_sunrise($timestamp, $format, $latitude, $longitude, $zenith, $gmt_offset);
if ($gmt_offset !== 0) {
$result = \date_sunrise($timestamp, $format, $latitude, $longitude, $zenith, $gmt_offset);
} elseif ($zenith !== null) {
$result = \date_sunrise($timestamp, $format, $latitude, $longitude, $zenith);
} elseif ($longitude !== null) {
$result = \date_sunrise($timestamp, $format, $latitude, $longitude);
} elseif ($latitude !== null) {
$result = \date_sunrise($timestamp, $format, $latitude);
} else {
$result = \date_sunrise($timestamp, $format);
}
if ($result === false) {
throw DatetimeException::createFromPhpError();
}
Expand Down Expand Up @@ -328,7 +338,17 @@ function date_sunrise(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $
function date_sunset(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $gmt_offset = 0)
{
error_clear_last();
$result = \date_sunset($timestamp, $format, $latitude, $longitude, $zenith, $gmt_offset);
if ($gmt_offset !== 0) {
$result = \date_sunset($timestamp, $format, $latitude, $longitude, $zenith, $gmt_offset);
} elseif ($zenith !== null) {
$result = \date_sunset($timestamp, $format, $latitude, $longitude, $zenith);
} elseif ($longitude !== null) {
$result = \date_sunset($timestamp, $format, $latitude, $longitude);
} elseif ($latitude !== null) {
$result = \date_sunset($timestamp, $format, $latitude);
} else {
$result = \date_sunset($timestamp, $format);
}
if ($result === false) {
throw DatetimeException::createFromPhpError();
}
Expand Down Expand Up @@ -380,7 +400,21 @@ function date_sunset(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $l
function mktime(int $hour = null, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int
{
error_clear_last();
$result = \mktime($hour, $minute, $second, $month, $day, $year);
if ($year !== null) {
$result = \mktime($hour, $minute, $second, $month, $day, $year);
} elseif ($day !== null) {
$result = \mktime($hour, $minute, $second, $month, $day);
} elseif ($month !== null) {
$result = \mktime($hour, $minute, $second, $month);
} elseif ($second !== null) {
$result = \mktime($hour, $minute, $second);
} elseif ($minute !== null) {
$result = \mktime($hour, $minute);
} elseif ($hour !== null) {
$result = \mktime($hour);
} else {
$result = \mktime();
}
if ($result === false) {
throw DatetimeException::createFromPhpError();
}
Expand Down Expand Up @@ -489,7 +523,11 @@ function strptime(string $date, string $format): array
function strtotime(string $time, int $now = null): int
{
error_clear_last();
$result = \strtotime($time, $now);
if ($now !== null) {
$result = \strtotime($time, $now);
} else {
$result = \strtotime($time);
}
if ($result === false) {
throw DatetimeException::createFromPhpError();
}
Expand Down
4 changes: 3 additions & 1 deletion generated/filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -1346,8 +1346,10 @@ function touch(string $filename, int $time = null, int $atime = null): void
error_clear_last();
if ($atime !== null) {
$result = \touch($filename, $time, $atime);
} else {
} elseif ($time !== null) {
$result = \touch($filename, $time);
} else {
$result = \touch($filename);
}
if ($result === false) {
throw FilesystemException::createFromPhpError();
Expand Down
1 change: 1 addition & 0 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@
'pspell_config_repl',
'pspell_config_runtogether',
'pspell_config_save_repl',
'pspell_new_config',
'pspell_new',
'pspell_save_wordlist',
'pspell_store_replacement',
Expand Down
48 changes: 45 additions & 3 deletions generated/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,21 @@ function ldap_get_values($link_identifier, $result_entry_identifier, string $att
function ldap_list($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null)
{
error_clear_last();
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
if ($serverctrls !== null) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
} elseif ($deref !== LDAP_DEREF_NEVER) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} elseif ($timelimit !== -1) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
} elseif ($sizelimit !== -1) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
} elseif ($attrsonly !== 0) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
} elseif ($attributes !== null) {
$result = \ldap_list($link_identifier, $base_dn, $filter, $attributes);
} else {
$result = \ldap_list($link_identifier, $base_dn, $filter);
}
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down Expand Up @@ -1181,7 +1195,21 @@ function ldap_parse_result($link, $result, int &$errcode, string &$matcheddn = n
function ldap_read($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null)
{
error_clear_last();
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
if ($serverctrls !== null) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
} elseif ($deref !== LDAP_DEREF_NEVER) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} elseif ($timelimit !== -1) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
} elseif ($sizelimit !== -1) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
} elseif ($attrsonly !== 0) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
} elseif ($attributes !== null) {
$result = \ldap_read($link_identifier, $base_dn, $filter, $attributes);
} else {
$result = \ldap_read($link_identifier, $base_dn, $filter);
}
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down Expand Up @@ -1349,7 +1377,21 @@ function ldap_sasl_bind($link, string $binddn = null, string $password = null, s
function ldap_search($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null)
{
error_clear_last();
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
if ($serverctrls !== null) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
} elseif ($deref !== LDAP_DEREF_NEVER) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} elseif ($timelimit !== -1) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
} elseif ($sizelimit !== -1) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
} elseif ($attrsonly !== 0) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
} elseif ($attributes !== null) {
$result = \ldap_search($link_identifier, $base_dn, $filter, $attributes);
} else {
$result = \ldap_search($link_identifier, $base_dn, $filter);
}
if ($result === false) {
throw LdapException::createFromPhpError();
}
Expand Down
30 changes: 25 additions & 5 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
function mb_check_encoding(string $var = null, string $encoding = null): void
{
error_clear_last();
$result = \mb_check_encoding($var, $encoding);
if ($encoding !== null) {
$result = \mb_check_encoding($var, $encoding);
} else {
$result = \mb_check_encoding($var);
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand Down Expand Up @@ -80,7 +84,11 @@ function mb_chr(int $cp, string $encoding = null): string
function mb_detect_order($encoding_list = null)
{
error_clear_last();
$result = \mb_detect_order($encoding_list);
if ($encoding_list !== null) {
$result = \mb_detect_order($encoding_list);
} else {
$result = \mb_detect_order();
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand Down Expand Up @@ -309,7 +317,11 @@ function mb_eregi_replace(string $pattern, string $replace, string $string, stri
function mb_http_output(string $encoding = null)
{
error_clear_last();
$result = \mb_http_output($encoding);
if ($encoding !== null) {
$result = \mb_http_output($encoding);
} else {
$result = \mb_http_output();
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand All @@ -336,7 +348,11 @@ function mb_http_output(string $encoding = null)
function mb_internal_encoding(string $encoding = null)
{
error_clear_last();
$result = \mb_internal_encoding($encoding);
if ($encoding !== null) {
$result = \mb_internal_encoding($encoding);
} else {
$result = \mb_internal_encoding();
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand Down Expand Up @@ -404,7 +420,11 @@ function mb_parse_str(string $encoded_string, array &$result = null): void
function mb_regex_encoding(string $encoding = null)
{
error_clear_last();
$result = \mb_regex_encoding($encoding);
if ($encoding !== null) {
$result = \mb_regex_encoding($encoding);
} else {
$result = \mb_regex_encoding();
}
if ($result === false) {
throw MbstringException::createFromPhpError();
}
Expand Down
14 changes: 13 additions & 1 deletion generated/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,19 @@ function mysql_close($link_identifier = null): void
function mysql_connect(string $server = null, string $username = null, string $password = null, bool $new_link = false, int $client_flags = 0)
{
error_clear_last();
$result = \mysql_connect($server, $username, $password, $new_link, $client_flags);
if ($client_flags !== 0) {
$result = \mysql_connect($server, $username, $password, $new_link, $client_flags);
} elseif ($new_link !== false) {
$result = \mysql_connect($server, $username, $password, $new_link);
} elseif ($password !== null) {
$result = \mysql_connect($server, $username, $password);
} elseif ($username !== null) {
$result = \mysql_connect($server, $username);
} elseif ($server !== null) {
$result = \mysql_connect($server);
} else {
$result = \mysql_connect();
}
if ($result === false) {
throw MysqlException::createFromPhpError();
}
Expand Down
6 changes: 5 additions & 1 deletion generated/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ function dns_get_record(string $hostname, int $type = DNS_ANY, array &$authns =
function fsockopen(string $hostname, int $port = -1, int &$errno = null, string &$errstr = null, float $timeout = null)
{
error_clear_last();
$result = \fsockopen($hostname, $port, $errno, $errstr, $timeout);
if ($timeout !== null) {
$result = \fsockopen($hostname, $port, $errno, $errstr, $timeout);
} else {
$result = \fsockopen($hostname, $port, $errno, $errstr);
}
if ($result === false) {
throw NetworkException::createFromPhpError();
}
Expand Down
16 changes: 14 additions & 2 deletions generated/pcntl.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ function pcntl_exec(string $path, array $args = null, array $envs = null): void
function pcntl_getpriority(int $pid = null, int $process_identifier = PRIO_PROCESS): int
{
error_clear_last();
$result = \pcntl_getpriority($pid, $process_identifier);
if ($process_identifier !== PRIO_PROCESS) {
$result = \pcntl_getpriority($pid, $process_identifier);
} elseif ($pid !== null) {
$result = \pcntl_getpriority($pid);
} else {
$result = \pcntl_getpriority();
}
if ($result === false) {
throw PcntlException::createFromPhpError();
}
Expand All @@ -81,7 +87,13 @@ function pcntl_getpriority(int $pid = null, int $process_identifier = PRIO_PROCE
function pcntl_setpriority(int $priority, int $pid = null, int $process_identifier = PRIO_PROCESS): void
{
error_clear_last();
$result = \pcntl_setpriority($priority, $pid, $process_identifier);
if ($process_identifier !== PRIO_PROCESS) {
$result = \pcntl_setpriority($priority, $pid, $process_identifier);
} elseif ($pid !== null) {
$result = \pcntl_setpriority($priority, $pid);
} else {
$result = \pcntl_setpriority($priority);
}
if ($result === false) {
throw PcntlException::createFromPhpError();
}
Expand Down
20 changes: 20 additions & 0 deletions generated/pspell.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,26 @@ function pspell_config_save_repl(int $dictionary_link, bool $flag): void
}


/**
*
*
* @param int $config The config parameter is the one returned by
* pspell_config_create when the config was created.
* @return int Returns a dictionary link identifier on success, .
* @throws PspellException
*
*/
function pspell_new_config(int $config): int
{
error_clear_last();
$result = \pspell_new_config($config);
if ($result === false) {
throw PspellException::createFromPhpError();
}
return $result;
}


/**
* pspell_new opens up a new dictionary and
* returns the dictionary link identifier for use in other pspell
Expand Down
14 changes: 12 additions & 2 deletions generated/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ 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();
$result = \stream_socket_accept($server_socket, $timeout, $peername);
if ($peername !== null) {
$result = \stream_socket_accept($server_socket, $timeout, $peername);
} elseif ($timeout !== null) {
$result = \stream_socket_accept($server_socket, $timeout);
} else {
$result = \stream_socket_accept($server_socket);
}
if ($result === false) {
throw StreamException::createFromPhpError();
}
Expand Down Expand Up @@ -396,8 +402,12 @@ function stream_socket_client(string $remote_socket, int &$errno = null, string
error_clear_last();
if ($context !== null) {
$result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags, $context);
} else {
} elseif ($flags !== STREAM_CLIENT_CONNECT) {
$result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags);
} elseif ($timeout !== null) {
$result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout);
} else {
$result = \stream_socket_client($remote_socket, $errno, $errstr);
}
if ($result === false) {
throw StreamException::createFromPhpError();
Expand Down
14 changes: 13 additions & 1 deletion generator/src/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,19 @@ public function isByReference(): bool
*/
public function isOptionalWithNoDefault(): bool
{
return ((string)$this->parameter['choice']) === 'opt' && !$this->hasDefaultValue();
if (((string)$this->parameter['choice']) !== 'opt') {
return false;
}
if (!$this->hasDefaultValue()) {
return true;
}

$initializer = $this->getInitializer();
// Some default value have weird values. For instance, first parameter of "mb_internal_encoding" has default value "mb_internal_encoding()"
if ($initializer !== 'array()' && strpos($initializer, '(') !== false) {
return true;
}
return false;
}

public function isVariadic(): bool
Expand Down
14 changes: 14 additions & 0 deletions generator/tests/GeneratedFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,18 @@ public function testPregSplit()
$keywords = preg_split("/[\s,]+/", "hypertext language, programming", null);
$this->assertSame(['hypertext', 'language', 'programming'], $keywords);
}


/**
* Tests that parameters with "time()" default value are correctly handled.
*/
public function testStrtotime()
{
require_once __DIR__.'/../../generated/datetime.php';
require_once __DIR__.'/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__.'/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__.'/../../generated/Exceptions/DatetimeException.php';

$this->assertSame(\strtotime('+1 day'), strtotime('+1 day'));
}
}
1 change: 1 addition & 0 deletions rector-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ services:
pspell_config_repl: 'Safe\pspell_config_repl'
pspell_config_runtogether: 'Safe\pspell_config_runtogether'
pspell_config_save_repl: 'Safe\pspell_config_save_repl'
pspell_new_config: 'Safe\pspell_new_config'
pspell_new: 'Safe\pspell_new'
pspell_save_wordlist: 'Safe\pspell_save_wordlist'
pspell_store_replacement: 'Safe\pspell_store_replacement'
Expand Down