Skip to content

Commit 99efd4d

Browse files
author
Bernd Hoehl
committed
no need to do for just optional parameters
1 parent 17b4dc5 commit 99efd4d

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

src/AspectMock/Intercept/FunctionInjector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function placeOptionalAndReferenceFunction($namespace, $function)
8686
$names[] = $name;
8787
$parameters[$newname] = $declaration;
8888
}
89-
if ($optionals || $byRef) {
89+
if ($byRef) {
9090
$this->template = $this->templateByRefOptional;
9191
$this->place('arguments', join(', ', $parameters));
9292
$code = '';

tests/unit/FunctionInjectorTest.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,8 @@ public function _before()
3131
public function testTemplate()
3232
{
3333
$php = $this->funcInjector->getPHP();
34-
if ((int)ini_get('mbstring.func_overload') & 2 !== 0) {
35-
// in this case strlen is overloaded by mb_strlen with optional parameter charset
36-
verify($php)->contains("function strlen(\$p0, \$p1=NULL)");
37-
verify($php)->contains("case 2: \$args = [\$p0, \$p1]; break;");
38-
verify($php)->contains("case 1: \$args = [\$p0]; break;");
39-
verify($php)->contains("return call_user_func_array('strlen', \$args);");
40-
} else {
41-
verify($php)->contains("function strlen()");
42-
verify($php)->contains("return call_user_func_array('strlen', func_get_args());");
43-
}
44-
}
45-
46-
public function testOptionalParameterTemplate()
47-
{
48-
$php = $this->funcOptionalParameterInjector->getPHP();
49-
verify($php)->contains("function explode(\$p0, \$p1, \$p2=NULL)");
50-
verify($php)->contains("case 3: \$args = [\$p0, \$p1, \$p2]; break;");
51-
verify($php)->contains("case 2: \$args = [\$p0, \$p1]; break;");
52-
verify($php)->contains("case 1: \$args = [\$p0]; break;");
53-
verify($php)->contains("return call_user_func_array('explode', \$args);");
34+
verify($php)->contains("function strlen()");
35+
verify($php)->contains("return call_user_func_array('strlen', func_get_args());");
5436
}
5537

5638
public function testReferencedParameterTemplate()

0 commit comments

Comments
 (0)