From 68ab665ca5e12d19094a4482e23910d27164453b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 13 May 2025 20:16:45 +0200 Subject: [PATCH] Fix `passthru()` on PHP 8.1 --- generated/8.1/functionsList.php | 1 + generated/8.1/rector-migrate.php | 1 + generated/8.2/exec.php | 29 ----------------------------- generated/8.3/exec.php | 29 ----------------------------- generated/8.4/exec.php | 29 ----------------------------- generated/8.5/exec.php | 29 ----------------------------- lib/special_cases.php | 29 +++++++++++++++++++++++++++++ 7 files changed, 31 insertions(+), 116 deletions(-) diff --git a/generated/8.1/functionsList.php b/generated/8.1/functionsList.php index fe521b5e..3b13b9c2 100644 --- a/generated/8.1/functionsList.php +++ b/generated/8.1/functionsList.php @@ -698,6 +698,7 @@ 'parse_ini_file', 'parse_ini_string', 'parse_url', + 'passthru', 'pclose', 'pcntl_getpriority', 'pcntl_setpriority', diff --git a/generated/8.1/rector-migrate.php b/generated/8.1/rector-migrate.php index cd06ea5f..eeacdaac 100644 --- a/generated/8.1/rector-migrate.php +++ b/generated/8.1/rector-migrate.php @@ -706,6 +706,7 @@ 'parse_ini_file' => 'Safe\parse_ini_file', 'parse_ini_string' => 'Safe\parse_ini_string', 'parse_url' => 'Safe\parse_url', + 'passthru' => 'Safe\passthru', 'pclose' => 'Safe\pclose', 'pcntl_getpriority' => 'Safe\pcntl_getpriority', 'pcntl_setpriority' => 'Safe\pcntl_setpriority', diff --git a/generated/8.2/exec.php b/generated/8.2/exec.php index 7cbb1bce..7e35d71b 100644 --- a/generated/8.2/exec.php +++ b/generated/8.2/exec.php @@ -43,35 +43,6 @@ 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(); - $safeResult = \passthru($command, $result_code); - if ($safeResult === false) { - throw ExecException::createFromPhpError(); - } -} - - /** * proc_close is similar to pclose * except that it only works on processes opened by diff --git a/generated/8.3/exec.php b/generated/8.3/exec.php index 7cbb1bce..7e35d71b 100644 --- a/generated/8.3/exec.php +++ b/generated/8.3/exec.php @@ -43,35 +43,6 @@ 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(); - $safeResult = \passthru($command, $result_code); - if ($safeResult === false) { - throw ExecException::createFromPhpError(); - } -} - - /** * proc_close is similar to pclose * except that it only works on processes opened by diff --git a/generated/8.4/exec.php b/generated/8.4/exec.php index 7cbb1bce..7e35d71b 100644 --- a/generated/8.4/exec.php +++ b/generated/8.4/exec.php @@ -43,35 +43,6 @@ 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(); - $safeResult = \passthru($command, $result_code); - if ($safeResult === false) { - throw ExecException::createFromPhpError(); - } -} - - /** * proc_close is similar to pclose * except that it only works on processes opened by diff --git a/generated/8.5/exec.php b/generated/8.5/exec.php index 7cbb1bce..7e35d71b 100644 --- a/generated/8.5/exec.php +++ b/generated/8.5/exec.php @@ -43,35 +43,6 @@ 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(); - $safeResult = \passthru($command, $result_code); - if ($safeResult === false) { - throw ExecException::createFromPhpError(); - } -} - - /** * proc_close is similar to pclose * except that it only works on processes opened by diff --git a/lib/special_cases.php b/lib/special_cases.php index a324166d..c5a9fb4f 100644 --- a/lib/special_cases.php +++ b/lib/special_cases.php @@ -17,6 +17,7 @@ use Safe\Exceptions\PcreException; use Safe\Exceptions\SimplexmlException; use Safe\Exceptions\FilesystemException; +use Safe\Exceptions\ExecException; use const PREG_NO_ERROR; @@ -399,3 +400,31 @@ function fgetcsv($stream, ?int $length = null, string $separator = ",", string $ } return $safeResult; } + +/** + * 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(); + $safeResult = \passthru($command, $result_code); + if ($safeResult === false) { + throw ExecException::createFromPhpError(); + } +}