Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 152b250

Browse files
authored
Merge pull request #489 from VolCh/symfony4
Allow Symfony4 components
2 parents f6102e3 + a19477c commit 152b250

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"forum": "https://www.facebook.com/groups/phpwebdriver/",
1111
"source": "https://github.com/facebook/php-webdriver"
1212
},
13+
"minimum-stability": "beta",
1314
"require": {
1415
"php": "^5.6 || ~7.0",
15-
"symfony/process": "^2.8 || ^3.1",
16+
"symfony/process": "^2.8 || ^3.1 || ^4.0",
1617
"ext-curl": "*",
1718
"ext-zip": "*"
1819
},
@@ -24,7 +25,7 @@
2425
"php-mock/php-mock-phpunit": "^1.1",
2526
"php-coveralls/php-coveralls": "^1.0.2",
2627
"guzzle/guzzle": "^3.4.1",
27-
"symfony/var-dumper": "^3.3"
28+
"symfony/var-dumper": "^3.3 || ^4.0"
2829
},
2930
"autoload": {
3031
"psr-4": {

lib/Remote/Service/DriverService.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,7 @@ public function start()
8181
return $this;
8282
}
8383

84-
$processBuilder = (new ProcessBuilder())
85-
->setPrefix($this->executable)
86-
->setArguments($this->args)
87-
->addEnvironmentVariables($this->environment);
88-
89-
$this->process = $processBuilder->getProcess();
84+
$this->process = $this->createProcess();
9085
$this->process->start();
9186

9287
$checker = new URLChecker();
@@ -144,4 +139,26 @@ protected static function checkExecutable($executable)
144139

145140
return $executable;
146141
}
142+
143+
/**
144+
* @return Process
145+
*/
146+
private function createProcess()
147+
{
148+
// BC: ProcessBuilder deprecated since Symfony 3.4 and removed in Symfony 4.0.
149+
if (class_exists(ProcessBuilder::class)
150+
&& false === mb_strpos('@deprecated', (new \ReflectionClass(ProcessBuilder::class))->getDocComment())
151+
) {
152+
$processBuilder = (new ProcessBuilder())
153+
->setPrefix($this->executable)
154+
->setArguments($this->args)
155+
->addEnvironmentVariables($this->environment);
156+
157+
return $processBuilder->getProcess();
158+
}
159+
// Safe to use since Symfony 3.3
160+
$commandLine = array_merge([$this->executable], $this->args);
161+
162+
return new Process($commandLine, null, $this->environment);
163+
}
147164
}

0 commit comments

Comments
 (0)