diff --git a/classes/MockDelegateFunction.tpl b/classes/MockDelegateFunction.tpl index 7887e96..180c077 100644 --- a/classes/MockDelegateFunction.tpl +++ b/classes/MockDelegateFunction.tpl @@ -27,7 +27,5 @@ class MockDelegateFunction implements FunctionProvider return [$this, "delegate"]; } - public function {functionName}() - { - } + {function} } diff --git a/classes/MockDelegateFunctionBuilder.php b/classes/MockDelegateFunctionBuilder.php index fa297c8..21c5734 100644 --- a/classes/MockDelegateFunctionBuilder.php +++ b/classes/MockDelegateFunctionBuilder.php @@ -48,17 +48,17 @@ public function __construct() */ public function build($functionName = null) { + $functionNameOrEmptyString = $functionName === null ? '' : $functionName; + $parameterBuilder = new ParameterBuilder(); - $parameterBuilder->build($functionName === null ? '' : $functionName); + $parameterBuilder->build($functionNameOrEmptyString); $signatureParameters = $parameterBuilder->getSignatureParameters(); - $populatedFunctionName = $functionName === null ? '_dummy' : $functionName; - /** * If a class with the same signature exists, it is considered equivalent * to the generated class. */ - $hash = md5($populatedFunctionName . $signatureParameters); + $hash = md5($functionNameOrEmptyString . $signatureParameters); $this->namespace = __NAMESPACE__ . $hash; if (class_exists($this->getFullyQualifiedClassName())) { return; @@ -67,7 +67,7 @@ public function build($functionName = null) $data = [ "namespace" => $this->namespace, "signatureParameters" => $signatureParameters, - "functionName" => $populatedFunctionName, + "function" => $functionName === null ? '' : 'public function ' . $functionName . '() {}', ]; $this->template->setVar($data, false); $definition = $this->template->render();