Skip to content

Commit 17b4dc5

Browse files
author
Bernd Hoehl
committed
only add optional =NULL, if not internal function
1 parent 6800516 commit 17b4dc5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/AspectMock/Intercept/FunctionInjector.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function __construct($namespace, $function)
4646
$this->place('func', $this->function);
4747
}
4848

49-
public function getParameterDeclaration(\ReflectionParameter $parameter)
49+
public function getParameterDeclaration(\ReflectionParameter $parameter, $internal)
5050
{
5151
$text = (string)$parameter;
5252
if (preg_match('@Parameter\s#[0-9]+\s\[\s<(required|optional)>(.*)(\sor NULL)(.*)\s\]@', $text, $match)) {
@@ -56,7 +56,7 @@ public function getParameterDeclaration(\ReflectionParameter $parameter)
5656
} else {
5757
throw new \Exception('reflection api changed. adjust code.');
5858
}
59-
if ($parameter->isOptional()) {
59+
if ($internal && $parameter->isOptional()) {
6060
$text .= "=NULL";
6161
}
6262
return $text;
@@ -70,10 +70,11 @@ public function placeOptionalAndReferenceFunction($namespace, $function)
7070
$byRef = false;
7171
$optionals = false;
7272
$names = [];
73+
$internal = $reflect->isInternal();
7374
foreach ($reflect->getParameters() as $parameter) {
7475
$name = '$'.$parameter->getName();
7576
$newname = '$p'.$parameter->getPosition();
76-
$declaration = str_replace($name, $newname, $this->getParameterDeclaration($parameter));
77+
$declaration = str_replace($name, $newname, $this->getParameterDeclaration($parameter, $internal));
7778
$name = $newname;
7879
if (!$optionals && $parameter->isOptional()) {
7980
$optionals = true;

0 commit comments

Comments
 (0)