[Process] added some constant to avoid harcoded strings

This commit is contained in:
Fabien Potencier 2012-02-05 12:11:37 +01:00
parent 766b88fd21
commit c2e8a0a24a

View File

@ -21,6 +21,9 @@ namespace Symfony\Component\Process;
*/ */
class Process class Process
{ {
const ERR = 'err';
const OUT = 'out';
private $commandline; private $commandline;
private $cwd; private $cwd;
private $env; private $env;
@ -93,7 +96,7 @@ class Process
$that = $this; $that = $this;
$callback = function ($type, $data) use ($that, $callback) $callback = function ($type, $data) use ($that, $callback)
{ {
if ('out' == $type) { if (self::OUT == $type) {
$that->addOutput($data); $that->addOutput($data);
} else { } else {
$that->addErrorOutput($data); $that->addErrorOutput($data);
@ -156,7 +159,7 @@ class Process
$type = array_search($pipe, $pipes); $type = array_search($pipe, $pipes);
$data = fread($pipe, 8192); $data = fread($pipe, 8192);
if (strlen($data) > 0) { if (strlen($data) > 0) {
call_user_func($callback, $type == 1 ? 'out' : 'err', $data); call_user_func($callback, $type == 1 ? self::OUT : self::ERR, $data);
} }
if (false === $data || feof($pipe)) { if (false === $data || feof($pipe)) {
fclose($pipe); fclose($pipe);