[Process] fixed usage of constants in closure

This commit is contained in:
Fabien Potencier 2012-02-06 07:00:39 +01:00
parent 7581c3b221
commit 1bef14a02a
1 changed files with 5 additions and 3 deletions

View File

@ -94,9 +94,11 @@ class Process
$this->stdout = '';
$this->stderr = '';
$that = $this;
$callback = function ($type, $data) use ($that, $callback)
$out = self::OUT;
$err = self::ERR;
$callback = function ($type, $data) use ($that, $callback, $out, $err)
{
if (self::OUT == $type) {
if ($out == $type) {
$that->addOutput($data);
} else {
$that->addErrorOutput($data);
@ -159,7 +161,7 @@ class Process
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
if (strlen($data) > 0) {
call_user_func($callback, $type == 1 ? self::OUT : self::ERR, $data);
call_user_func($callback, $type == 1 ? $out : $err, $data);
}
if (false === $data || feof($pipe)) {
fclose($pipe);