diff --git a/generated/exec.php b/generated/exec.php index 83121e7d..c4dd4911 100644 --- a/generated/exec.php +++ b/generated/exec.php @@ -43,6 +43,35 @@ function exec(string $command, ?array &$output = null, ?int &$result_code = null } +/** + * The passthru function is similar to the + * exec function in that it executes a + * command. This function + * should be used in place of exec or + * system when the output from the Unix command + * is binary data which needs to be passed directly back to the + * browser. A common use for this is to execute something like the + * pbmplus utilities that can output an image stream directly. By + * setting the Content-type to image/gif and + * then calling a pbmplus program to output a gif, you can create + * PHP scripts that output images directly. + * + * @param string $command The command that will be executed. + * @param int|null $result_code If the result_code argument is present, the + * return status of the Unix command will be placed here. + * @throws ExecException + * + */ +function passthru(string $command, ?int &$result_code = null): void +{ + error_clear_last(); + $result = \passthru($command, $result_code); + if ($result === false) { + throw ExecException::createFromPhpError(); + } +} + + /** * proc_nice changes the priority of the current * process by the amount specified in priority. A diff --git a/generated/filesystem.php b/generated/filesystem.php index 33891f83..833719b6 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -235,7 +235,7 @@ function fflush($stream): void * @param resource $stream A valid file pointer to a file successfully opened by * fopen, popen, or * fsockopen. - * @param \0|int $length Must be greater than the longest line (in characters) to be found in + * @param int $length Must be greater than the longest line (in characters) to be found in * the CSV file (allowing for trailing line-end characters). Otherwise the * line is split in chunks of length characters, * unless the split would occur inside an enclosure. @@ -251,7 +251,7 @@ function fflush($stream): void * @throws FilesystemException * */ -function fgetcsv($stream, $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\") +function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\") { error_clear_last(); if ($escape !== "\\") { @@ -299,14 +299,14 @@ function fgetcsv($stream, $length = null, string $separator = ",", string $enclo * Seeking (offset) is not supported with remote files. * Attempting to seek on non-local files may work with small offsets, but this * is unpredictable because it works on the buffered stream. - * @param \0|int $length Maximum length of data read. The default is to read until end + * @param int $length Maximum length of data read. The default is to read until end * of file is reached. Note that this parameter is applied to the * stream processed by the filters. * @return string The function returns the read data. * @throws FilesystemException * */ -function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, $length = null): string +function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string { error_clear_last(); if ($length !== null) { @@ -395,11 +395,11 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co * * @param resource|null $context A valid context resource created with * stream_context_create. - * @return \0|int This function returns the number of bytes that were written to the file. + * @return int This function returns the number of bytes that were written to the file. * @throws FilesystemException * */ -function file_put_contents(string $filename, $data, int $flags = 0, $context = null) +function file_put_contents(string $filename, $data, int $flags = 0, $context = null): int { error_clear_last(); if ($context !== null) { @@ -613,12 +613,12 @@ function fileperms(string $filename): int * Gets the size for the given file. * * @param string $filename Path to the file. - * @return \0|int Returns the size of the file in bytes, or FALSE (and generates an error + * @return int Returns the size of the file in bytes, or FALSE (and generates an error * of level E_WARNING) in case of an error. * @throws FilesystemException * */ -function filesize(string $filename) +function filesize(string $filename): int { error_clear_last(); $result = \filesize($filename); @@ -929,12 +929,12 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $ * * @param resource $stream A file system pointer resource * that is typically created using fopen. - * @param \0|int $length Up to length number of bytes read. + * @param int $length Up to length number of bytes read. * @return string Returns the read string. * @throws FilesystemException * */ -function fread($stream, $length): string +function fread($stream, int $length): string { error_clear_last(); $result = \fread($stream, $length); @@ -998,7 +998,7 @@ function fsync($stream): void * @param resource $stream The file pointer. * * The stream must be open for writing. - * @param \0|int $size The size to truncate to. + * @param int $size The size to truncate to. * * If size is larger than the file then the file * is extended with null bytes. @@ -1008,7 +1008,7 @@ function fsync($stream): void * @throws FilesystemException * */ -function ftruncate($stream, $size): void +function ftruncate($stream, int $size): void { error_clear_last(); $result = \ftruncate($stream, $size); @@ -1024,14 +1024,14 @@ function ftruncate($stream, $size): void * @param resource $stream A file system pointer resource * that is typically created using fopen. * @param string $data The string that is to be written. - * @param \0|int $length If length is an integer, writing will stop + * @param int $length If length is an integer, writing will stop * after length bytes have been written or the * end of data is reached, whichever comes first. - * @return \0|int + * @return int * @throws FilesystemException * */ -function fwrite($stream, string $data, $length = null) +function fwrite($stream, string $data, int $length = null): int { error_clear_last(); if ($length !== null) { @@ -1356,11 +1356,11 @@ function parse_ini_string(string $ini_string, bool $process_sections = false, in * you want to search for the file in the include_path, too. * @param resource $context A context stream * resource. - * @return \0|int Returns the number of bytes read from the file on success + * @return int Returns the number of bytes read from the file on success * @throws FilesystemException * */ -function readfile(string $filename, bool $use_include_path = false, $context = null) +function readfile(string $filename, bool $use_include_path = false, $context = null): int { error_clear_last(); if ($context !== null) { diff --git a/generated/functionsList.php b/generated/functionsList.php index f5970b52..bf152651 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -693,6 +693,7 @@ 'parse_ini_file', 'parse_ini_string', 'parse_url', + 'passthru', 'pcntl_getpriority', 'pcntl_setpriority', 'pcntl_signal', diff --git a/generated/openssl.php b/generated/openssl.php index f2ddda34..1c5b875d 100644 --- a/generated/openssl.php +++ b/generated/openssl.php @@ -1353,12 +1353,12 @@ function openssl_spki_verify(string $spki): void * @param int|string $algorithm int - one of these Signature Algorithms. * * string - a valid string returned by openssl_get_md_methods example, "sha1WithRSAEncryption" or "sha512". - * @return \-1|\0|\1 Returns 1 if the signature is correct, 0 if it is incorrect, and + * @return int Returns 1 if the signature is correct, 0 if it is incorrect, and * -1. * @throws OpensslException * */ -function openssl_verify(string $data, string $signature, $public_key, $algorithm = OPENSSL_ALGO_SHA1) +function openssl_verify(string $data, string $signature, $public_key, $algorithm = OPENSSL_ALGO_SHA1): int { error_clear_last(); $result = \openssl_verify($data, $signature, $public_key, $algorithm); diff --git a/generated/pcre.php b/generated/pcre.php index e3ebc582..4ebb9839 100644 --- a/generated/pcre.php +++ b/generated/pcre.php @@ -369,11 +369,11 @@ function preg_grep(string $pattern, array $array, int $flags = 0): array * * * The above example will output: - * @return \0|int|null Returns the number of full pattern matches (which might be zero). + * @return int|null Returns the number of full pattern matches (which might be zero). * @throws PcreException * */ -function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) +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/zlib.php b/generated/zlib.php index 92d198d2..39dc8985 100644 --- a/generated/zlib.php +++ b/generated/zlib.php @@ -686,11 +686,11 @@ function inflate_init(int $encoding, array $options = []) * contents written to standard output. * @param int $use_include_path You can set this optional parameter to 1, if you * want to search for the file in the include_path too. - * @return \0|int Returns the number of (uncompressed) bytes read from the file on success + * @return int Returns the number of (uncompressed) bytes read from the file on success * @throws ZlibException * */ -function readgzfile(string $filename, int $use_include_path = 0) +function readgzfile(string $filename, int $use_include_path = 0): int { error_clear_last(); $result = \readgzfile($filename, $use_include_path); diff --git a/rector-migrate.php b/rector-migrate.php index 45af36a9..33d71034 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -703,6 +703,7 @@ 'parse_ini_file' => 'Safe\parse_ini_file', 'parse_ini_string' => 'Safe\parse_ini_string', 'parse_url' => 'Safe\parse_url', + 'passthru' => 'Safe\passthru', 'pcntl_getpriority' => 'Safe\pcntl_getpriority', 'pcntl_setpriority' => 'Safe\pcntl_setpriority', 'pcntl_signal' => 'Safe\pcntl_signal',