diff --git a/generated/apache.php b/generated/apache.php index a402332d..6ffb983c 100644 --- a/generated/apache.php +++ b/generated/apache.php @@ -93,8 +93,7 @@ function apache_lookup_uri(string $filename): object /** * Fetches all HTTP request headers from the current request. Works in the - * Apache, FastCGI, CLI, FPM and NSAPI server module - * in Netscape/iPlanet/SunONE webservers. + * Apache, FastCGI, CLI, and FPM webservers. * * @return array An associative array of all the HTTP headers in the current request. * @throws ApacheException @@ -135,8 +134,7 @@ function apache_reset_timeout(): void /** * Fetch all HTTP response headers. Works in the - * Apache, FastCGI, CLI, FPM and NSAPI server module - * in Netscape/iPlanet/SunONE webservers. + * Apache, FastCGI, CLI, and FPM webservers. * * @return array An array of all Apache response headers on success. * @throws ApacheException diff --git a/generated/curl.php b/generated/curl.php index 9a885d9b..05e659e8 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -3089,7 +3089,7 @@ function curl_share_errno($share_handle): int * * * - * @param string $value + * @param mixed $value * * * @@ -3126,7 +3126,7 @@ function curl_share_errno($share_handle): int * @throws CurlException * */ -function curl_share_setopt($share_handle, int $option, string $value): void +function curl_share_setopt($share_handle, int $option, $value): void { error_clear_last(); $result = \curl_share_setopt($share_handle, $option, $value); diff --git a/generated/datetime.php b/generated/datetime.php index 05c46583..b0fef547 100644 --- a/generated/datetime.php +++ b/generated/datetime.php @@ -233,10 +233,10 @@ function date_sun_info(int $timestamp, float $latitude, float $longitude): array * @throws DatetimeException * */ -function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0) +function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { error_clear_last(); - if ($utcOffset !== 0) { + if ($utcOffset !== null) { $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith); @@ -336,10 +336,10 @@ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, f * @throws DatetimeException * */ -function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0) +function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { error_clear_last(); - if ($utcOffset !== 0) { + if ($utcOffset !== null) { $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith); diff --git a/generated/dir.php b/generated/dir.php index 628dec53..1f23ea92 100644 --- a/generated/dir.php +++ b/generated/dir.php @@ -106,10 +106,11 @@ function opendir(string $path, $context = null) * with opendir. If the directory handle is * not specified, the last link opened by opendir * is assumed. + * @return null Returns NULL on success. * @throws DirException * */ -function rewinddir($dir_handle = null): void +function rewinddir($dir_handle = null) { error_clear_last(); if ($dir_handle !== null) { @@ -120,6 +121,7 @@ function rewinddir($dir_handle = null): void if ($result === false) { throw DirException::createFromPhpError(); } + return $result; } diff --git a/generated/exec.php b/generated/exec.php index a816ee09..afd33b77 100644 --- a/generated/exec.php +++ b/generated/exec.php @@ -49,7 +49,7 @@ function exec(string $command, ?array &$output = null, ?int &$result_code = null * * @param resource $process The proc_open resource that will * be evaluated. - * @return array An array of collected information on success. The returned array contains the following elements: + * @return array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int} An array of collected information on success. The returned array contains the following elements: * * * diff --git a/generated/fileinfo.php b/generated/fileinfo.php index 8d8c84c4..c062e17b 100644 --- a/generated/fileinfo.php +++ b/generated/fileinfo.php @@ -58,13 +58,13 @@ function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = "") * Returns the MIME content type for a file as determined by using * information from the magic.mime file. * - * @param string $filename Path to the tested file. + * @param string|resource $filename Path to the tested file. * @return string Returns the content type in MIME format, like * text/plain or application/octet-stream. * @throws FileinfoException * */ -function mime_content_type(string $filename): string +function mime_content_type($filename): string { error_clear_last(); $result = \mime_content_type($filename); diff --git a/generated/filter.php b/generated/filter.php index 0ee0c0ed..aba02b4d 100644 --- a/generated/filter.php +++ b/generated/filter.php @@ -23,7 +23,7 @@ * This parameter can be also an integer holding a filter constant. Then all values in the * input array are filtered by this filter. * @param bool $add_empty Add missing keys as NULL to the return value. - * @return mixed An array containing the values of the requested variables on success. + * @return array|null An array containing the values of the requested variables on success. * If the input array designated by type is not populated, * the function returns NULL if the FILTER_NULL_ON_FAILURE * flag is not given, or FALSE otherwise. For other failures, FALSE is returned. @@ -36,7 +36,7 @@ * @throws FilterException * */ -function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true) +function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { error_clear_last(); $result = \filter_input_array($type, $options, $add_empty); @@ -65,12 +65,12 @@ function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empt * This parameter can be also an integer holding a filter constant. Then all values in the * input array are filtered by this filter. * @param bool $add_empty Add missing keys as NULL to the return value. - * @return mixed An array containing the values of the requested variables on success. An array value will be FALSE if the filter fails, or NULL if + * @return array|null An array containing the values of the requested variables on success. An array value will be FALSE if the filter fails, or NULL if * the variable is not set. * @throws FilterException * */ -function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true) +function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { error_clear_last(); $result = \filter_var_array($array, $options, $add_empty); diff --git a/generated/ftp.php b/generated/ftp.php index ebabd05e..a36e853a 100644 --- a/generated/ftp.php +++ b/generated/ftp.php @@ -8,17 +8,17 @@ * Sends an ALLO command to the remote FTP server to * allocate space for a file to be uploaded. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param int $filesize The number of bytes to allocate. - * @param string|null $result A textual representation of the servers response will be returned by - * reference in result if a variable is provided. + * @param resource $ftp The link identifier of the FTP connection. + * @param int $size The number of bytes to allocate. + * @param string|null $response A textual representation of the servers response will be returned by + * reference in response if a variable is provided. * @throws FtpException * */ -function ftp_alloc($ftp_stream, int $filesize, ?string &$result = null): void +function ftp_alloc($ftp, int $size, ?string &$response = null): void { error_clear_last(); - $result = \ftp_alloc($ftp_stream, $filesize, $result); + $result = \ftp_alloc($ftp, $size, $response); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -29,16 +29,16 @@ function ftp_alloc($ftp_stream, int $filesize, ?string &$result = null): void * * * @param resource $ftp - * @param string $remote_file - * @param string $local_file + * @param string $remote_filename + * @param string $local_filename * @param int $mode * @throws FtpException * */ -function ftp_append($ftp, string $remote_file, string $local_file, int $mode = FTP_BINARY): void +function ftp_append($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): void { error_clear_last(); - $result = \ftp_append($ftp, $remote_file, $local_file, $mode); + $result = \ftp_append($ftp, $remote_filename, $local_filename, $mode); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -48,14 +48,14 @@ function ftp_append($ftp, string $remote_file, string $local_file, int $mode = F /** * Changes to the parent directory. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @throws FtpException * */ -function ftp_cdup($ftp_stream): void +function ftp_cdup($ftp): void { error_clear_last(); - $result = \ftp_cdup($ftp_stream); + $result = \ftp_cdup($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -65,15 +65,15 @@ function ftp_cdup($ftp_stream): void /** * Changes the current directory to the specified one. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $directory The target directory. * @throws FtpException * */ -function ftp_chdir($ftp_stream, string $directory): void +function ftp_chdir($ftp, string $directory): void { error_clear_last(); - $result = \ftp_chdir($ftp_stream, $directory); + $result = \ftp_chdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -82,19 +82,19 @@ function ftp_chdir($ftp_stream, string $directory): void /** * Sets the permissions on the specified remote file to - * mode. + * permissions. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param int $mode The new permissions, given as an octal value. + * @param resource $ftp The link identifier of the FTP connection. + * @param int $permissions The new permissions, given as an octal value. * @param string $filename The remote file. * @return int Returns the new file permissions on success. * @throws FtpException * */ -function ftp_chmod($ftp_stream, int $mode, string $filename): int +function ftp_chmod($ftp, int $permissions, string $filename): int { error_clear_last(); - $result = \ftp_chmod($ftp_stream, $mode, $filename); + $result = \ftp_chmod($ftp, $permissions, $filename); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -106,14 +106,14 @@ function ftp_chmod($ftp_stream, int $mode, string $filename): int * ftp_close closes the given link identifier * and releases the resource. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @throws FtpException * */ -function ftp_close($ftp_stream): void +function ftp_close($ftp): void { error_clear_last(); - $result = \ftp_close($ftp_stream); + $result = \ftp_close($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -122,9 +122,9 @@ function ftp_close($ftp_stream): void /** * ftp_connect opens an FTP connection to the - * specified host. + * specified hostname. * - * @param string $host The FTP server address. This parameter shouldn't have any trailing + * @param string $hostname The FTP server address. This parameter shouldn't have any trailing * slashes and shouldn't be prefixed with ftp://. * @param int $port This parameter specifies an alternate port to connect to. If it is * omitted or set to zero, then the default FTP port, 21, will be used. @@ -136,10 +136,10 @@ function ftp_close($ftp_stream): void * @throws FtpException * */ -function ftp_connect(string $host, int $port = 21, int $timeout = 90) +function ftp_connect(string $hostname, int $port = 21, int $timeout = 90) { error_clear_last(); - $result = \ftp_connect($host, $port, $timeout); + $result = \ftp_connect($hostname, $port, $timeout); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -149,17 +149,17 @@ function ftp_connect(string $host, int $port = 21, int $timeout = 90) /** * ftp_delete deletes the file specified by - * path from the FTP server. + * filename from the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $path The file to delete. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $filename The file to delete. * @throws FtpException * */ -function ftp_delete($ftp_stream, string $path): void +function ftp_delete($ftp, string $filename): void { error_clear_last(); - $result = \ftp_delete($ftp_stream, $path); + $result = \ftp_delete($ftp, $filename); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -167,22 +167,22 @@ function ftp_delete($ftp_stream, string $path): void /** - * ftp_fget retrieves remote_file + * ftp_fget retrieves remote_filename * from the FTP server, and writes it to the given file pointer. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param resource $handle An open file pointer in which we store the data. - * @param string $remote_file The remote file path. + * @param resource $ftp The link identifier of the FTP connection. + * @param resource $stream An open file pointer in which we store the data. + * @param string $remote_filename The remote file path. * @param int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $resumepos The position in the remote file to start downloading from. + * @param int $offset The position in the remote file to start downloading from. * @throws FtpException * */ -function ftp_fget($ftp_stream, $handle, string $remote_file, int $mode = FTP_BINARY, int $resumepos = 0): void +function ftp_fget($ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_fget($ftp_stream, $handle, $remote_file, $mode, $resumepos); + $result = \ftp_fget($ftp, $stream, $remote_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -193,19 +193,19 @@ function ftp_fget($ftp_stream, $handle, string $remote_file, int $mode = FTP_BIN * ftp_fput uploads the data from a file pointer * to a remote file on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $remote_file The remote file path. - * @param resource $handle An open file pointer on the local file. Reading stops at end of file. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $remote_filename The remote file path. + * @param resource $stream An open file pointer on the local file. Reading stops at end of file. * @param int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $startpos The position in the remote file to start uploading to. + * @param int $offset The position in the remote file to start uploading to. * @throws FtpException * */ -function ftp_fput($ftp_stream, string $remote_file, $handle, int $mode = FTP_BINARY, int $startpos = 0): void +function ftp_fput($ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_fput($ftp_stream, $remote_file, $handle, $mode, $startpos); + $result = \ftp_fput($ftp, $remote_filename, $stream, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -216,19 +216,19 @@ function ftp_fput($ftp_stream, string $remote_file, $handle, int $mode = FTP_BIN * ftp_get retrieves a remote file from the FTP server, * and saves it into a local file. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $local_file The local file path (will be overwritten if the file already exists). - * @param string $remote_file The remote file path. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $local_filename The local file path (will be overwritten if the file already exists). + * @param string $remote_filename The remote file path. * @param int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $resumepos The position in the remote file to start downloading from. + * @param int $offset The position in the remote file to start downloading from. * @throws FtpException * */ -function ftp_get($ftp_stream, string $local_file, string $remote_file, int $mode = FTP_BINARY, int $resumepos = 0): void +function ftp_get($ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_get($ftp_stream, $local_file, $remote_file, $mode, $resumepos); + $result = \ftp_get($ftp, $local_filename, $remote_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -238,16 +238,16 @@ function ftp_get($ftp_stream, string $local_file, string $remote_file, int $mode /** * Logs in to the given FTP stream. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $username The username (USER). * @param string $password The password (PASS). * @throws FtpException * */ -function ftp_login($ftp_stream, string $username, string $password): void +function ftp_login($ftp, string $username, string $password): void { error_clear_last(); - $result = \ftp_login($ftp_stream, $username, $password); + $result = \ftp_login($ftp, $username, $password); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -257,16 +257,16 @@ function ftp_login($ftp_stream, string $username, string $password): void /** * Creates the specified directory on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $directory The name of the directory that will be created. * @return string Returns the newly created directory name on success. * @throws FtpException * */ -function ftp_mkdir($ftp_stream, string $directory): string +function ftp_mkdir($ftp, string $directory): string { error_clear_last(); - $result = \ftp_mkdir($ftp_stream, $directory); + $result = \ftp_mkdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -277,16 +277,16 @@ function ftp_mkdir($ftp_stream, string $directory): string /** * * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $directory The directory to be listed. * @return array Returns an array of arrays with file infos from the specified directory on success. * @throws FtpException * */ -function ftp_mlsd($ftp_stream, string $directory): array +function ftp_mlsd($ftp, string $directory): array { error_clear_last(); - $result = \ftp_mlsd($ftp_stream, $directory); + $result = \ftp_mlsd($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -295,9 +295,38 @@ function ftp_mlsd($ftp_stream, string $directory): array /** + * ftp_nb_put stores a local file on the FTP server. * + * The difference between this function and the ftp_put + * is that this function uploads the file asynchronously, so your program can + * perform other operations while the file is being uploaded. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $remote_filename The remote file path. + * @param string $local_filename The local file path. + * @param int $mode The transfer mode. Must be either FTP_ASCII or + * FTP_BINARY. + * @param int $offset The position in the remote file to start uploading to. + * @return int Returns FTP_FAILED or FTP_FINISHED + * or FTP_MOREDATA to open the local file. + * @throws FtpException + * + */ +function ftp_nb_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int +{ + error_clear_last(); + $result = \ftp_nb_put($ftp, $remote_filename, $local_filename, $mode, $offset); + if ($result === false) { + throw FtpException::createFromPhpError(); + } + return $result; +} + + +/** + * + * + * @param resource $ftp The link identifier of the FTP connection. * @param string $directory The directory to be listed. This parameter can also include arguments, eg. * ftp_nlist($conn_id, "-la /your/dir"); * Note that this parameter isn't escaped so there may be some issues with @@ -306,10 +335,10 @@ function ftp_mlsd($ftp_stream, string $directory): array * @throws FtpException * */ -function ftp_nlist($ftp_stream, string $directory): array +function ftp_nlist($ftp, string $directory): array { error_clear_last(); - $result = \ftp_nlist($ftp_stream, $directory); + $result = \ftp_nlist($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -326,15 +355,15 @@ function ftp_nlist($ftp_stream, string $directory): array * Please note that ftp_pasv can only be called after a * successful login or otherwise it will fail. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param bool $pasv If TRUE, the passive mode is turned on, else it's turned off. + * @param resource $ftp The link identifier of the FTP connection. + * @param bool $enable If TRUE, the passive mode is turned on, else it's turned off. * @throws FtpException * */ -function ftp_pasv($ftp_stream, bool $pasv): void +function ftp_pasv($ftp, bool $enable): void { error_clear_last(); - $result = \ftp_pasv($ftp_stream, $pasv); + $result = \ftp_pasv($ftp, $enable); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -344,19 +373,19 @@ function ftp_pasv($ftp_stream, bool $pasv): void /** * ftp_put stores a local file on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $remote_file The remote file path. - * @param string $local_file The local file path. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $remote_filename The remote file path. + * @param string $local_filename The local file path. * @param int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $startpos The position in the remote file to start uploading to. + * @param int $offset The position in the remote file to start uploading to. * @throws FtpException * */ -function ftp_put($ftp_stream, string $remote_file, string $local_file, int $mode = FTP_BINARY, int $startpos = 0): void +function ftp_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos); + $result = \ftp_put($ftp, $remote_filename, $local_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -366,15 +395,15 @@ function ftp_put($ftp_stream, string $remote_file, string $local_file, int $mode /** * * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @return string Returns the current directory name. * @throws FtpException * */ -function ftp_pwd($ftp_stream): string +function ftp_pwd($ftp): string { error_clear_last(); - $result = \ftp_pwd($ftp_stream); + $result = \ftp_pwd($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -386,16 +415,16 @@ function ftp_pwd($ftp_stream): string * ftp_rename renames a file or a directory on the FTP * server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $oldname The old file/directory name. - * @param string $newname The new name. + * @param resource $ftp The link identifier of the FTP connection. + * @param string $from The old file/directory name. + * @param string $to The new name. * @throws FtpException * */ -function ftp_rename($ftp_stream, string $oldname, string $newname): void +function ftp_rename($ftp, string $from, string $to): void { error_clear_last(); - $result = \ftp_rename($ftp_stream, $oldname, $newname); + $result = \ftp_rename($ftp, $from, $to); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -405,16 +434,16 @@ function ftp_rename($ftp_stream, string $oldname, string $newname): void /** * Removes the specified directory on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $directory The directory to delete. This must be either an absolute or relative * path to an empty directory. * @throws FtpException * */ -function ftp_rmdir($ftp_stream, string $directory): void +function ftp_rmdir($ftp, string $directory): void { error_clear_last(); - $result = \ftp_rmdir($ftp_stream, $directory); + $result = \ftp_rmdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -429,16 +458,16 @@ function ftp_rmdir($ftp_stream, string $directory): void * to server. They are useful for handling such things as file permissions and * group membership. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @param string $command The SITE command. Note that this parameter isn't escaped so there may * be some issues with filenames containing spaces and other characters. * @throws FtpException * */ -function ftp_site($ftp_stream, string $command): void +function ftp_site($ftp, string $command): void { error_clear_last(); - $result = \ftp_site($ftp_stream, $command); + $result = \ftp_site($ftp, $command); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -447,14 +476,14 @@ function ftp_site($ftp_stream, string $command): void /** * ftp_ssl_connect opens an explicit SSL-FTP connection to the - * specified host. That implies that + * specified hostname. That implies that * ftp_ssl_connect will succeed even if the server is not * configured for SSL-FTP, or its certificate is invalid. Only when * ftp_login is called, the client will send the * appropriate AUTH FTP command, so ftp_login will fail in * the mentioned cases. * - * @param string $host The FTP server address. This parameter shouldn't have any trailing + * @param string $hostname The FTP server address. This parameter shouldn't have any trailing * slashes and shouldn't be prefixed with ftp://. * @param int $port This parameter specifies an alternate port to connect to. If it is * omitted or set to zero, then the default FTP port, 21, will be used. @@ -466,10 +495,10 @@ function ftp_site($ftp_stream, string $command): void * @throws FtpException * */ -function ftp_ssl_connect(string $host, int $port = 21, int $timeout = 90) +function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90) { error_clear_last(); - $result = \ftp_ssl_connect($host, $port, $timeout); + $result = \ftp_ssl_connect($hostname, $port, $timeout); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -480,15 +509,15 @@ function ftp_ssl_connect(string $host, int $port = 21, int $timeout = 90) /** * Returns the system type identifier of the remote FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp The link identifier of the FTP connection. * @return string Returns the remote system type. * @throws FtpException * */ -function ftp_systype($ftp_stream): string +function ftp_systype($ftp): string { error_clear_last(); - $result = \ftp_systype($ftp_stream); + $result = \ftp_systype($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } diff --git a/generated/functionsList.php b/generated/functionsList.php index ec926cff..d2a2090f 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -173,6 +173,7 @@ 'ftp_login', 'ftp_mkdir', 'ftp_mlsd', + 'ftp_nb_put', 'ftp_nlist', 'ftp_pasv', 'ftp_put', @@ -341,29 +342,48 @@ 'imagewebp', 'imagexbm', 'image_type_to_extension', + 'imap_8bit', 'imap_append', + 'imap_base64', + 'imap_binary', + 'imap_body', + 'imap_bodystruct', 'imap_check', 'imap_clearflag_full', 'imap_close', 'imap_createmailbox', 'imap_deletemailbox', + 'imap_fetchbody', + 'imap_fetchheader', + 'imap_fetchmime', 'imap_fetchstructure', + 'imap_fetch_overview', 'imap_gc', + 'imap_getacl', + 'imap_getmailboxes', + 'imap_getsubscribed', 'imap_headerinfo', + 'imap_headers', + 'imap_listscan', + 'imap_lsub', 'imap_mail', 'imap_mailboxmsginfo', 'imap_mail_compose', 'imap_mail_copy', 'imap_mail_move', + 'imap_mime_header_decode', 'imap_mutf7_to_utf8', 'imap_num_msg', 'imap_open', + 'imap_qprint', 'imap_renamemailbox', + 'imap_rfc822_write_address', 'imap_savebody', 'imap_setacl', 'imap_setflag_full', 'imap_set_quota', 'imap_sort', + 'imap_status', 'imap_subscribe', 'imap_thread', 'imap_timeout', @@ -444,7 +464,6 @@ 'ldap_set_option', 'ldap_unbind', 'libxml_get_last_error', - 'libxml_set_external_entity_loader', 'link', 'long2ip', 'lstat', @@ -607,6 +626,11 @@ 'opendir', 'openlog', 'openssl_cipher_iv_length', + 'openssl_cms_decrypt', + 'openssl_cms_encrypt', + 'openssl_cms_read', + 'openssl_cms_sign', + 'openssl_cms_verify', 'openssl_csr_export', 'openssl_csr_export_to_file', 'openssl_csr_get_subject', @@ -713,8 +737,14 @@ 'php_sapi_name', 'png2wbmp', 'posix_access', + 'posix_getgrgid', 'posix_getgrnam', + 'posix_getgroups', + 'posix_getlogin', 'posix_getpgid', + 'posix_getpwuid', + 'posix_getrlimit', + 'posix_getsid', 'posix_initgroups', 'posix_kill', 'posix_mkfifo', @@ -725,6 +755,8 @@ 'posix_setpgid', 'posix_setrlimit', 'posix_setuid', + 'posix_times', + 'posix_uname', 'preg_match', 'preg_match_all', 'preg_replace', @@ -872,6 +904,7 @@ 'socket_accept', 'socket_addrinfo_bind', 'socket_addrinfo_connect', + 'socket_addrinfo_lookup', 'socket_bind', 'socket_connect', 'socket_create', @@ -925,6 +958,8 @@ 'ssh2_connect', 'ssh2_disconnect', 'ssh2_exec', + 'ssh2_forward_accept', + 'ssh2_forward_listen', 'ssh2_publickey_add', 'ssh2_publickey_init', 'ssh2_publickey_remove', @@ -1013,6 +1048,10 @@ 'yaz_search', 'yaz_wait', 'zip_entry_close', + 'zip_entry_compressedsize', + 'zip_entry_compressionmethod', + 'zip_entry_filesize', + 'zip_entry_name', 'zip_entry_open', 'zip_entry_read', 'zlib_decode', diff --git a/generated/image.php b/generated/image.php index bacc4907..cdaeeba8 100644 --- a/generated/image.php +++ b/generated/image.php @@ -301,7 +301,7 @@ function imagearc($image, int $cx, int $cy, int $width, int $height, int $start, * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * * NULL is invalid if the compressed arguments is * not used. @@ -1468,11 +1468,11 @@ function imagegammacorrect($image, float $inputgamma, float $outputgamma): void * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @throws ImageException * */ -function imagegd($image, ?string $to = null): void +function imagegd($image, $to = null): void { error_clear_last(); $result = \imagegd($image, $to); @@ -1487,7 +1487,7 @@ function imagegd($image, ?string $to = null): void * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $chunk_size Chunk size. * @param int $type Either IMG_GD2_RAW or * IMG_GD2_COMPRESSED. Default is @@ -1495,7 +1495,7 @@ function imagegd($image, ?string $to = null): void * @throws ImageException * */ -function imagegd2($image, ?string $to = null, int $chunk_size = 128, int $type = IMG_GD2_RAW): void +function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2_RAW): void { error_clear_last(); $result = \imagegd2($image, $to, $chunk_size, $type); @@ -1519,11 +1519,11 @@ function imagegd2($image, ?string $to = null, int $chunk_size = 128, int $type = * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @throws ImageException * */ -function imagegif($image, ?string $to = null): void +function imagegif($image, $to = null): void { error_clear_last(); if ($to !== null) { @@ -1581,14 +1581,14 @@ function imagegrabwindow(int $window_handle, int $client_area = 0) * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $quality quality is optional, and ranges from 0 (worst * quality, smaller file) to 100 (best quality, biggest file). The * default (-1) uses the default IJG quality value (about 75). * @throws ImageException * */ -function imagejpeg($image, ?string $to = null, int $quality = -1): void +function imagejpeg($image, $to = null, int $quality = -1): void { error_clear_last(); if ($quality !== -1) { @@ -1766,7 +1766,7 @@ function imageloadfont(string $file): int * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * * NULL is invalid if the quality and * filters arguments are not used. @@ -1782,7 +1782,7 @@ function imageloadfont(string $file): int * @throws ImageException * */ -function imagepng($image, ?string $to = null, int $quality = -1, int $filters = -1): void +function imagepng($image, $to = null, int $quality = -1, int $filters = -1): void { error_clear_last(); if ($filters !== -1) { @@ -2477,14 +2477,14 @@ function imagettftext($image, float $size, float $angle, int $x, int $y, int $co * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $foreground You can set the foreground color with this parameter by setting an * identifier obtained from imagecolorallocate. * The default foreground color is black. * @throws ImageException * */ -function imagewbmp($image, ?string $to = null, int $foreground = null): void +function imagewbmp($image, $to = null, int $foreground = null): void { error_clear_last(); if ($foreground !== null) { @@ -2505,13 +2505,13 @@ function imagewbmp($image, ?string $to = null, int $foreground = null): void * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $quality quality ranges from 0 (worst * quality, smaller file) to 100 (best quality, biggest file). * @throws ImageException * */ -function imagewebp($image, ?string $to = null, int $quality = 80): void +function imagewebp($image, $to = null, int $quality = 80): void { error_clear_last(); if ($quality !== 80) { @@ -2533,7 +2533,7 @@ function imagewebp($image, ?string $to = null, int $quality = 80): void * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $filename The path to save the file to, given as string. If NULL, the raw image stream will be output directly. + * @param string|resource|null $filename The path to save the file to, given as string. If NULL, the raw image stream will be output directly. * * The filename (without the .xbm extension) is also * used for the C identifiers of the XBM, whereby non @@ -2547,7 +2547,7 @@ function imagewebp($image, ?string $to = null, int $quality = 80): void * @throws ImageException * */ -function imagexbm($image, ?string $filename, int $foreground = null): void +function imagexbm($image, $filename, int $foreground = null): void { error_clear_last(); if ($foreground !== null) { diff --git a/generated/imap.php b/generated/imap.php index bcc999da..35898be1 100644 --- a/generated/imap.php +++ b/generated/imap.php @@ -5,11 +5,31 @@ use Safe\Exceptions\ImapException; /** - * Appends a string message to the specified mailbox. + * Convert an 8bit string to a quoted-printable string (according to + * RFC2045, section 6.7). * - * @param resource $imap_stream An IMAP stream returned by + * @param string $string The 8bit string to convert + * @return string Returns a quoted-printable string. + * @throws ImapException + * + */ +function imap_8bit(string $string): string +{ + error_clear_last(); + $result = \imap_8bit($string); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Appends a string message to the specified folder. + * + * @param resource $imap An IMAP stream returned by * imap_open. - * @param string $mailbox The mailbox name, see imap_open for more + * @param string $folder The mailbox name, see imap_open for more * information * @param string $message The message to be append, as a string * @@ -17,31 +37,143 @@ * your end-of-line terminator instead of "\n" or the operation will * fail * @param string $options If provided, the options will also be written - * to the mailbox + * to the folder * @param string $internal_date If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a date string that conforms to the rfc2060 specifications for a date_time value. * @throws ImapException * */ -function imap_append($imap_stream, string $mailbox, string $message, string $options = null, string $internal_date = null): void +function imap_append($imap, string $folder, string $message, string $options = null, string $internal_date = null): void { error_clear_last(); if ($internal_date !== null) { - $result = \imap_append($imap_stream, $mailbox, $message, $options, $internal_date); + $result = \imap_append($imap, $folder, $message, $options, $internal_date); } elseif ($options !== null) { - $result = \imap_append($imap_stream, $mailbox, $message, $options); + $result = \imap_append($imap, $folder, $message, $options); } else { - $result = \imap_append($imap_stream, $mailbox, $message); + $result = \imap_append($imap, $folder, $message); + } + if ($result === false) { + throw ImapException::createFromPhpError(); } +} + + +/** + * Decodes the given BASE-64 encoded string. + * + * @param string $string The encoded text + * @return string Returns the decoded message as a string. + * @throws ImapException + * + */ +function imap_base64(string $string): string +{ + error_clear_last(); + $result = \imap_base64($string); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Convert an 8bit string to a base64 string according to RFC2045, Section 6.8. + * + * @param string $string The 8bit string + * @return string Returns a base64 encoded string. + * @throws ImapException + * + */ +function imap_binary(string $string): string +{ + error_clear_last(); + $result = \imap_binary($string); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; +} + + +/** + * imap_body returns the body of the message, + * numbered message_num in the current + * mailbox. + * + * imap_body will only return a verbatim copy of the + * message body. To extract single parts of a multipart MIME-encoded + * message you have to use imap_fetchstructure to + * analyze its structure and imap_fetchbody to + * extract a copy of a single body component. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param int $message_num The message number + * @param int $flags The optional flags are a bit mask + * with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if not already set + * + * + * + * + * FT_INTERNAL - The return string is in internal format, will + * not canonicalize to CRLF. + * + * + * + * @return string Returns the body of the specified message, as a string. + * @throws ImapException + * + */ +function imap_body($imap, int $message_num, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_body($imap, $message_num, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Read the structure of a specified body section of a specific message. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param int $message_num The message number + * @param string $section The body section to read + * @return \stdClass Returns the information in an object. + * For a detailed description + * of the object structure and properties see + * imap_fetchstructure. + * @throws ImapException + * + */ +function imap_bodystruct($imap, int $message_num, string $section): \stdClass +{ + error_clear_last(); + $result = \imap_bodystruct($imap, $message_num, $section); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; } /** * Checks information about the current mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @return \stdClass Returns the information in an object with following properties: * @@ -77,10 +209,10 @@ function imap_append($imap_stream, string $mailbox, string $message, string $opt * @throws ImapException * */ -function imap_check($imap_stream): \stdClass +function imap_check($imap): \stdClass { error_clear_last(); - $result = \imap_check($imap_stream); + $result = \imap_check($imap); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -93,7 +225,7 @@ function imap_check($imap_stream): \stdClass * flag to the flags set for the * messages in the specified sequence. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $sequence A sequence of message numbers. You can enumerate desired messages * with the X,Y syntax, or retrieve all messages @@ -113,10 +245,10 @@ function imap_check($imap_stream): \stdClass * @throws ImapException * */ -function imap_clearflag_full($imap_stream, string $sequence, string $flag, int $options = 0): void +function imap_clearflag_full($imap, string $sequence, string $flag, int $options = 0): void { error_clear_last(); - $result = \imap_clearflag_full($imap_stream, $sequence, $flag, $options); + $result = \imap_clearflag_full($imap, $sequence, $flag, $options); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -126,19 +258,19 @@ function imap_clearflag_full($imap_stream, string $sequence, string $flag, int $ /** * Closes the imap stream. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $flag If set to CL_EXPUNGE, the function will silently + * @param int $flags If set to CL_EXPUNGE, the function will silently * expunge the mailbox before closing, removing all messages marked for * deletion. You can achieve the same thing by using * imap_expunge * @throws ImapException * */ -function imap_close($imap_stream, int $flag = 0): void +function imap_close($imap, int $flags = 0): void { error_clear_last(); - $result = \imap_close($imap_stream, $flag); + $result = \imap_close($imap, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -148,7 +280,7 @@ function imap_close($imap_stream, int $flag = 0): void /** * Creates a new mailbox specified by mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $mailbox The mailbox name, see imap_open for more * information. Names containing international characters should be @@ -156,10 +288,10 @@ function imap_close($imap_stream, int $flag = 0): void * @throws ImapException * */ -function imap_createmailbox($imap_stream, string $mailbox): void +function imap_createmailbox($imap, string $mailbox): void { error_clear_last(); - $result = \imap_createmailbox($imap_stream, $mailbox); + $result = \imap_createmailbox($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -169,32 +301,285 @@ function imap_createmailbox($imap_stream, string $mailbox): void /** * Deletes the specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param string $mailbox The mailbox name, see imap_open for more - * information + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $mailbox The mailbox name, see imap_open for more + * information + * @throws ImapException + * + */ +function imap_deletemailbox($imap, string $mailbox): void +{ + error_clear_last(); + $result = \imap_deletemailbox($imap, $mailbox); + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * This function fetches mail headers for the given + * sequence and returns an overview of their + * contents. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $sequence A message sequence description. You can enumerate desired messages + * with the X,Y syntax, or retrieve all messages + * within an interval with the X:Y syntax + * @param int $flags sequence will contain a sequence of message + * indices or UIDs, if this parameter is set to + * FT_UID. + * @return array Returns an array of objects describing one message header each. + * The object will only define a property if it exists. The possible + * properties are: + * + * + * + * subject - the messages subject + * + * + * + * + * from - who sent it + * + * + * + * + * to - recipient + * + * + * + * + * date - when was it sent + * + * + * + * + * message_id - Message-ID + * + * + * + * + * references - is a reference to this message id + * + * + * + * + * in_reply_to - is a reply to this message id + * + * + * + * + * size - size in bytes + * + * + * + * + * uid - UID the message has in the mailbox + * + * + * + * + * msgno - message sequence number in the mailbox + * + * + * + * + * recent - this message is flagged as recent + * + * + * + * + * flagged - this message is flagged + * + * + * + * + * answered - this message is flagged as answered + * + * + * + * + * deleted - this message is flagged for deletion + * + * + * + * + * seen - this message is flagged as already read + * + * + * + * + * draft - this message is flagged as being a draft + * + * + * + * + * udate - the UNIX timestamp of the arrival date + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_fetch_overview($imap, string $sequence, int $flags = 0): array +{ + error_clear_last(); + $result = \imap_fetch_overview($imap, $sequence, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Fetch of a particular section of the body of the specified messages. + * Body parts are not decoded by this function. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which + * index into a body part list as per the IMAP4 specification + * @param int $flags A bitmask with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if + * not already set + * + * + * + * + * FT_INTERNAL - The return string is in + * internal format, will not canonicalize to CRLF. + * + * + * + * @return string Returns a particular section of the body of the specified messages as a + * text string. + * @throws ImapException + * + */ +function imap_fetchbody($imap, int $message_num, string $section, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_fetchbody($imap, $message_num, $section, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * This function causes a fetch of the complete, unfiltered RFC2822 format header of the specified + * message. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param int $message_num The message number + * @param int $flags The possible flags are: + * + * + * + * FT_UID - The msgno + * argument is a UID + * + * + * + * + * FT_INTERNAL - The return string + * is in "internal" format, without any attempt to + * canonicalize to CRLF newlines + * + * + * + * + * FT_PREFETCHTEXT - The RFC822.TEXT + * should be pre-fetched at the same time. This avoids an + * extra RTT on an IMAP connection if a full message text is + * desired (e.g. in a "save to local file" operation) + * + * + * + * @return string Returns the header of the specified message as a text string. + * @throws ImapException + * + */ +function imap_fetchheader($imap, int $message_num, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_fetchheader($imap, $message_num, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Fetch the MIME headers of a particular section of the body of the specified messages. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which + * index into a body part list as per the IMAP4 specification + * @param int $flags A bitmask with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if + * not already set + * + * + * + * + * FT_INTERNAL - The return string is in + * internal format, will not canonicalize to CRLF. + * + * + * + * @return string Returns the MIME headers of a particular section of the body of the specified messages as a + * text string. * @throws ImapException * */ -function imap_deletemailbox($imap_stream, string $mailbox): void +function imap_fetchmime($imap, int $message_num, string $section, int $flags = 0): string { error_clear_last(); - $result = \imap_deletemailbox($imap_stream, $mailbox); + $result = \imap_fetchmime($imap, $message_num, $section, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; } /** * Fetches all the structured information for a given message. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $msg_number The message number - * @param int $options This optional parameter only has a single option, + * @param int $message_num The message number + * @param int $flags This optional parameter only has a single option, * FT_UID, which tells the function to treat the - * msg_number argument as a + * message_num argument as a * UID. * @return \stdClass Returns an object with properties listed in the table below. * @@ -323,10 +708,10 @@ function imap_deletemailbox($imap_stream, string $mailbox): void * @throws ImapException * */ -function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \stdClass +function imap_fetchstructure($imap, int $message_num, int $flags = 0): \stdClass { error_clear_last(); - $result = \imap_fetchstructure($imap_stream, $msg_number, $options); + $result = \imap_fetchstructure($imap, $message_num, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -337,9 +722,9 @@ function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \ /** * Purges the cache of entries of a specific type. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $caches Specifies the cache to purge. It may one or a combination + * @param int $flags Specifies the cache to purge. It may one or a combination * of the following constants: * IMAP_GC_ELT (message cache elements), * IMAP_GC_ENV (envelope and bodies), @@ -347,27 +732,222 @@ function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \ * @throws ImapException * */ -function imap_gc($imap_stream, int $caches): void +function imap_gc($imap, int $flags): void +{ + error_clear_last(); + $result = \imap_gc($imap, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * Gets the ACL for a given mailbox. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $mailbox The mailbox name, see imap_open for more + * information + * @return array Returns an associative array of "folder" => "acl" pairs. + * @throws ImapException + * + */ +function imap_getacl($imap, string $mailbox): array +{ + error_clear_last(); + $result = \imap_getacl($imap, $mailbox); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets information on the mailboxes. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of objects containing mailbox information. Each + * object has the attributes name, specifying + * the full name of the mailbox; delimiter, + * which is the hierarchy delimiter for the part of the hierarchy + * this mailbox is in; and + * attributes. Attributes + * is a bitmask that can be tested against: + * + * + * + * LATT_NOINFERIORS - This mailbox not contains, and may not contain any + * "children" (there are no mailboxes below this one). Calling + * imap_createmailbox will not work on this mailbox. + * + * + * + * + * LATT_NOSELECT - This is only a container, + * not a mailbox - you cannot open it. + * + * + * + * + * LATT_MARKED - This mailbox is marked. This means that it may + * contain new messages since the last time it was checked. Not provided by all IMAP + * servers. + * + * + * + * + * LATT_UNMARKED - This mailbox is not marked, does not contain new + * messages. If either MARKED or UNMARKED is + * provided, you can assume the IMAP server supports this feature for this mailbox. + * + * + * + * + * LATT_REFERRAL - This container has a referral to a remote mailbox. + * + * + * + * + * LATT_HASCHILDREN - This mailbox has selectable inferiors. + * + * + * + * + * LATT_HASNOCHILDREN - This mailbox has no selectable inferiors. + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_getmailboxes($imap, string $reference, string $pattern): array +{ + error_clear_last(); + $result = \imap_getmailboxes($imap, $reference, $pattern); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets information about the subscribed mailboxes. + * + * Identical to imap_getmailboxes, except that it only + * returns mailboxes that the user is subscribed to. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of objects containing mailbox information. Each + * object has the attributes name, specifying + * the full name of the mailbox; delimiter, + * which is the hierarchy delimiter for the part of the hierarchy + * this mailbox is in; and + * attributes. Attributes + * is a bitmask that can be tested against: + * + * + * + * LATT_NOINFERIORS - This mailbox has no + * "children" (there are no mailboxes below this one). + * + * + * + * + * LATT_NOSELECT - This is only a container, + * not a mailbox - you cannot open it. + * + * + * + * + * LATT_MARKED - This mailbox is marked. + * Only used by UW-IMAPD. + * + * + * + * + * LATT_UNMARKED - This mailbox is not marked. + * Only used by UW-IMAPD. + * + * + * + * + * LATT_REFERRAL - This container has a referral to a remote mailbox. + * + * + * + * + * LATT_HASCHILDREN - This mailbox has selectable inferiors. + * + * + * + * + * LATT_HASNOCHILDREN - This mailbox has no selectable inferiors. + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_getsubscribed($imap, string $reference, string $pattern): array { error_clear_last(); - $result = \imap_gc($imap_stream, $caches); + $result = \imap_getsubscribed($imap, $reference, $pattern); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; } /** * Gets information about the given message number by reading its headers. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $msg_number The message number - * @param int $fromlength Number of characters for the fetchfrom property. + * @param int $message_num The message number + * @param int $from_length Number of characters for the fetchfrom property. * Must be greater than or equal to zero. - * @param int $subjectlength Number of characters for the fetchsubject property + * @param int $subject_length Number of characters for the fetchsubject property * Must be greater than or equal to zero. - * @param string|null $defaulthost * @return \stdClass Returns FALSE on error or, if successful, the information in an object with following properties: * * @@ -559,28 +1139,125 @@ function imap_gc($imap_stream, int $caches): void * * * - * fetchfrom - from line formatted to fit fromlength + * fetchfrom - from line formatted to fit from_length * characters * * * * * fetchsubject - subject line formatted to fit - * subjectlength characters + * subject_length characters * * * * @throws ImapException * */ -function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int $subjectlength = 0, ?string $defaulthost = null): \stdClass +function imap_headerinfo($imap, int $message_num, int $from_length = 0, int $subject_length = 0): \stdClass { error_clear_last(); - if ($defaulthost !== null) { - $result = \imap_headerinfo($imap_stream, $msg_number, $fromlength, $subjectlength, $defaulthost); - } else { - $result = \imap_headerinfo($imap_stream, $msg_number, $fromlength, $subjectlength); + $result = \imap_headerinfo($imap, $message_num, $from_length, $subject_length); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns headers for all messages in a mailbox. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @return array Returns an array of string formatted with header info. One + * element per mail message. + * Returns FALSE on failure. + * @throws ImapException + * + */ +function imap_headers($imap): array +{ + error_clear_last(); + $result = \imap_headers($imap); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns an array containing the names of the mailboxes that have + * content in the text of the mailbox. + * + * This function is similar to imap_listmailbox, + * but it will additionally check for the presence of the string + * content inside the mailbox data. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @param string $content The searched string + * @return array Returns an array containing the names of the mailboxes that have + * content in the text of the mailbox. + * @throws ImapException + * + */ +function imap_listscan($imap, string $reference, string $pattern, string $content): array +{ + error_clear_last(); + $result = \imap_listscan($imap, $reference, $pattern, $content); + if ($result === false) { + throw ImapException::createFromPhpError(); } + return $result; +} + + +/** + * Gets an array of all the mailboxes that you have subscribed. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of all the subscribed mailboxes. + * @throws ImapException + * + */ +function imap_lsub($imap, string $reference, string $pattern): array +{ + error_clear_last(); + $result = \imap_lsub($imap, $reference, $pattern); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -590,14 +1267,14 @@ function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int /** * Create a MIME message based on the given envelope - * and body sections. + * and bodies sections. * * @param array $envelope An associative array of header fields. Valid keys are: "remail", * "return_path", "date", "from", "reply_to", "in_reply_to", "subject", * "to", "cc", "bcc" and "message_id", which set the respective message headers to the given string. * To set additional headers, the key "custom_headers" is supported, which expects * an array of those headers, e.g. ["User-Agent: My Mail Client"]. - * @param array $body An indexed array of bodies. The first body is the main body of the message; + * @param array $bodies An indexed array of bodies. The first body is the main body of the message; * only if it has a type of TYPEMULTIPART, further bodies * are processed; these bodies constitute the bodies of the parts. * @@ -695,10 +1372,10 @@ function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int * @throws ImapException * */ -function imap_mail_compose(array $envelope, array $body): string +function imap_mail_compose(array $envelope, array $bodies): string { error_clear_last(); - $result = \imap_mail_compose($envelope, $body); + $result = \imap_mail_compose($envelope, $bodies); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -707,16 +1384,16 @@ function imap_mail_compose(array $envelope, array $body): string /** - * Copies mail messages specified by msglist + * Copies mail messages specified by message_nums * to specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param string $msglist msglist is a range not just message + * @param string $message_nums message_nums is a range not just message * numbers (as described in RFC2060). * @param string $mailbox The mailbox name, see imap_open for more * information - * @param int $options options is a bitmask of one or more of + * @param int $flags flags is a bitmask of one or more of * * * @@ -733,10 +1410,10 @@ function imap_mail_compose(array $envelope, array $body): string * @throws ImapException * */ -function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $options = 0): void +function imap_mail_copy($imap, string $message_nums, string $mailbox, int $flags = 0): void { error_clear_last(); - $result = \imap_mail_copy($imap_stream, $msglist, $mailbox, $options); + $result = \imap_mail_copy($imap, $message_nums, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -744,16 +1421,16 @@ function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $opt /** - * Moves mail messages specified by msglist to the + * Moves mail messages specified by message_nums to the * specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param string $msglist msglist is a range not just message numbers + * @param string $message_nums message_nums is a range not just message numbers * (as described in RFC2060). * @param string $mailbox The mailbox name, see imap_open for more * information - * @param int $options options is a bitmask and may contain the single option: + * @param int $flags flags is a bitmask and may contain the single option: * * * @@ -764,10 +1441,10 @@ function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $opt * @throws ImapException * */ -function imap_mail_move($imap_stream, string $msglist, string $mailbox, int $options = 0): void +function imap_mail_move($imap, string $message_nums, string $mailbox, int $flags = 0): void { error_clear_last(); - $result = \imap_mail_move($imap_stream, $msglist, $mailbox, $options); + $result = \imap_mail_move($imap, $message_nums, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -789,16 +1466,16 @@ function imap_mail_move($imap_stream, string $msglist, string $mailbox, int $opt * @param string $cc * @param string $bcc The receivers specified in bcc will get the * mail, but are excluded from the headers. - * @param string $rpath Use this parameter to specify return path upon mail delivery failure. + * @param string $return_path Use this parameter to specify return path upon mail delivery failure. * This is useful when using PHP as a mail client for multiple users. * @throws ImapException * */ -function imap_mail(string $to, string $subject, string $message, string $additional_headers = null, string $cc = null, string $bcc = null, string $rpath = null): void +function imap_mail(string $to, string $subject, string $message, string $additional_headers = null, string $cc = null, string $bcc = null, string $return_path = null): void { error_clear_last(); - if ($rpath !== null) { - $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $rpath); + if ($return_path !== null) { + $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $return_path); } elseif ($bcc !== null) { $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc); } elseif ($cc !== null) { @@ -820,7 +1497,7 @@ function imap_mail(string $to, string $subject, string $message, string $additio * all messages in the mailbox, which will take some additional time to * execute. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @return \stdClass Returns the information in an object with following properties: * @@ -867,10 +1544,37 @@ function imap_mail(string $to, string $subject, string $message, string $additio * @throws ImapException * */ -function imap_mailboxmsginfo($imap_stream): \stdClass +function imap_mailboxmsginfo($imap): \stdClass +{ + error_clear_last(); + $result = \imap_mailboxmsginfo($imap); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Decodes MIME message header extensions that are non ASCII text (see RFC2047). + * + * @param string $string The MIME text + * @return array The decoded elements are returned in an array of objects, where each + * object has two properties, charset and + * text. + * + * If the element hasn't been encoded, and in other words is in + * plain US-ASCII, the charset property of that element is + * set to default. + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_mime_header_decode(string $string): array { error_clear_last(); - $result = \imap_mailboxmsginfo($imap_stream); + $result = \imap_mime_header_decode($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -881,15 +1585,15 @@ function imap_mailboxmsginfo($imap_stream): \stdClass /** * Decode a modified UTF-7 (as specified in RFC 2060, section 5.1.3) string to UTF-8. * - * @param string $in A string encoded in modified UTF-7. - * @return string Returns in converted to UTF-8. + * @param string $string A string encoded in modified UTF-7. + * @return string Returns string converted to UTF-8. * @throws ImapException * */ -function imap_mutf7_to_utf8(string $in): string +function imap_mutf7_to_utf8(string $string): string { error_clear_last(); - $result = \imap_mutf7_to_utf8($in); + $result = \imap_mutf7_to_utf8($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -900,16 +1604,16 @@ function imap_mutf7_to_utf8(string $in): string /** * Gets the number of messages in the current mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @return int Return the number of messages in the current mailbox, as an integer. * @throws ImapException * */ -function imap_num_msg($imap_stream): int +function imap_num_msg($imap): int { error_clear_last(); - $result = \imap_num_msg($imap_stream); + $result = \imap_num_msg($imap); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1051,9 +1755,9 @@ function imap_num_msg($imap_stream): int * * * - * @param string $username The user name - * @param string $password The password associated with the username - * @param int $options The options are a bit mask with one or more of + * @param string $user The user name + * @param string $password The password associated with the user + * @param int $flags The flags are a bit mask with one or more of * the following: * * @@ -1107,8 +1811,8 @@ function imap_num_msg($imap_stream): int * * * - * @param int $n_retries Number of maximum connect attempts - * @param array|null $params Connection parameters, the following (string) keys maybe used + * @param int $retries Number of maximum connect attempts + * @param array $options Connection parameters, the following (string) keys maybe used * to set one or more connection parameters: * * @@ -1121,10 +1825,29 @@ function imap_num_msg($imap_stream): int * @throws ImapException * */ -function imap_open(string $mailbox, string $username, string $password, int $options = 0, int $n_retries = 0, ?array $params = null) +function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []) +{ + error_clear_last(); + $result = \imap_open($mailbox, $user, $password, $flags, $retries, $options); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Convert a quoted-printable string to an 8 bit string according to RFC2045, section 6.7. + * + * @param string $string A quoted-printable string + * @return string Returns an 8 bits string. + * @throws ImapException + * + */ +function imap_qprint(string $string): string { error_clear_last(); - $result = \imap_open($mailbox, $username, $password, $options, $n_retries, $params); + $result = \imap_qprint($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1137,40 +1860,62 @@ function imap_open(string $mailbox, string $username, string $password, int $opt * imap_open for the format of * mbox names). * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param string $old_mbox The old mailbox name, see imap_open for more + * @param string $from The old mailbox name, see imap_open for more * information - * @param string $new_mbox The new mailbox name, see imap_open for more + * @param string $to The new mailbox name, see imap_open for more + * information + * @throws ImapException + * + */ +function imap_renamemailbox($imap, string $from, string $to): void +{ + error_clear_last(); + $result = \imap_renamemailbox($imap, $from, $to); + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * Returns a properly formatted email address as defined in RFC2822 given the needed information. + * + * @param string|null $mailbox The mailbox name, see imap_open for more * information + * @param string|null $hostname The email host part + * @param string|null $personal The name of the account owner + * @return string Returns a string properly formatted email address as defined in RFC2822. * @throws ImapException * */ -function imap_renamemailbox($imap_stream, string $old_mbox, string $new_mbox): void +function imap_rfc822_write_address(?string $mailbox, ?string $hostname, ?string $personal): string { error_clear_last(); - $result = \imap_renamemailbox($imap_stream, $old_mbox, $new_mbox); + $result = \imap_rfc822_write_address($mailbox, $hostname, $personal); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; } /** * Saves a part or the whole body of the specified message. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string|resource $file The path to the saved file as a string, or a valid file descriptor * returned by fopen. - * @param int $msg_number The message number - * @param string $part_number The part number. It is a string of integers delimited by period which + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which * index into a body part list as per the IMAP4 specification - * @param int $options A bitmask with one or more of the following: + * @param int $flags A bitmask with one or more of the following: * * * - * FT_UID - The msg_number is a UID + * FT_UID - The message_num is a UID * * * @@ -1189,10 +1934,10 @@ function imap_renamemailbox($imap_stream, string $old_mbox, string $new_mbox): v * @throws ImapException * */ -function imap_savebody($imap_stream, $file, int $msg_number, string $part_number = "", int $options = 0): void +function imap_savebody($imap, $file, int $message_num, string $section = "", int $flags = 0): void { error_clear_last(); - $result = \imap_savebody($imap_stream, $file, $msg_number, $part_number, $options); + $result = \imap_savebody($imap, $file, $message_num, $section, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1202,18 +1947,18 @@ function imap_savebody($imap_stream, $file, int $msg_number, string $part_number /** * Sets an upper limit quota on a per mailbox basis. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $quota_root The mailbox to have a quota set. This should follow the IMAP standard * format for a mailbox: user.name. - * @param int $quota_limit The maximum size (in KB) for the quota_root + * @param int $mailbox_size The maximum size (in KB) for the quota_root * @throws ImapException * */ -function imap_set_quota($imap_stream, string $quota_root, int $quota_limit): void +function imap_set_quota($imap, string $quota_root, int $mailbox_size): void { error_clear_last(); - $result = \imap_set_quota($imap_stream, $quota_root, $quota_limit); + $result = \imap_set_quota($imap, $quota_root, $mailbox_size); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1223,20 +1968,20 @@ function imap_set_quota($imap_stream, string $quota_root, int $quota_limit): voi /** * Sets the ACL for a giving mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $mailbox The mailbox name, see imap_open for more * information - * @param string $id The user to give the rights to. + * @param string $user_id The user to give the rights to. * @param string $rights The rights to give to the user. Passing an empty string will delete * acl. * @throws ImapException * */ -function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): void +function imap_setacl($imap, string $mailbox, string $user_id, string $rights): void { error_clear_last(); - $result = \imap_setacl($imap_stream, $mailbox, $id, $rights); + $result = \imap_setacl($imap, $mailbox, $user_id, $rights); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1248,7 +1993,7 @@ function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): * flags set for the messages in the specified * sequence. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $sequence A sequence of message numbers. You can enumerate desired messages * with the X,Y syntax, or retrieve all messages @@ -1269,10 +2014,10 @@ function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): * @throws ImapException * */ -function imap_setflag_full($imap_stream, string $sequence, string $flag, int $options = NIL): void +function imap_setflag_full($imap, string $sequence, string $flag, int $options = 0): void { error_clear_last(); - $result = \imap_setflag_full($imap_stream, $sequence, $flag, $options); + $result = \imap_setflag_full($imap, $sequence, $flag, $options); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1282,7 +2027,7 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op /** * Gets and sorts message numbers by the given parameters. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param int $criteria Criteria can be one (and only one) of the following: * @@ -1322,8 +2067,8 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op * * * - * @param int $reverse Set this to 1 for reverse sorting - * @param int $options The options are a bitmask of one or more of the + * @param int $reverse Whether to sort in reverse order. + * @param int $flags The flags are a bitmask of one or more of the * following: * * @@ -1345,16 +2090,83 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op * @throws ImapException * */ -function imap_sort($imap_stream, int $criteria, int $reverse, int $options = 0, string $search_criteria = null, string $charset = null): array +function imap_sort($imap, int $criteria, int $reverse, int $flags = 0, string $search_criteria = null, string $charset = null): array { error_clear_last(); if ($charset !== null) { - $result = \imap_sort($imap_stream, $criteria, $reverse, $options, $search_criteria, $charset); + $result = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria, $charset); } elseif ($search_criteria !== null) { - $result = \imap_sort($imap_stream, $criteria, $reverse, $options, $search_criteria); + $result = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria); } else { - $result = \imap_sort($imap_stream, $criteria, $reverse, $options); + $result = \imap_sort($imap, $criteria, $reverse, $flags); + } + if ($result === false) { + throw ImapException::createFromPhpError(); } + return $result; +} + + +/** + * Gets status information about the given mailbox. + * + * @param resource $imap An IMAP stream returned by + * imap_open. + * @param string $mailbox The mailbox name, see imap_open for more + * information + * @param int $flags Valid flags are: + * + * + * + * SA_MESSAGES - set $status->messages to the + * number of messages in the mailbox + * + * + * + * + * SA_RECENT - set $status->recent to the number + * of recent messages in the mailbox + * + * + * + * + * SA_UNSEEN - set $status->unseen to the number + * of unseen (new) messages in the mailbox + * + * + * + * + * SA_UIDNEXT - set $status->uidnext to the next + * uid to be used in the mailbox + * + * + * + * + * SA_UIDVALIDITY - set $status->uidvalidity to a + * constant that changes when uids for the mailbox may no longer be + * valid + * + * + * + * + * SA_ALL - set all of the above + * + * + * + * @return \stdClass This function returns an object containing status information. + * The object has the following properties: messages, + * recent, unseen, + * uidnext, and uidvalidity. + * + * flags is also set, which contains a bitmask which can + * be checked against any of the above constants. + * @throws ImapException + * + */ +function imap_status($imap, string $mailbox, int $flags): \stdClass +{ + error_clear_last(); + $result = \imap_status($imap, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1365,17 +2177,17 @@ function imap_sort($imap_stream, int $criteria, int $reverse, int $options = 0, /** * Subscribe to a new mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $mailbox The mailbox name, see imap_open for more * information * @throws ImapException * */ -function imap_subscribe($imap_stream, string $mailbox): void +function imap_subscribe($imap, string $mailbox): void { error_clear_last(); - $result = \imap_subscribe($imap_stream, $mailbox); + $result = \imap_subscribe($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1385,9 +2197,9 @@ function imap_subscribe($imap_stream, string $mailbox): void /** * Gets a tree of a threaded message. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $options + * @param int $flags * @return array imap_thread returns an associative array containing * a tree of messages threaded by REFERENCES. * @@ -1407,10 +2219,10 @@ function imap_subscribe($imap_stream, string $mailbox): void * @throws ImapException * */ -function imap_thread($imap_stream, int $options = SE_FREE): array +function imap_thread($imap, int $flags = SE_FREE): array { error_clear_last(); - $result = \imap_thread($imap_stream, $options); + $result = \imap_thread($imap, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1451,17 +2263,17 @@ function imap_timeout(int $timeout_type, int $timeout = -1) * Removes the deletion flag for a specified message, which is set by * imap_delete or imap_mail_move. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. - * @param int $msg_number The message number + * @param int $message_num The message number * @param int $flags * @throws ImapException * */ -function imap_undelete($imap_stream, int $msg_number, int $flags = 0): void +function imap_undelete($imap, int $message_num, int $flags = 0): void { error_clear_last(); - $result = \imap_undelete($imap_stream, $msg_number, $flags); + $result = \imap_undelete($imap, $message_num, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1471,17 +2283,17 @@ function imap_undelete($imap_stream, int $msg_number, int $flags = 0): void /** * Unsubscribe from the specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by + * @param resource $imap An IMAP stream returned by * imap_open. * @param string $mailbox The mailbox name, see imap_open for more * information * @throws ImapException * */ -function imap_unsubscribe($imap_stream, string $mailbox): void +function imap_unsubscribe($imap, string $mailbox): void { error_clear_last(); - $result = \imap_unsubscribe($imap_stream, $mailbox); + $result = \imap_unsubscribe($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1491,15 +2303,15 @@ function imap_unsubscribe($imap_stream, string $mailbox): void /** * Encode a UTF-8 string to modified UTF-7 (as specified in RFC 2060, section 5.1.3). * - * @param string $in A UTF-8 encoded string. - * @return string Returns in converted to modified UTF-7. + * @param string $string A UTF-8 encoded string. + * @return string Returns string converted to modified UTF-7. * @throws ImapException * */ -function imap_utf8_to_mutf7(string $in): string +function imap_utf8_to_mutf7(string $string): string { error_clear_last(); - $result = \imap_utf8_to_mutf7($in); + $result = \imap_utf8_to_mutf7($string); if ($result === false) { throw ImapException::createFromPhpError(); } diff --git a/generated/info.php b/generated/info.php index 29d2642b..e2aa08a1 100644 --- a/generated/info.php +++ b/generated/info.php @@ -273,12 +273,12 @@ function ini_get(string $option): string * @param string $option Not all the available options can be changed using * ini_set. There is a list of all available options * in the appendix. - * @param string|int|float|bool $value The new value for the option. + * @param string $value The new value for the option. * @return string Returns the old value on success, FALSE on failure. * @throws InfoException * */ -function ini_set(string $option, $value): string +function ini_set(string $option, string $value): string { error_clear_last(); $result = \ini_set($option, $value); @@ -301,7 +301,7 @@ function ini_set(string $option, $value): string * cgi-fcgi, cli, cli-server, * embed, fpm-fcgi, * litespeed, - * nsapi, phpdbg. + * phpdbg. * @throws InfoException * */ diff --git a/generated/ldap.php b/generated/ldap.php index c2bc0956..b579ac29 100644 --- a/generated/ldap.php +++ b/generated/ldap.php @@ -236,11 +236,11 @@ function ldap_delete_ext($ldap, string $dn, array $controls = null) * * @param resource $ldap An LDAP link identifier, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_delete($ldap, string $dn, $controls = null): void +function ldap_delete($ldap, string $dn, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -284,7 +284,7 @@ function ldap_dn2ufn(string $dn): string * @param array $controls If provided, a password policy request control is send with the request and this is * filled with an array of LDAP Controls * returned with the request. - * @return mixed Returns the generated password if new_password is empty or omitted. + * @return string|bool Returns the generated password if new_password is empty or omitted. * Otherwise returns TRUE on success. * @throws LdapException * @@ -304,11 +304,11 @@ function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", s * Performs a WHOAMI extended operation and returns the data. * * @param resource $ldap An LDAP link identifier, returned by ldap_connect. - * @return string The data returned by the server. + * @return string|bool The data returned by the server. * @throws LdapException * */ -function ldap_exop_whoami($ldap): string +function ldap_exop_whoami($ldap) { error_clear_last(); $result = \ldap_exop_whoami($ldap); @@ -332,7 +332,7 @@ function ldap_exop_whoami($ldap): string * If not provided you may use ldap_parse_exop on the result object * later to get this data. * @param string|null $retoid Will be filled with the response OID if provided, usually equal to the request OID. - * @return mixed When used with retdata, returns TRUE on success. + * @return resource|bool When used with retdata, returns TRUE on success. * When used without retdata, returns a result identifier. * @throws LdapException * @@ -697,7 +697,7 @@ function ldap_get_entries($ldap, $result): array * 7.1 * * - * LDAP_OPT_X_TLS_KEYILE + * LDAP_OPT_X_TLS_KEYFILE * string * 7.1 * @@ -877,12 +877,12 @@ function ldap_get_values($ldap, $entry, string $attribute): array * * * - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @return resource Returns a search result identifier. * @throws LdapException * */ -function ldap_list($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, $controls = null) +function ldap_list($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = null) { error_clear_last(); if ($controls !== null) { @@ -930,11 +930,11 @@ function ldap_mod_add_ext($ldap, string $dn, array $entry, array $controls = nul * @param resource $ldap An LDAP link identifier, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry An associative array listing the attirbute values to add. If an attribute was not existing yet it will be added. If an attribute is existing you can only add values to it if it supports multiple values. - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_add($ldap, string $dn, array $entry, $controls = null): void +function ldap_mod_add($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -982,11 +982,11 @@ function ldap_mod_del_ext($ldap, string $dn, array $entry, array $controls = nul * @param resource $ldap An LDAP link identifier, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_del($ldap, string $dn, array $entry, $controls = null): void +function ldap_mod_del($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -1033,11 +1033,11 @@ function ldap_mod_replace_ext($ldap, string $dn, array $entry, array $controls = * @param resource $ldap An LDAP link identifier, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry An associative array listing the attributes to replace. Sending an empty array as value will remove the attribute, while sending an attribute not existing yet on this entry will add it. - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_replace($ldap, string $dn, array $entry, $controls = null): void +function ldap_mod_replace($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -1130,13 +1130,13 @@ function ldap_mod_replace($ldap, string $dn, array $entry, $controls = null): vo * value for values must be an array of strings, and * any value for modtype must be one of the * LDAP_MODIFY_BATCH_* constants listed above. - * @param $controls Each value specified through values is added (as + * @param array $controls Each value specified through values is added (as * an additional value) to the attribute named by * attrib. * @throws LdapException * */ -function ldap_modify_batch($ldap, string $dn, array $modifications_info, $controls = null): void +function ldap_modify_batch($ldap, string $dn, array $modifications_info, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -1290,12 +1290,12 @@ function ldap_parse_result($ldap, $result, ?int &$error_code, ?string &$matched_ * * * - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @return resource Returns a search result identifier. * @throws LdapException * */ -function ldap_read($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, $controls = null) +function ldap_read($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = null) { error_clear_last(); if ($controls !== null) { @@ -1347,11 +1347,11 @@ function ldap_rename_ext($ldap, string $dn, string $new_rdn, string $new_parent, * @param string $new_parent The new parent/superior entry. * @param bool $delete_old_rdn If TRUE the old RDN value(s) is removed, else the old RDN value(s) * is retained as non-distinguished values of the entry. - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, $controls = null): void +function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, array $controls = null): void { error_clear_last(); if ($controls !== null) { @@ -1486,12 +1486,12 @@ function ldap_sasl_bind($ldap, string $dn = null, string $password = null, strin * * * - * @param $controls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @return resource Returns a search result identifier. * @throws LdapException * */ -function ldap_search($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, $controls = null) +function ldap_search($ldap, string $base, string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = null) { error_clear_last(); if ($controls !== null) { diff --git a/generated/libxml.php b/generated/libxml.php index cef784c4..cab8297a 100644 --- a/generated/libxml.php +++ b/generated/libxml.php @@ -21,23 +21,3 @@ function libxml_get_last_error(): \LibXMLError } return $result; } - - -/** - * Changes the default external entity loader. - * - * @param callable $resolver_function A callable that takes three arguments. Two strings, a public id - * and system id, and a context (an array with four keys) as the third argument. - * This callback should return a resource, a string from which a resource can be - * opened, or NULL. - * @throws LibxmlException - * - */ -function libxml_set_external_entity_loader(callable $resolver_function): void -{ - error_clear_last(); - $result = \libxml_set_external_entity_loader($resolver_function); - if ($result === false) { - throw LibxmlException::createFromPhpError(); - } -} diff --git a/generated/mbstring.php b/generated/mbstring.php index 11a72479..113e2260 100644 --- a/generated/mbstring.php +++ b/generated/mbstring.php @@ -35,7 +35,7 @@ function mb_chr(int $codepoint, string $encoding = null): string * If string is an array, all its string values will be * converted recursively. * - * @param string $string The string or array being encoded. + * @param string|array $string The string or array being encoded. * @param string $to_encoding The type of encoding that string is being converted to. * @param mixed $from_encoding Is specified by character code names before conversion. It is either * an array, or a comma separated enumerated list. @@ -45,11 +45,11 @@ function mb_chr(int $codepoint, string $encoding = null): string * * See supported * encodings. - * @return string The encoded string or array on success. + * @return string|array The encoded string or array on success. * @throws MbstringException * */ -function mb_convert_encoding(string $string, string $to_encoding, $from_encoding = null): string +function mb_convert_encoding($string, string $to_encoding, $from_encoding = null) { error_clear_last(); if ($from_encoding !== null) { diff --git a/generated/openssl.php b/generated/openssl.php index 4db1d989..985b8ade 100644 --- a/generated/openssl.php +++ b/generated/openssl.php @@ -23,6 +23,148 @@ function openssl_cipher_iv_length(string $method): int } +/** + * Decrypts a CMS message. + * + * @param string $input_filename The name of a file containing encrypted content. + * @param string $output_filename The name of the file to deposit the decrypted content. + * @param $certificate The name of the file containing a certificate of the recipient. + * @param $private_key The name of the file containing a PKCS#8 key. + * @param int $encoding The encoding of the input file. One of OPENSSL_CMS_SMIME, + * OPENSLL_CMS_DER or OPENSSL_CMS_PEM. + * @throws OpensslException + * + */ +function openssl_cms_decrypt(string $input_filename, string $output_filename, $certificate, $private_key = null, int $encoding = OPENSSL_ENCODING_SMIME): void +{ + error_clear_last(); + if ($encoding !== OPENSSL_ENCODING_SMIME) { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate, $private_key, $encoding); + } elseif ($private_key !== null) { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate, $private_key); + } else { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function encrypts content to one or more recipients, + * based on the certificates that are passed to it. + * + * @param string $input_filename The file to be encrypted. + * @param string $output_filename The output file. + * @param $certificate Recipients to encrypt to. + * @param $headers Headers to include when S/MIME is used. + * @param int $flags Flags to be passed to CMS_sign. + * @param int $encoding An encoding to output. One of OPENSSL_CMS_SMIME, + * OPENSLL_CMS_DER or OPENSSL_CMS_PEM. + * @param int $cipher_algo A cypher to use. + * @throws OpensslException + * + */ +function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_RC2_40): void +{ + error_clear_last(); + $result = \openssl_cms_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $encoding, $cipher_algo); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * Performs the exact analog to openssl_pkcs7_read. + * + * @param string $input_filename + * @param array $certificates + * @throws OpensslException + * + */ +function openssl_cms_read(string $input_filename, array &$certificates): void +{ + error_clear_last(); + $result = \openssl_cms_read($input_filename, $certificates); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function signs a file with an X.509 certificate and key. + * + * @param string $input_filename The name of the file to be signed. + * @param string $output_filename The name of the file to deposit the results. + * @param $certificate The name of the file containing the signing certificate. + * @param $private_key The name of file containing the key associated with certificate. + * @param $headers An array of headers to be included in S/MIME output. + * @param int $flags Flags to be passed to cms_sign. + * @param int $encoding The encoding of the output file. One of OPENSSL_CMS_SMIME, + * OPENSLL_CMS_DER or OPENSSL_CMS_PEM. + * @param $untrusted_certificates_filename Intermediate certificates to be included in the signature. + * @throws OpensslException + * + */ +function openssl_cms_sign(string $input_filename, string $output_filename, $certificate, $private_key, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, $untrusted_certificates_filename = null): void +{ + error_clear_last(); + if ($untrusted_certificates_filename !== null) { + $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding, $untrusted_certificates_filename); + } else { + $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function verifies a CMS signature, either attached or detached, with the specified encoding. + * + * @param string $input_filename The input file. + * @param int $flags Flags to pass to cms_verify. + * @param $certificates A file with the signer certificate and optionally intermediate certificates. + * @param array $ca_info An array containing self-signed certificate authority certificates. + * @param $untrusted_certificates_filename A file containing additional intermediate certificates. + * @param $content A file pointing to the content when signatures are detached. + * @param $pk7 + * @param $sigfile A file to save the signature to. + * @param int $encoding The encoding of the input file. One of OPENSSL_CMS_SMIME, + * OPENSLL_CMS_DER or OPENSSL_CMS_PEM. + * @throws OpensslException + * + */ +function openssl_cms_verify(string $input_filename, int $flags = 0, $certificates = null, array $ca_info = [], $untrusted_certificates_filename = null, $content = null, $pk7 = null, $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): void +{ + error_clear_last(); + if ($encoding !== OPENSSL_ENCODING_SMIME) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7, $sigfile, $encoding); + } elseif ($sigfile !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7, $sigfile); + } elseif ($pk7 !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7); + } elseif ($content !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content); + } elseif ($untrusted_certificates_filename !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename); + } elseif ($ca_info !== []) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info); + } elseif ($certificates !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates); + } else { + $result = \openssl_cms_verify($input_filename, $flags); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + /** * openssl_csr_export_to_file takes the Certificate * Signing Request represented by csr and saves it @@ -645,7 +787,7 @@ function openssl_pkcs7_sign(string $infilename, string $outfilename, $signcert, * * @param resource|string|array $key * @param string $outfilename Path to the output file. - * @param string $passphrase The key can be optionally protected by a + * @param string|null $passphrase The key can be optionally protected by a * passphrase. * @param array $configargs configargs can be used to fine-tune the export * process by specifying and/or overriding options for the openssl @@ -654,7 +796,7 @@ function openssl_pkcs7_sign(string $infilename, string $outfilename, $signcert, * @throws OpensslException * */ -function openssl_pkey_export_to_file($key, string $outfilename, string $passphrase = null, array $configargs = null): void +function openssl_pkey_export_to_file($key, string $outfilename, ?string $passphrase = null, array $configargs = null): void { error_clear_last(); if ($configargs !== null) { @@ -677,7 +819,7 @@ function openssl_pkey_export_to_file($key, string $outfilename, string $passphra * * @param resource $key * @param string|null $out - * @param string $passphrase The key is optionally protected by passphrase. + * @param string|null $passphrase The key is optionally protected by passphrase. * @param array $configargs configargs can be used to fine-tune the export * process by specifying and/or overriding options for the openssl * configuration file. See openssl_csr_new for more @@ -685,7 +827,7 @@ function openssl_pkey_export_to_file($key, string $outfilename, string $passphra * @throws OpensslException * */ -function openssl_pkey_export($key, ?string &$out, string $passphrase = null, array $configargs = null): void +function openssl_pkey_export($key, ?string &$out, ?string $passphrase = null, array $configargs = null): void { error_clear_last(); if ($configargs !== null) { @@ -762,9 +904,9 @@ function openssl_pkey_get_public($certificate) /** - * openssl_pkey_new generates a new private and public - * key pair. The public component of the key can be obtained using - * openssl_pkey_get_public. + * openssl_pkey_new generates a new private + * key. + * How to obtain the public component of the key is shown in an example below. * * @param array $configargs You can finetune the key generation (such as specifying the number of * bits) using configargs. See @@ -948,7 +1090,7 @@ function openssl_random_pseudo_bytes(int $length, ?bool &$crypto_strong = null): * * @param string $data The data to seal. * @param string|null $sealed_data The sealed data. - * @param array $env_keys Array of encrypted keys. + * @param array|null $env_keys Array of encrypted keys. * @param array $pub_key_ids Array of public key resource identifiers. * @param string $method The cipher method. * @@ -965,7 +1107,7 @@ function openssl_random_pseudo_bytes(int $length, ?bool &$crypto_strong = null): * @throws OpensslException * */ -function openssl_seal(string $data, ?string &$sealed_data, array &$env_keys, array $pub_key_ids, string $method = "RC4", string &$iv = null): int +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(); $result = \openssl_seal($data, $sealed_data, $env_keys, $pub_key_ids, $method, $iv); diff --git a/generated/pcre.php b/generated/pcre.php index ac46d938..53ebff61 100644 --- a/generated/pcre.php +++ b/generated/pcre.php @@ -347,7 +347,7 @@ * @throws PcreException * */ -function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = PREG_PATTERN_ORDER, int $offset = 0): int +function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int { error_clear_last(); $result = \preg_match_all($pattern, $subject, $matches, $flags, $offset); diff --git a/generated/posix.php b/generated/posix.php index fde85176..1532a9a5 100644 --- a/generated/posix.php +++ b/generated/posix.php @@ -7,8 +7,8 @@ /** * posix_access checks the user's permission of a file. * - * @param string $file The name of the file to be tested. - * @param int $mode A mask consisting of one or more of POSIX_F_OK, + * @param string $filename The name of the file to be tested. + * @param int $flags A mask consisting of one or more of POSIX_F_OK, * POSIX_R_OK, POSIX_W_OK and * POSIX_X_OK. * @@ -20,16 +20,80 @@ * @throws PosixException * */ -function posix_access(string $file, int $mode = POSIX_F_OK): void +function posix_access(string $filename, int $flags = 0): void { error_clear_last(); - $result = \posix_access($file, $mode); + $result = \posix_access($filename, $flags); if ($result === false) { throw PosixException::createFromPhpError(); } } +/** + * Gets information about a group provided its id. + * + * @param int $group_id The group id. + * @return array The array elements returned are: + * + * The group information array + * + * + * + * Element + * Description + * + * + * + * + * name + * + * The name element contains the name of the group. This is + * a short, usually less than 16 character "handle" of the + * group, not the real, full name. + * + * + * + * passwd + * + * The passwd element contains the group's password in an + * encrypted format. Often, for example on a system employing + * "shadow" passwords, an asterisk is returned instead. + * + * + * + * gid + * + * Group ID, should be the same as the + * group_id parameter used when calling the + * function, and hence redundant. + * + * + * + * members + * + * This consists of an array of + * string's for all the members in the group. + * + * + * + * + * + * The function returns FALSE on failure. + * @throws PosixException + * + */ +function posix_getgrgid(int $group_id): array +{ + error_clear_last(); + $result = \posix_getgrgid($group_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + /** * Gets information about a group provided its name. * @@ -94,19 +158,281 @@ function posix_getgrnam(string $name): array } +/** + * Gets the group set of the current process. + * + * @return array Returns an array of integers containing the numeric group ids of the group + * set of the current process. + * @throws PosixException + * + */ +function posix_getgroups(): array +{ + error_clear_last(); + $result = \posix_getgroups(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns the login name of the user owning the current process. + * + * @return string Returns the login name of the user, as a string. + * @throws PosixException + * + */ +function posix_getlogin(): string +{ + error_clear_last(); + $result = \posix_getlogin(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + /** * Returns the process group identifier of the process - * pid. + * process_id. * - * @param int $pid The process id. + * @param int $process_id The process id. * @return int Returns the identifier, as an int. * @throws PosixException * */ -function posix_getpgid(int $pid): int +function posix_getpgid(int $process_id): int { error_clear_last(); - $result = \posix_getpgid($pid); + $result = \posix_getpgid($process_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns an array of information about the user + * referenced by the given user ID. + * + * @param int $user_id The user identifier. + * @return array Returns an associative array with the following elements: + * + * The user information array + * + * + * + * Element + * Description + * + * + * + * + * name + * + * The name element contains the username of the user. This is + * a short, usually less than 16 character "handle" of the + * user, not the real, full name. + * + * + * + * passwd + * + * The passwd element contains the user's password in an + * encrypted format. Often, for example on a system employing + * "shadow" passwords, an asterisk is returned instead. + * + * + * + * uid + * + * User ID, should be the same as the + * user_id parameter used when calling the + * function, and hence redundant. + * + * + * + * gid + * + * The group ID of the user. Use the function + * posix_getgrgid to resolve the group + * name and a list of its members. + * + * + * + * gecos + * + * GECOS is an obsolete term that refers to the finger + * information field on a Honeywell batch processing system. + * The field, however, lives on, and its contents have been + * formalized by POSIX. The field contains a comma separated + * list containing the user's full name, office phone, office + * number, and home phone number. On most systems, only the + * user's full name is available. + * + * + * + * dir + * + * This element contains the absolute path to the + * home directory of the user. + * + * + * + * shell + * + * The shell element contains the absolute path to the + * executable of the user's default shell. + * + * + * + * + * + * The function returns FALSE on failure. + * @throws PosixException + * + */ +function posix_getpwuid(int $user_id): array +{ + error_clear_last(); + $result = \posix_getpwuid($user_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * posix_getrlimit returns an array + * of information about the current resource's soft and hard limits. + * + * + * Each resource has an associated soft and hard limit. The soft + * limit is the value that the kernel enforces for the corresponding + * resource. The hard limit acts as a ceiling for the soft limit. + * An unprivileged process may only set its soft limit to a value + * from 0 to the hard limit, and irreversibly lower its hard limit. + * + * @return array Returns an associative array of elements for each + * limit that is defined. Each limit has a soft and a hard limit. + * + * List of possible limits returned + * + * + * + * Limit name + * Limit description + * + * + * + * + * core + * + * The maximum size of the core file. When 0, not core files are + * created. When core files are larger than this size, they will + * be truncated at this size. + * + * + * + * totalmem + * + * The maximum size of the memory of the process, in bytes. + * + * + * + * virtualmem + * + * The maximum size of the virtual memory for the process, in bytes. + * + * + * + * data + * + * The maximum size of the data segment for the process, in bytes. + * + * + * + * stack + * + * The maximum size of the process stack, in bytes. + * + * + * + * rss + * + * The maximum number of virtual pages resident in RAM + * + * + * + * maxproc + * + * The maximum number of processes that can be created for the + * real user ID of the calling process. + * + * + * + * memlock + * + * The maximum number of bytes of memory that may be locked into RAM. + * + * + * + * cpu + * + * The amount of time the process is allowed to use the CPU. + * + * + * + * filesize + * + * The maximum size of the data segment for the process, in bytes. + * + * + * + * openfiles + * + * One more than the maximum number of open file descriptors. + * + * + * + * + * + * The function returns FALSE on failure. + * @throws PosixException + * + */ +function posix_getrlimit(): array +{ + error_clear_last(); + $result = \posix_getrlimit(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * Return the session id of the process process_id. + * The session id of a process is the process group id of the session leader. + * + * @param int $process_id The process identifier. If set to 0, the current process is + * assumed. If an invalid process_id is + * specified, then FALSE is returned and an error is set which + * can be checked with posix_get_last_error. + * @return int Returns the identifier, as an int. + * @throws PosixException + * + */ +function posix_getsid(int $process_id): int +{ + error_clear_last(); + $result = \posix_getsid($process_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -117,15 +443,15 @@ function posix_getpgid(int $pid): int /** * Calculates the group access list for the user specified in name. * - * @param string $name The user to calculate the list for. - * @param int $base_group_id Typically the group number from the password file. + * @param string $username The user to calculate the list for. + * @param int $group_id Typically the group number from the password file. * @throws PosixException * */ -function posix_initgroups(string $name, int $base_group_id): void +function posix_initgroups(string $username, int $group_id): void { error_clear_last(); - $result = \posix_initgroups($name, $base_group_id); + $result = \posix_initgroups($username, $group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -133,18 +459,18 @@ function posix_initgroups(string $name, int $base_group_id): void /** - * Send the signal sig to the process with - * the process identifier pid. + * Send the signal signal to the process with + * the process identifier process_id. * - * @param int $pid The process identifier. - * @param int $sig One of the PCNTL signals constants. + * @param int $process_id The process identifier. + * @param int $signal One of the PCNTL signals constants. * @throws PosixException * */ -function posix_kill(int $pid, int $sig): void +function posix_kill(int $process_id, int $signal): void { error_clear_last(); - $result = \posix_kill($pid, $sig); + $result = \posix_kill($process_id, $signal); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -156,8 +482,8 @@ function posix_kill(int $pid, int $sig): void * FIFO file which exists in the file system and acts as * a bidirectional communication endpoint for processes. * - * @param string $pathname Path to the FIFO file. - * @param int $mode The second parameter mode has to be given in + * @param string $filename Path to the FIFO file. + * @param int $permissions The second parameter permissions has to be given in * octal notation (e.g. 0644). The permission of the newly created * FIFO also depends on the setting of the current * umask. The permissions of the created file are @@ -165,10 +491,10 @@ function posix_kill(int $pid, int $sig): void * @throws PosixException * */ -function posix_mkfifo(string $pathname, int $mode): void +function posix_mkfifo(string $filename, int $permissions): void { error_clear_last(); - $result = \posix_mkfifo($pathname, $mode); + $result = \posix_mkfifo($filename, $permissions); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -178,8 +504,8 @@ function posix_mkfifo(string $pathname, int $mode): void /** * Creates a special or ordinary file. * - * @param string $pathname The file to create - * @param int $mode This parameter is constructed by a bitwise OR between file type (one of + * @param string $filename The file to create + * @param int $flags This parameter is constructed by a bitwise OR between file type (one of * the following constants: POSIX_S_IFREG, * POSIX_S_IFCHR, POSIX_S_IFBLK, * POSIX_S_IFIFO or @@ -190,10 +516,10 @@ function posix_mkfifo(string $pathname, int $mode): void * @throws PosixException * */ -function posix_mknod(string $pathname, int $mode, int $major = 0, int $minor = 0): void +function posix_mknod(string $filename, int $flags, int $major = 0, int $minor = 0): void { error_clear_last(); - $result = \posix_mknod($pathname, $mode, $major, $minor); + $result = \posix_mknod($filename, $flags, $major, $minor); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -205,14 +531,14 @@ function posix_mknod(string $pathname, int $mode, int $major = 0, int $minor = 0 * privileged function and needs appropriate privileges (usually * root) on the system to be able to perform this function. * - * @param int $gid The group id. + * @param int $group_id The group id. * @throws PosixException * */ -function posix_setegid(int $gid): void +function posix_setegid(int $group_id): void { error_clear_last(); - $result = \posix_setegid($gid); + $result = \posix_setegid($group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -224,14 +550,14 @@ function posix_setegid(int $gid): void * function and needs appropriate privileges (usually root) on * the system to be able to perform this function. * - * @param int $uid The user id. + * @param int $user_id The user id. * @throws PosixException * */ -function posix_seteuid(int $uid): void +function posix_seteuid(int $user_id): void { error_clear_last(); - $result = \posix_seteuid($uid); + $result = \posix_seteuid($user_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -246,14 +572,14 @@ function posix_seteuid(int $uid): void * posix_setgid first, * posix_setuid last. * - * @param int $gid The group id. + * @param int $group_id The group id. * @throws PosixException * */ -function posix_setgid(int $gid): void +function posix_setgid(int $group_id): void { error_clear_last(); - $result = \posix_setgid($gid); + $result = \posix_setgid($group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -261,18 +587,18 @@ function posix_setgid(int $gid): void /** - * Let the process pid join the process group - * pgid. + * Let the process process_id join the process group + * process_group_id. * - * @param int $pid The process id. - * @param int $pgid The process group id. + * @param int $process_id The process id. + * @param int $process_group_id The process group id. * @throws PosixException * */ -function posix_setpgid(int $pid, int $pgid): void +function posix_setpgid(int $process_id, int $process_group_id): void { error_clear_last(); - $result = \posix_setpgid($pid, $pgid); + $result = \posix_setpgid($process_id, $process_group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -293,17 +619,17 @@ function posix_setpgid(int $pid, int $pgid): void * @param int $resource The * resource limit constant * corresponding to the limit that is being set. - * @param int $softlimit The soft limit, in whatever unit the resource limit requires, or + * @param int $soft_limit The soft limit, in whatever unit the resource limit requires, or * POSIX_RLIMIT_INFINITY. - * @param int $hardlimit The hard limit, in whatever unit the resource limit requires, or + * @param int $hard_limit The hard limit, in whatever unit the resource limit requires, or * POSIX_RLIMIT_INFINITY. * @throws PosixException * */ -function posix_setrlimit(int $resource, int $softlimit, int $hardlimit): void +function posix_setrlimit(int $resource, int $soft_limit, int $hard_limit): void { error_clear_last(); - $result = \posix_setrlimit($resource, $softlimit, $hardlimit); + $result = \posix_setrlimit($resource, $soft_limit, $hard_limit); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -315,15 +641,113 @@ function posix_setrlimit(int $resource, int $softlimit, int $hardlimit): void * function that needs appropriate privileges (usually root) on * the system to be able to perform this function. * - * @param int $uid The user id. + * @param int $user_id The user id. + * @throws PosixException + * + */ +function posix_setuid(int $user_id): void +{ + error_clear_last(); + $result = \posix_setuid($user_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } +} + + +/** + * Gets information about the current CPU usage. + * + * @return array Returns a hash of strings with information about the current + * process CPU usage. The indices of the hash are: + * + * + * + * ticks - the number of clock ticks that have elapsed since + * reboot. + * + * + * + * + * utime - user time used by the current process. + * + * + * + * + * stime - system time used by the current process. + * + * + * + * + * cutime - user time used by current process and children. + * + * + * + * + * cstime - system time used by current process and children. + * + * + * + * The function returns FALSE on failure. * @throws PosixException * */ -function posix_setuid(int $uid): void +function posix_times(): array { error_clear_last(); - $result = \posix_setuid($uid); + $result = \posix_times(); if ($result === false) { throw PosixException::createFromPhpError(); } + return $result; +} + + +/** + * Gets information about the system. + * + * Posix requires that assumptions must not be made about the + * format of the values, e.g. the assumption that a release may contain + * three digits or anything else returned by this function. + * + * @return array Returns a hash of strings with information about the + * system. The indices of the hash are + * + * + * sysname - operating system name (e.g. Linux) + * + * + * nodename - system name (e.g. valiant) + * + * + * release - operating system release (e.g. 2.2.10) + * + * + * version - operating system version (e.g. #4 Tue Jul 20 + * 17:01:36 MEST 1999) + * + * + * machine - system architecture (e.g. i586) + * + * + * domainname - DNS domainname (e.g. example.com) + * + * + * + * domainname is a GNU extension and not part of POSIX.1, so this + * field is only available on GNU systems or when using the GNU + * libc. + * + * The function returns FALSE on failure. + * @throws PosixException + * + */ +function posix_uname(): array +{ + error_clear_last(); + $result = \posix_uname(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; } diff --git a/generated/ps.php b/generated/ps.php index a66667aa..a2dca797 100644 --- a/generated/ps.php +++ b/generated/ps.php @@ -558,7 +558,7 @@ function ps_delete($psdoc): void * Ends a page which was started with ps_begin_page. * Ending a page will leave the current drawing context, which e.g. requires * to reload fonts if they were loading within the page, and to set many - * other drawing parameters like the line width, or color.. + * other drawing parameters like the line width, or color. * * @param resource $psdoc Resource identifier of the postscript file * as returned by ps_new. diff --git a/generated/sockets.php b/generated/sockets.php index aa158a19..63ceb10a 100644 --- a/generated/sockets.php +++ b/generated/sockets.php @@ -10,23 +10,23 @@ * socket_bind, and told to listen for connections * with socket_listen, this function will accept * incoming connections on that socket. Once a successful connection - * is made, a new socket resource is returned, which may be used - * for communication. If there are multiple connections queued on - * the socket, the first will be used. If there are no pending + * is made, a new Socket instance is returned, + * which may be used for communication. If there are multiple connections + * queued on the socket, the first will be used. If there are no pending * connections, socket_accept will block until * a connection becomes present. If socket * has been made non-blocking using * socket_set_blocking or * socket_set_nonblock, FALSE will be returned. * - * The socket resource returned by + * The Socket instance returned by * socket_accept may not be used to accept new * connections. The original listening socket * socket, however, remains open and may be * reused. * - * @param resource $socket A valid socket resource created with socket_create. - * @return resource Returns a new socket resource on success. The actual + * @param resource $socket A Socket instance created with socket_create. + * @return resource Returns a new Socket instance on success. The actual * error code can be retrieved by calling * socket_last_error. This error code may be passed to * socket_strerror to get a textual explanation of the @@ -46,19 +46,19 @@ function socket_accept($socket) /** - * Create a Socket resource, and bind it to the provided AddrInfo resource. The return + * Create a Socket instance, and bind it to the provided AddressInfo. The return * value of this function may be used with socket_listen. * - * @param resource $addr Resource created from socket_addrinfo_lookup. - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup. + * @return resource|null Returns a Socket instance on success. * @throws SocketsException * */ -function socket_addrinfo_bind($addr) +function socket_addrinfo_bind($address) { error_clear_last(); - $result = \socket_addrinfo_bind($addr); - if ($result === null) { + $result = \socket_addrinfo_bind($address); + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -66,19 +66,50 @@ function socket_addrinfo_bind($addr) /** - * Create a Socket resource, and connect it to the provided AddrInfo resource. The return + * Create a Socket instance, and connect it to the provided AddressInfo instance. The return * value of this function may be used with the rest of the socket functions. * - * @param resource $addr Resource created from socket_addrinfo_lookup - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup + * @return resource|null Returns a Socket instance on success. * @throws SocketsException * */ -function socket_addrinfo_connect($addr) +function socket_addrinfo_connect($address) { error_clear_last(); - $result = \socket_addrinfo_connect($addr); - if ($result === null) { + $result = \socket_addrinfo_connect($address); + if ($result === false) { + throw SocketsException::createFromPhpError(); + } + return $result; +} + + +/** + * Lookup different ways we can connect to host. The returned array contains + * a set of AddressInfo instances that we can bind to using socket_addrinfo_bind. + * + * @param string $host Hostname to search. + * @param mixed $service The service to connect to. If service is a name, it is translated to the corresponding + * port number. + * @param array $hints Hints provide criteria for selecting addresses returned. You may specify the + * hints as defined by getadrinfo. + * @return resource[] Returns an array of AddressInfo instances that can be used with the other socket_addrinfo functions. + * On failure, FALSE is returned. + * @throws SocketsException + * + */ +function socket_addrinfo_lookup(string $host, $service = null, array $hints = []): iterable +{ + error_clear_last(); + if ($hints !== []) { + $result = \socket_addrinfo_lookup($host, $service, $hints); + } elseif ($service !== null) { + $result = \socket_addrinfo_lookup($host, $service); + } else { + $result = \socket_addrinfo_lookup($host); + } + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -91,7 +122,7 @@ function socket_addrinfo_connect($addr) * a connection is be established using socket_connect * or socket_listen. * - * @param resource $socket A valid socket resource created with socket_create. + * @param resource $socket A Socket instance created with socket_create. * @param string $address If the socket is of the AF_INET family, the * address is an IP in dotted-quad notation * (e.g. 127.0.0.1). @@ -116,9 +147,9 @@ function socket_bind($socket, string $address, int $port = 0): void /** - * Initiate a connection to address using the socket resource - * socket, which must be a valid socket - * resource created with socket_create. + * Initiate a connection to address using the Socket instance + * socket, which must be Socket + * instance created with socket_create. * * @param resource $socket * @param string $address The address parameter is either an IPv4 address @@ -135,10 +166,14 @@ function socket_bind($socket, string $address, int $port = 0): void * @throws SocketsException * */ -function socket_connect($socket, string $address, int $port = 0): void +function socket_connect($socket, string $address, int $port = null): void { error_clear_last(); - $result = \socket_connect($socket, $address, $port); + if ($port !== null) { + $result = \socket_connect($socket, $address, $port); + } else { + $result = \socket_connect($socket, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -146,7 +181,7 @@ function socket_connect($socket, string $address, int $port = 0): void /** - * socket_create_listen creates a new socket resource of + * socket_create_listen creates a new Socket instance of * type AF_INET listening on all * local interfaces on the given port waiting for new connections. * @@ -159,7 +194,7 @@ function socket_connect($socket, string $address, int $port = 0): void * SOMAXCONN may be passed as * backlog parameter, see * socket_listen for more information. - * @return resource socket_create_listen returns a new socket resource + * @return resource socket_create_listen returns a new Socket instance * on success. The error code can be retrieved with * socket_last_error. This code may be passed to * socket_strerror to get a textual explanation of the @@ -180,7 +215,7 @@ function socket_create_listen(int $port, int $backlog = 128) /** * socket_create_pair creates two connected and - * indistinguishable sockets, and stores them in fd. + * indistinguishable sockets, and stores them in pair. * This function is commonly used in IPC (InterProcess Communication). * * @param int $domain The domain parameter specifies the protocol @@ -199,14 +234,14 @@ function socket_create_listen(int $port, int $backlog = 128) * * See socket_create for the full list of supported * protocols. - * @param resource[]|null $fd Reference to an array in which the two socket resources will be inserted. + * @param resource[]|null $pair Reference to an array in which the two Socket instances will be inserted. * @throws SocketsException * */ -function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$fd): void +function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$pair): void { error_clear_last(); - $result = \socket_create_pair($domain, $type, $protocol, $fd); + $result = \socket_create_pair($domain, $type, $protocol, $pair); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -214,7 +249,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f /** - * Creates and returns a socket resource, also referred to as an endpoint + * Creates and returns a Socket instance, also referred to as an endpoint * of communication. A typical network connection is made up of 2 sockets, one * performing the role of the client, and another performing the role of the server. * @@ -229,7 +264,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f * the desired protocol is TCP, or UDP the corresponding constants * SOL_TCP, and SOL_UDP * can also be used. - * @return resource socket_create returns a socket resource on success. The actual error code can be retrieved by calling + * @return resource socket_create returns a Socket instance on success. The actual error code can be retrieved by calling * socket_last_error. This error code may be passed to * socket_strerror to get a textual explanation of the * error. @@ -268,10 +303,10 @@ function socket_export_stream($socket) /** * The socket_get_option function retrieves the value for - * the option specified by the optname parameter for the + * the option specified by the option parameter for the * specified socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $level The level parameter specifies the protocol * level at which the option resides. For example, to retrieve options at @@ -280,7 +315,7 @@ function socket_export_stream($socket) * TCP, can be used by * specifying the protocol number of that level. Protocol numbers can be * found by using the getprotobyname function. - * @param int $optname Reports whether the socket lingers on + * @param int $option Reports whether the socket lingers on * socket_close if data is present. By default, * when the socket is closed, it attempts to send all unsent data. * In the case of a connection-oriented socket, @@ -302,10 +337,10 @@ function socket_export_stream($socket) * @throws SocketsException * */ -function socket_get_option($socket, int $level, int $optname) +function socket_get_option($socket, int $level, int $option) { error_clear_last(); - $result = \socket_get_option($socket, $level, $optname); + $result = \socket_get_option($socket, $level, $option); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -317,7 +352,7 @@ function socket_get_option($socket, int $level, int $optname) * Queries the remote side of the given socket which may either result in * host/port or in a Unix filesystem path, dependent on its type. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param string|null $address If the given socket is of type AF_INET or * AF_INET6, socket_getpeername @@ -349,9 +384,9 @@ function socket_getpeername($socket, ?string &$address, ?int &$port = null): voi /** * * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string|null $addr If the given socket is of type AF_INET + * @param string|null $address If the given socket is of type AF_INET * or AF_INET6, socket_getsockname * will return the local IP address in appropriate notation (e.g. * 127.0.0.1 or fe80::1) in the @@ -366,10 +401,10 @@ function socket_getpeername($socket, ?string &$address, ?int &$port = null): voi * @throws SocketsException * */ -function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void +function socket_getsockname($socket, ?string &$address, ?int &$port = null): void { error_clear_last(); - $result = \socket_getsockname($socket, $addr, $port); + $result = \socket_getsockname($socket, $address, $port); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -380,7 +415,7 @@ function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void * Imports a stream that encapsulates a socket into a socket extension resource. * * @param resource $stream The stream resource to import. - * @return resource|false Returns FALSE. + * @return resource Returns FALSE on failure. * @throws SocketsException * */ @@ -388,7 +423,7 @@ function socket_import_stream($stream) { error_clear_last(); $result = \socket_import_stream($stream); - if ($result === null) { + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -405,7 +440,7 @@ function socket_import_stream($stream) * type SOCK_STREAM or * SOCK_SEQPACKET. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_addrinfo_bind * @param int $backlog A maximum of backlog incoming connections will be * queued for processing. If a connection request arrives with the queue @@ -434,19 +469,19 @@ function socket_listen($socket, int $backlog = 0): void /** - * The function socket_read reads from the socket - * resource socket created by the + * The function socket_read reads from the Socket instance + * socket created by the * socket_create or * socket_accept functions. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $length The maximum number of bytes read is specified by the * length parameter. Otherwise you can use * \r, \n, - * or \0 to end reading (depending on the type + * or \0 to end reading (depending on the mode * parameter, see below). - * @param int $type Optional type parameter is a named constant: + * @param int $mode Optional mode parameter is a named constant: * * * @@ -469,10 +504,10 @@ function socket_listen($socket, int $backlog = 0): void * @throws SocketsException * */ -function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string +function socket_read($socket, int $length, int $mode = PHP_BINARY_READ): string { error_clear_last(); - $result = \socket_read($socket, $length, $type); + $result = \socket_read($socket, $length, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -482,14 +517,14 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string /** * The function socket_send sends - * len bytes to the socket - * socket from buf. + * length bytes to the socket + * socket from data. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string $buf A buffer containing the data that will be sent to the remote host. - * @param int $len The number of bytes that will be sent to the remote host from - * buf. + * @param string $data A buffer containing the data that will be sent to the remote host. + * @param int $length The number of bytes that will be sent to the remote host from + * data. * @param int $flags The value of flags can be any combination of * the following flags, joined with the binary OR (|) * operator. @@ -530,10 +565,10 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string * @throws SocketsException * */ -function socket_send($socket, string $buf, int $len, int $flags): int +function socket_send($socket, string $data, int $length, int $flags): int { error_clear_last(); - $result = \socket_send($socket, $buf, $len, $flags); + $result = \socket_send($socket, $data, $length, $flags); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -564,13 +599,13 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int /** * The function socket_sendto sends - * len bytes from buf + * length bytes from data * through the socket socket to the - * port at the address addr. + * port at the address address. * - * @param resource $socket A valid socket resource created using socket_create. - * @param string $buf The sent data will be taken from buffer buf. - * @param int $len len bytes from buf will be + * @param resource $socket A Socket instance created using socket_create. + * @param string $data The sent data will be taken from buffer data. + * @param int $length length bytes from data will be * sent. * @param int $flags The value of flags can be any combination of * the following flags, joined with the binary OR (|) @@ -608,7 +643,7 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * * * - * @param string $addr IP address of the remote host. + * @param string $address IP address of the remote host. * @param int $port port is the remote port number at which the data * will be sent. * @return int socket_sendto returns the number of bytes sent to the @@ -616,10 +651,14 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * @throws SocketsException * */ -function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, int $port = 0): int +function socket_sendto($socket, string $data, int $length, int $flags, string $address, int $port = null): int { error_clear_last(); - $result = \socket_sendto($socket, $buf, $len, $flags, $addr, $port); + if ($port !== null) { + $result = \socket_sendto($socket, $data, $length, $flags, $address, $port); + } else { + $result = \socket_sendto($socket, $data, $length, $flags, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -636,7 +675,7 @@ function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, * a blocking socket, the script will pause its execution until it receives * a signal or it can perform the operation. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -661,7 +700,7 @@ function socket_set_block($socket): void * signal or it can perform the operation. Rather, if the operation would result * in a block, the called function will fail. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -678,12 +717,12 @@ function socket_set_nonblock($socket): void /** * The socket_set_option function sets the option - * specified by the optname parameter, at the + * specified by the option parameter, at the * specified protocol level, to the value pointed to - * by the optval parameter for the + * by the value parameter for the * socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $level The level parameter specifies the protocol * level at which the option resides. For example, to retrieve options at @@ -692,16 +731,16 @@ function socket_set_nonblock($socket): void * TCP, can be used by specifying the protocol number of that level. * Protocol numbers can be found by using the * getprotobyname function. - * @param int $optname The available socket options are the same as those for the + * @param int $option The available socket options are the same as those for the * socket_get_option function. - * @param int|string|array $optval The option value. + * @param int|string|array $value The option value. * @throws SocketsException * */ -function socket_set_option($socket, int $level, int $optname, $optval): void +function socket_set_option($socket, int $level, int $option, $value): void { error_clear_last(); - $result = \socket_set_option($socket, $level, $optname, $optval); + $result = \socket_set_option($socket, $level, $option, $value); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -713,10 +752,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * incoming, outgoing or all data (the default) from being sent through the * socket * - * @param resource $socket A valid socket resource created with socket_create. - * @param int $how The value of how can be one of the following: + * @param resource $socket A Socket instance created with socket_create. + * @param int $mode The value of mode can be one of the following: * - * possible values for how + * possible values for mode * * * @@ -743,10 +782,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * @throws SocketsException * */ -function socket_shutdown($socket, int $how = 2): void +function socket_shutdown($socket, int $mode = 2): void { error_clear_last(); - $result = \socket_shutdown($socket, $how); + $result = \socket_shutdown($socket, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -756,18 +795,18 @@ function socket_shutdown($socket, int $how = 2): void /** * Exports the WSAPROTOCOL_INFO structure into shared memory and returns * an identifier to be used with socket_wsaprotocol_info_import. The - * exported ID is only valid for the given target_pid. + * exported ID is only valid for the given process_id. * - * @param resource $socket A valid socket resource. - * @param int $target_pid The ID of the process which will import the socket. + * @param resource $socket A Socket instance. + * @param int $process_id The ID of the process which will import the socket. * @return string Returns an identifier to be used for the import * @throws SocketsException * */ -function socket_wsaprotocol_info_export($socket, int $target_pid): string +function socket_wsaprotocol_info_export($socket, int $process_id): string { error_clear_last(); - $result = \socket_wsaprotocol_info_export($socket, $target_pid); + $result = \socket_wsaprotocol_info_export($socket, $process_id); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -780,7 +819,7 @@ function socket_wsaprotocol_info_export($socket, int $target_pid): string * * @param string $info_id The ID which has been returned by a former call to * socket_wsaprotocol_info_export. - * @return resource Returns the socket resource + * @return resource Returns a Socket instance on success * @throws SocketsException * */ diff --git a/generated/ssh2.php b/generated/ssh2.php index 96af9df3..01f23600 100644 --- a/generated/ssh2.php +++ b/generated/ssh2.php @@ -380,6 +380,53 @@ function ssh2_exec($session, string $command, string $pty = null, array $env = n } +/** + * Accepts a connection created by a listener. + * + * @param resource $listener An SSH2 Listener resource, obtained from a call to ssh2_forward_listen. + * @return Returns a stream resource. + * @throws Ssh2Exception + * + */ +function ssh2_forward_accept($listener) +{ + error_clear_last(); + $result = \ssh2_forward_accept($listener); + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} + + +/** + * Binds a port on the remote server and listen for connections. + * + * @param resource $session An SSH Session resource, obtained from a call to ssh2_connect. + * @param int $port The port of the remote server. + * @param string $host + * @param int $max_connections + * @return Returns an SSH2 Listener. + * @throws Ssh2Exception + * + */ +function ssh2_forward_listen($session, int $port, string $host = null, int $max_connections = 16) +{ + error_clear_last(); + if ($max_connections !== 16) { + $result = \ssh2_forward_listen($session, $port, $host, $max_connections); + } elseif ($host !== null) { + $result = \ssh2_forward_listen($session, $port, $host); + } else { + $result = \ssh2_forward_listen($session, $port); + } + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} + + /** * * diff --git a/generated/zip.php b/generated/zip.php index 8fd22bb9..d4097eb1 100644 --- a/generated/zip.php +++ b/generated/zip.php @@ -21,10 +21,87 @@ function zip_entry_close($zip_entry): void } +/** + * Returns the compressed size of the specified directory entry. + * + * @param resource $zip_entry A directory entry returned by zip_read. + * @return int The compressed size. + * @throws ZipException + * + */ +function zip_entry_compressedsize($zip_entry): int +{ + error_clear_last(); + $result = \zip_entry_compressedsize($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns the compression method of the directory entry specified + * by zip_entry. + * + * @param resource $zip_entry A directory entry returned by zip_read. + * @return string The compression method. + * @throws ZipException + * + */ +function zip_entry_compressionmethod($zip_entry): string +{ + error_clear_last(); + $result = \zip_entry_compressionmethod($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns the actual size of the specified directory entry. + * + * @param resource $zip_entry A directory entry returned by zip_read. + * @return int The size of the directory entry. + * @throws ZipException + * + */ +function zip_entry_filesize($zip_entry): int +{ + error_clear_last(); + $result = \zip_entry_filesize($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns the name of the specified directory entry. + * + * @param resource $zip_entry A directory entry returned by zip_read. + * @return string The name of the directory entry. + * @throws ZipException + * + */ +function zip_entry_name($zip_entry): string +{ + error_clear_last(); + $result = \zip_entry_name($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + /** * Opens a directory entry in a zip file for reading. * - * @param resource $zip A valid resource handle returned by zip_open. + * @param resource $zip_dp A valid resource handle returned by zip_open. * @param resource $zip_entry A directory entry returned by zip_read. * @param string $mode Any of the modes specified in the documentation of * fopen. @@ -35,14 +112,10 @@ function zip_entry_close($zip_entry): void * @throws ZipException * */ -function zip_entry_open($zip, $zip_entry, string $mode = null): void +function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void { error_clear_last(); - if ($mode !== null) { - $result = \zip_entry_open($zip, $zip_entry, $mode); - } else { - $result = \zip_entry_open($zip, $zip_entry); - } + $result = \zip_entry_open($zip_dp, $zip_entry, $mode); if ($result === false) { throw ZipException::createFromPhpError(); } @@ -53,17 +126,17 @@ function zip_entry_open($zip, $zip_entry, string $mode = null): void * Reads from an open directory entry. * * @param resource $zip_entry A directory entry returned by zip_read. - * @param int $length The number of bytes to return. + * @param int $len The number of bytes to return. * * This should be the uncompressed length you wish to read. * @return string Returns the data read, empty string on end of a file. * @throws ZipException * */ -function zip_entry_read($zip_entry, int $length = 1024): string +function zip_entry_read($zip_entry, int $len = 1024): string { error_clear_last(); - $result = \zip_entry_read($zip_entry, $length); + $result = \zip_entry_read($zip_entry, $len); if ($result === false) { throw ZipException::createFromPhpError(); } diff --git a/generated/zlib.php b/generated/zlib.php index ef813816..f261ba88 100644 --- a/generated/zlib.php +++ b/generated/zlib.php @@ -302,10 +302,14 @@ function gzfile(string $filename, int $use_include_path = 0): array * @throws ZlibException * */ -function gzgets($stream, int $length = 1024): string +function gzgets($stream, int $length = null): string { error_clear_last(); - $result = \gzgets($stream, $length); + if ($length !== null) { + $result = \gzgets($stream, $length); + } else { + $result = \gzgets($stream); + } if ($result === false) { throw ZlibException::createFromPhpError(); } diff --git a/generator/composer.json b/generator/composer.json index 08a90956..40ad548a 100644 --- a/generator/composer.json +++ b/generator/composer.json @@ -16,10 +16,10 @@ }, "require-dev": { "phpunit/phpunit": "^8.5.2", - "phpstan/phpstan": "^0.12", "thecodingmachine/phpstan-strict-rules": "^0.12", "squizlabs/php_codesniffer": "^3.2", - "php-coveralls/php-coveralls": "^2.1" + "php-coveralls/php-coveralls": "^2.1", + "phpstan/phpstan": "^0.12.68" }, "scripts": { "phpstan": "phpstan analyse src -c phpstan.neon --level=max --no-progress -vvv", diff --git a/generator/composer.lock b/generator/composer.lock index de89582c..914f222a 100644 --- a/generator/composer.lock +++ b/generator/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e04789907a5cccb0f12c0af583c48e7", + "content-hash": "431ecbdfbe4c78368c53a8ca1f05d845", "packages": [ { "name": "psr/container", @@ -1153,21 +1153,23 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.2", + "version": "0.12.68", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "15a2c2b7d4195aa712506e14763ef7646ac6a08c" + "reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/15a2c2b7d4195aa712506e14763ef7646ac6a08c", - "reference": "15a2c2b7d4195aa712506e14763ef7646ac6a08c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ddbe01af0706ee094c3f1ce9730b35aebb508d3d", + "reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d", "shasum": "" }, "require": { - "nikic/php-parser": "^4.3.0", - "php": "^7.1" + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" }, "bin": [ "phpstan", @@ -1189,7 +1191,21 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2019-12-09T09:13:49+00:00" + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-01-18T12:29:17+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1441,6 +1457,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2019-09-17T06:23:10+00:00" }, { diff --git a/generator/src/Parameter.php b/generator/src/Parameter.php index 6fc0944c..d7f87587 100644 --- a/generator/src/Parameter.php +++ b/generator/src/Parameter.php @@ -21,7 +21,7 @@ public function __construct(\SimpleXMLElement $parameter, ?PhpStanFunction $phpS $this->parameter = $parameter; $phpStanParam = $phpStanFunction ? $phpStanFunction->getParameter($this->getParameter(), $position) : null; - $this->type = $phpStanParam ? $phpStanParam->getType() : new PhpStanType($this->parameter->type->__toString()); + $this->type = $phpStanParam ? $phpStanParam->getType() : new PhpStanType($this->parameter->type->__toString()); //todo: is this if useful? } /** diff --git a/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php b/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php index 1a3d8432..f87ec549 100644 --- a/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php +++ b/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php @@ -6,11 +6,8 @@ */ return [ - 'libxml_get_last_error' => ['LibXMLError|false'], //LibXMLError need to be uppercase - 'gmp_random_seed' => ['void', 'seed'=>'GMP|string|int'], //gmp_random_seed doesn't return - 'imageconvolution' => ['bool', 'src_im'=>'resource', 'matrix3x3'=>'array', 'div'=>'float', 'offset'=>'float'], //imageconvolution return a bool - 'iptcembed' => ['string|bool', 'iptcdata'=>'string', 'jpeg_file_name'=>'string', 'spool='=>'int'], //iptcembed return either a string, true or false 'password_hash' => ['string|false', 'password'=>'string', 'algo'=>'int|string|null', 'options='=>'array'], 'com_load_typelib' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'bool'], // case_insensitive is a bool 'sem_get' => ['resource|false', 'key'=>'int', 'max_acquire='=>'int', 'perm='=>'int', 'auto_release='=>'bool'], // auto_release is a bool + 'imap_open' => ['resource|false', 'mailbox'=>'string', 'user'=>'string', 'password'=>'string', 'flags='=>'int', 'retries='=>'int', 'options=' => 'array'], //the last 3 parameters were renamed ]; diff --git a/generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php b/generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php index ac36580b..71e1cb51 100644 --- a/generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php +++ b/generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php @@ -16,7 +16,7 @@ class PhpStanFunctionMapReader public function __construct() { - $this->functionMap = require 'phar://'.__DIR__.'/../../vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/functionMap.php'; + $this->functionMap = require 'phar://'.__DIR__.'/../../vendor/phpstan/phpstan/phpstan.phar/resources/functionMap.php'; $this->customFunctionMap = require __DIR__.'/CustomPhpStanFunctionMap.php'; } diff --git a/generator/src/PhpStanFunctions/PhpStanParameter.php b/generator/src/PhpStanFunctions/PhpStanParameter.php index 333ca2cd..16deedaf 100644 --- a/generator/src/PhpStanFunctions/PhpStanParameter.php +++ b/generator/src/PhpStanFunctions/PhpStanParameter.php @@ -15,11 +15,6 @@ class PhpStanParameter * @var PhpStanType */ private $type; - /** - * Whether the parameter is "write only" (applies only to "by reference" parameters) - * @var bool - */ - private $writeOnly = false; public function __construct(string $name, string $type) { diff --git a/generator/src/PhpStanFunctions/PhpStanType.php b/generator/src/PhpStanFunctions/PhpStanType.php index 7d199ee8..b6a12dd2 100644 --- a/generator/src/PhpStanFunctions/PhpStanType.php +++ b/generator/src/PhpStanFunctions/PhpStanType.php @@ -32,6 +32,13 @@ class PhpStanType public function __construct(string $data, bool $writeOnly = false) { + //weird case: null|false => null + if ($data === 'null|false') { + $this->nullable = false; + $this->falsable = true; + $this->types = ['null']; + return; + } //first we try to parse the type string to have a list as clean as possible. $nullable = false; $falsable = false; @@ -50,7 +57,9 @@ public function __construct(string $data, bool $writeOnly = false) $falsable = true; \array_splice($returnTypes, (int) $falsablePosition, 1); } - if (\count($returnTypes) === 0) { + /** @var int $count */ + $count = \count($returnTypes); + if ($count === 0) { throw new \RuntimeException('Error when trying to extract parameter type'); } foreach ($returnTypes as &$returnType) { @@ -108,6 +117,8 @@ public function getSignatureType(?int $errorType = null): string $type = 'iterable'; //generics cannot be typehinted and have to be turned into iterable } elseif (\strpos($type, 'resource') !== false) { $type = ''; // resource cant be typehinted + } elseif (\strpos($type, 'null') !== false) { + $type = ''; // null is a real typehint } } diff --git a/generator/src/Scanner.php b/generator/src/Scanner.php index 7b7b4bbe..25a9903e 100644 --- a/generator/src/Scanner.php +++ b/generator/src/Scanner.php @@ -91,14 +91,8 @@ public function getMethods(array $paths): array $phpStanFunctionMapReader = new PhpStanFunctionMapReader(); $ignoredFunctions = $this->getIgnoredFunctions(); $ignoredFunctions = \array_combine($ignoredFunctions, $ignoredFunctions); - if ($ignoredFunctions === false) { - throw new \RuntimeException('Failed when combining arrays'); - } $ignoredModules = $this->getIgnoredModules(); $ignoredModules = \array_combine($ignoredModules, $ignoredModules); - if ($ignoredModules === false) { - throw new \RuntimeException('Failed when combining arrays'); - } foreach ($paths as $path) { $module = \basename(\dirname($path, 2)); if (isset($ignoredModules[$module])) { diff --git a/generator/tests/MethodTest.php b/generator/tests/MethodTest.php index 831ad85b..11d06c86 100644 --- a/generator/tests/MethodTest.php +++ b/generator/tests/MethodTest.php @@ -71,14 +71,17 @@ public function testGetTypeHintFromRessource() $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), Method::FALSY_TYPE); $params = $method->getParams(); $this->assertEquals('\HashContext', $params[0]->getDocBlockType()); - $this->assertEquals('\HashContext', $params[0]->getSignatureType()); - + $this->assertEquals('\HashContext', $params[0]->getSignatureType()); + } + + public function testImapOpen5Parameter() + { $docPage = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/imap/functions/imap-open.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), Method::FALSY_TYPE); $params = $method->getParams(); - $this->assertEquals('array|null', $params[5]->getDocBlockType()); - $this->assertEquals('?array', $params[5]->getSignatureType()); + $this->assertEquals('array', $params[5]->getDocBlockType()); + $this->assertEquals('array', $params[5]->getSignatureType()); } public function testGetInitializer() diff --git a/generator/tests/PhpStanFunctions/PhpStanTypeTest.php b/generator/tests/PhpStanFunctions/PhpStanTypeTest.php index cb2644f8..06bb8200 100644 --- a/generator/tests/PhpStanFunctions/PhpStanTypeTest.php +++ b/generator/tests/PhpStanFunctions/PhpStanTypeTest.php @@ -142,4 +142,11 @@ public function testDuplicateType(): void $this->assertEquals('array', $param->getSignatureType()); } + public function testNullOrFalseBecomingNull(): void + { + $param = new PhpStanType('null|false'); + $this->assertEquals('null', $param->getDocBlockType(Method::FALSY_TYPE)); + $this->assertEquals('', $param->getSignatureType(Method::FALSY_TYPE)); + } + } \ No newline at end of file diff --git a/rector-migrate-0.7.php b/rector-migrate-0.7.php index e93ac1b3..de1a89d9 100644 --- a/rector-migrate-0.7.php +++ b/rector-migrate-0.7.php @@ -183,6 +183,7 @@ 'ftp_login' => 'Safe\ftp_login', 'ftp_mkdir' => 'Safe\ftp_mkdir', 'ftp_mlsd' => 'Safe\ftp_mlsd', + 'ftp_nb_put' => 'Safe\ftp_nb_put', 'ftp_nlist' => 'Safe\ftp_nlist', 'ftp_pasv' => 'Safe\ftp_pasv', 'ftp_put' => 'Safe\ftp_put', @@ -351,29 +352,48 @@ 'imagewebp' => 'Safe\imagewebp', 'imagexbm' => 'Safe\imagexbm', 'image_type_to_extension' => 'Safe\image_type_to_extension', + 'imap_8bit' => 'Safe\imap_8bit', 'imap_append' => 'Safe\imap_append', + 'imap_base64' => 'Safe\imap_base64', + 'imap_binary' => 'Safe\imap_binary', + 'imap_body' => 'Safe\imap_body', + 'imap_bodystruct' => 'Safe\imap_bodystruct', 'imap_check' => 'Safe\imap_check', 'imap_clearflag_full' => 'Safe\imap_clearflag_full', 'imap_close' => 'Safe\imap_close', 'imap_createmailbox' => 'Safe\imap_createmailbox', 'imap_deletemailbox' => 'Safe\imap_deletemailbox', + 'imap_fetchbody' => 'Safe\imap_fetchbody', + 'imap_fetchheader' => 'Safe\imap_fetchheader', + 'imap_fetchmime' => 'Safe\imap_fetchmime', 'imap_fetchstructure' => 'Safe\imap_fetchstructure', + 'imap_fetch_overview' => 'Safe\imap_fetch_overview', 'imap_gc' => 'Safe\imap_gc', + 'imap_getacl' => 'Safe\imap_getacl', + 'imap_getmailboxes' => 'Safe\imap_getmailboxes', + 'imap_getsubscribed' => 'Safe\imap_getsubscribed', 'imap_headerinfo' => 'Safe\imap_headerinfo', + 'imap_headers' => 'Safe\imap_headers', + 'imap_listscan' => 'Safe\imap_listscan', + 'imap_lsub' => 'Safe\imap_lsub', 'imap_mail' => 'Safe\imap_mail', 'imap_mailboxmsginfo' => 'Safe\imap_mailboxmsginfo', 'imap_mail_compose' => 'Safe\imap_mail_compose', 'imap_mail_copy' => 'Safe\imap_mail_copy', 'imap_mail_move' => 'Safe\imap_mail_move', + 'imap_mime_header_decode' => 'Safe\imap_mime_header_decode', 'imap_mutf7_to_utf8' => 'Safe\imap_mutf7_to_utf8', 'imap_num_msg' => 'Safe\imap_num_msg', 'imap_open' => 'Safe\imap_open', + 'imap_qprint' => 'Safe\imap_qprint', 'imap_renamemailbox' => 'Safe\imap_renamemailbox', + 'imap_rfc822_write_address' => 'Safe\imap_rfc822_write_address', 'imap_savebody' => 'Safe\imap_savebody', 'imap_setacl' => 'Safe\imap_setacl', 'imap_setflag_full' => 'Safe\imap_setflag_full', 'imap_set_quota' => 'Safe\imap_set_quota', 'imap_sort' => 'Safe\imap_sort', + 'imap_status' => 'Safe\imap_status', 'imap_subscribe' => 'Safe\imap_subscribe', 'imap_thread' => 'Safe\imap_thread', 'imap_timeout' => 'Safe\imap_timeout', @@ -454,7 +474,6 @@ 'ldap_set_option' => 'Safe\ldap_set_option', 'ldap_unbind' => 'Safe\ldap_unbind', 'libxml_get_last_error' => 'Safe\libxml_get_last_error', - 'libxml_set_external_entity_loader' => 'Safe\libxml_set_external_entity_loader', 'link' => 'Safe\link', 'long2ip' => 'Safe\long2ip', 'lstat' => 'Safe\lstat', @@ -617,6 +636,11 @@ 'opendir' => 'Safe\opendir', 'openlog' => 'Safe\openlog', 'openssl_cipher_iv_length' => 'Safe\openssl_cipher_iv_length', + 'openssl_cms_decrypt' => 'Safe\openssl_cms_decrypt', + 'openssl_cms_encrypt' => 'Safe\openssl_cms_encrypt', + 'openssl_cms_read' => 'Safe\openssl_cms_read', + 'openssl_cms_sign' => 'Safe\openssl_cms_sign', + 'openssl_cms_verify' => 'Safe\openssl_cms_verify', 'openssl_csr_export' => 'Safe\openssl_csr_export', 'openssl_csr_export_to_file' => 'Safe\openssl_csr_export_to_file', 'openssl_csr_get_subject' => 'Safe\openssl_csr_get_subject', @@ -723,8 +747,14 @@ 'php_sapi_name' => 'Safe\php_sapi_name', 'png2wbmp' => 'Safe\png2wbmp', 'posix_access' => 'Safe\posix_access', + 'posix_getgrgid' => 'Safe\posix_getgrgid', 'posix_getgrnam' => 'Safe\posix_getgrnam', + 'posix_getgroups' => 'Safe\posix_getgroups', + 'posix_getlogin' => 'Safe\posix_getlogin', 'posix_getpgid' => 'Safe\posix_getpgid', + 'posix_getpwuid' => 'Safe\posix_getpwuid', + 'posix_getrlimit' => 'Safe\posix_getrlimit', + 'posix_getsid' => 'Safe\posix_getsid', 'posix_initgroups' => 'Safe\posix_initgroups', 'posix_kill' => 'Safe\posix_kill', 'posix_mkfifo' => 'Safe\posix_mkfifo', @@ -735,6 +765,8 @@ 'posix_setpgid' => 'Safe\posix_setpgid', 'posix_setrlimit' => 'Safe\posix_setrlimit', 'posix_setuid' => 'Safe\posix_setuid', + 'posix_times' => 'Safe\posix_times', + 'posix_uname' => 'Safe\posix_uname', 'preg_match' => 'Safe\preg_match', 'preg_match_all' => 'Safe\preg_match_all', 'preg_replace' => 'Safe\preg_replace', @@ -882,6 +914,7 @@ 'socket_accept' => 'Safe\socket_accept', 'socket_addrinfo_bind' => 'Safe\socket_addrinfo_bind', 'socket_addrinfo_connect' => 'Safe\socket_addrinfo_connect', + 'socket_addrinfo_lookup' => 'Safe\socket_addrinfo_lookup', 'socket_bind' => 'Safe\socket_bind', 'socket_connect' => 'Safe\socket_connect', 'socket_create' => 'Safe\socket_create', @@ -935,6 +968,8 @@ 'ssh2_connect' => 'Safe\ssh2_connect', 'ssh2_disconnect' => 'Safe\ssh2_disconnect', 'ssh2_exec' => 'Safe\ssh2_exec', + 'ssh2_forward_accept' => 'Safe\ssh2_forward_accept', + 'ssh2_forward_listen' => 'Safe\ssh2_forward_listen', 'ssh2_publickey_add' => 'Safe\ssh2_publickey_add', 'ssh2_publickey_init' => 'Safe\ssh2_publickey_init', 'ssh2_publickey_remove' => 'Safe\ssh2_publickey_remove', @@ -1023,6 +1058,10 @@ 'yaz_search' => 'Safe\yaz_search', 'yaz_wait' => 'Safe\yaz_wait', 'zip_entry_close' => 'Safe\zip_entry_close', + 'zip_entry_compressedsize' => 'Safe\zip_entry_compressedsize', + 'zip_entry_compressionmethod' => 'Safe\zip_entry_compressionmethod', + 'zip_entry_filesize' => 'Safe\zip_entry_filesize', + 'zip_entry_name' => 'Safe\zip_entry_name', 'zip_entry_open' => 'Safe\zip_entry_open', 'zip_entry_read' => 'Safe\zip_entry_read', 'zlib_decode' => 'Safe\zlib_decode',