[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
1 changed files with 5 additions and 2 deletions

View File

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