Skip to content

Commit bf91dd7

Browse files
committed
PhpInterpreter changed to immutable object
1 parent 2c65e44 commit bf91dd7

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/Runner/PhpInterpreter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ public function __construct($path, array $args = [])
8585
/**
8686
* @param string
8787
* @param string
88+
* @return static
8889
*/
89-
public function addPhpIniOption($name, $value = null)
90+
public function withPhpIniOption($name, $value = null)
9091
{
91-
$this->commandLine .= ' -d ' . Helpers::escapeArg($name . ($value === null ? '' : "=$value"));
92+
$me = clone $this;
93+
$me->commandLine .= ' -d ' . Helpers::escapeArg($name . ($value === null ? '' : "=$value"));
94+
return $me;
9295
}
9396

9497

src/Runner/TestHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(Runner $runner)
3737
public function initiate($file)
3838
{
3939
list($annotations, $title) = $this->getAnnotations($file);
40-
$php = clone $this->runner->getInterpreter();
40+
$php = $this->runner->getInterpreter();
4141

4242
$tests = [new Test($file, $title)];
4343
foreach (get_class_methods($this) as $method) {
@@ -128,10 +128,10 @@ private function initiatePhpExtension(Test $test, $value, PhpInterpreter $interp
128128
}
129129

130130

131-
private function initiatePhpIni(Test $test, $pair, PhpInterpreter $interpreter)
131+
private function initiatePhpIni(Test $test, $pair, PhpInterpreter &$interpreter)
132132
{
133133
list($name, $value) = explode('=', $pair, 2) + [1 => null];
134-
$interpreter->addPhpIniOption($name, $value);
134+
$interpreter = $interpreter->withPhpIniOption($name, $value);
135135
}
136136

137137

tests/Runner/Runner.multiple-fails.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class Logger implements Tester\Runner\OutputHandler
3838
}
3939
}
4040

41-
$interpreter = createInterpreter();
42-
$interpreter->addPhpIniOption('display_errors', 'on');
43-
$interpreter->addPhpIniOption('html_errors', 'off');
41+
$interpreter = createInterpreter()
42+
->withPhpIniOption('display_errors', 'on')
43+
->withPhpIniOption('html_errors', 'off');
4444

4545
$runner = new Runner($interpreter);
4646
$runner->paths[] = __DIR__ . '/multiple-fails/*.phptx';

0 commit comments

Comments
 (0)