-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathStandardSymfonyProcessFactory.php
More file actions
52 lines (45 loc) · 1.33 KB
/
StandardSymfonyProcessFactory.php
File metadata and controls
52 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* This file is part of the Webmozarts Console Parallelization package.
*
* (c) Webmozarts GmbH <office@webmozarts.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Webmozarts\Console\Parallelization\Process;
use Symfony\Component\Process\InputStream;
use Symfony\Component\Process\PhpSubprocess;
use Symfony\Component\Process\Process;
final class StandardSymfonyProcessFactory implements SymfonyProcessFactory
{
public function startProcess(
int $index,
InputStream $inputStream,
array $phpExecutable,
array $command,
string $workingDirectory,
?array $environmentVariables,
callable $processOutput
): Process {
$process = new PhpSubprocess(
$command,
$workingDirectory,
$environmentVariables,
php: $phpExecutable,
);
$process->setInput($inputStream);
// @codeCoverageIgnoreStart
$process->start(
static fn (string $type, string $buffer) => $processOutput(
$index,
$process->getPid(),
$type,
$buffer,
),
);
// @codeCoverageIgnoreEnd
return $process;
}
}