8000 [Process] Allow non-blocking start with PhpProcess · loicfrering/symfony@2cd43da · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cd43da

Browse files
krichprollschfabpot
authored andcommitted
[Process] Allow non-blocking start with PhpProcess
1 parent ab64da5 commit 2cd43da

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/Symfony/Component/Process/PhpProcess.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,9 @@ public function setPhpBinary($php)
5555
}
5656

5757
/**
58-
* Runs the process.
59-
*
60-
* @param Closure|string|array $callback A PHP callback to run whenever there is some
61-
* output available on STDOUT or STDERR
62-
*
63-
* @return integer The exit status code
64-
*
65-
* @api
58+
* {@inheritdoc}
6659
*/
67-
public function run($callback = null)
60+
public function start($callback = null)
6861
{
6962
if (null === $this->getCommandLine()) {
7063
if (false === $php = $this->executableFinder->find()) {
@@ -73,6 +66,6 @@ public function run($callback = null)
7366
$this->setCommandLine($php);
7467
}
7568

76-
return parent::run($callback);
69+
return parent::start($callback);
7770
}
7871
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Symfony\Component\Process\Tests;
4+
5+
use Symfony\Component\Process\PhpProcess;
6+
7+
class PhpProcessTest extends \PHPUnit_Framework_TestCase
8+
{
9+
10+
public function testNonBlockingWorks()
11+
{
12+
$expected = 'hello world!';
13+
$process = new PhpProcess(<<<PHP
14+
<?php echo '$expected';
15+
PHP
16+
);
17+
$process->start();
18+
$process->wait();
19+
$this->assertEquals($expected, $process->getOutput());
20+
}
21+
}

0 commit comments

Comments
 (0)
0