Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magic method __toString() must return a string #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
14 changes: 11 additions & 3 deletions src/MrRio/ShellWrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -134,11 +134,19 @@ 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)) {

fwrite($pipes[0], self::$stdin);
if (isset(self::$stdin)) {
fwrite($pipes[0], self::$stdin);
}
fclose($pipes[0]);

$output = '';
Expand Down