From 0cf5feaa7cdb988181b526d59c40f51f2f5ee2ec Mon Sep 17 00:00:00 2001 From: Demin Yin Date: Thu, 29 Mar 2018 15:58:53 -0700 Subject: [PATCH 1/4] fix "PHP Catchable fatal error: Method MrRio\ShellWrap::__toString() must return a string value" --- src/MrRio/ShellWrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MrRio/ShellWrap.php b/src/MrRio/ShellWrap.php index 8ba4fff..eecf873 100644 --- a/src/MrRio/ShellWrap.php +++ b/src/MrRio/ShellWrap.php @@ -25,7 +25,7 @@ class ShellWrap static public $exceptionOnError = true; - private static $output = array(); + private static $output = ''; private static $prepend = array(); private static $stdin = null; From 738b5772d38177b0d95428f5a38db304630ca804 Mon Sep 17 00:00:00 2001 From: Demin Yin Date: Fri, 15 Jun 2018 12:31:38 -0700 Subject: [PATCH 2/4] specify current working directory explicitly when executing shell commands --- src/MrRio/ShellWrap.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MrRio/ShellWrap.php b/src/MrRio/ShellWrap.php index eecf873..b63bf4c 100644 --- a/src/MrRio/ShellWrap.php +++ b/src/MrRio/ShellWrap.php @@ -134,7 +134,13 @@ private static function __run($arguments) 2 => array('pipe', 'w') // Stderr ); - $process = proc_open($shell, $descriptor_spec, $pipes); + // If you use function chdir() to change working directory to a different directory first, following two + // statements should still return same directories. However, in Travis CI they return different directories back + // (the 2nd one returns the directory where the PHP script was invoked). + // 1. getcwd() + // 2. (string) ShellWrap::pwd() + // Thus we have the 4th parameter (getcwd()) specified explicitly here, also ideally it's unnecessary. + $process = proc_open($shell, $descriptor_spec, $pipes, getcwd()); if (is_resource($process)) { From 71bf0dde77326f47c9c5118b0126b322250eb823 Mon Sep 17 00:00:00 2001 From: Demin Yin Date: Thu, 28 Jun 2018 21:34:41 -0700 Subject: [PATCH 3/4] change package name to avoid the Github rate limit issue --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a2a226b..d23163b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "mrrio/shellwrap", + "name": "deminy/shellwrap", "type": "library", "description": "Use any command-line tool as a PHP function.", "keywords": ["command", "shell", "api", "command-line", "exec"], From eec6ec6f714bd2faaccde4fb3b0f70a1d7c9d308 Mon Sep 17 00:00:00 2001 From: Demin Yin Date: Fri, 4 Nov 2022 15:32:38 -0700 Subject: [PATCH 4/4] fix deprecation warning in PHP 8.1 The warning message looks like this: PHP Deprecated: fwrite(): Passing null to parameter #2 ($data) of type string is deprecated ... --- src/MrRio/ShellWrap.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MrRio/ShellWrap.php b/src/MrRio/ShellWrap.php index b63bf4c..a509b44 100644 --- a/src/MrRio/ShellWrap.php +++ b/src/MrRio/ShellWrap.php @@ -144,7 +144,9 @@ private static function __run($arguments) if (is_resource($process)) { - fwrite($pipes[0], self::$stdin); + if (isset(self::$stdin)) { + fwrite($pipes[0], self::$stdin); + } fclose($pipes[0]); $output = '';