Loading core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php +6 −1 Original line number Diff line number Diff line Loading @@ -300,8 +300,13 @@ protected function buildMethodBody(\ReflectionMethod $reflection_method) { $function_name = $reflection_method->getName(); if (!$reflection_method->isStatic()) { if ($reflection_method->getReturnType() && $reflection_method->getReturnType()->getName() === 'void') { $output .= ' $this->lazyLoadItself()->' . $function_name . '('; } else { $output .= ' return $this->lazyLoadItself()->' . $function_name . '('; } } else { $class_name = $reflection_method->getDeclaringClass()->getName(); $output .= " \\$class_name::$function_name("; Loading core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +32 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,30 @@ public function complexMethod(string $parameter, callable $function, \Drupal\Tes return $this->lazyLoadItself()->complexMethod($parameter, $function, $test_service, $elements); } EOS; $this->assertEquals($this->buildExpectedClass($class, $method_body), $result); } /** * @covers ::buildMethodBody */ public function testBuildServiceMethodReturnsVoid() { $class = TestServiceMethodReturnsVoid::class; $result = $this->proxyBuilder->build($class); // @todo Solve the silly linebreak for array() $method_body = <<<'EOS' /** * {@inheritdoc} */ public function methodReturnsVoid(string $parameter): void { $this->lazyLoadItself()->methodReturnsVoid($parameter); } EOS; $this->assertEquals($this->buildExpectedClass($class, $method_body), $result); Loading Loading @@ -387,6 +411,14 @@ public function complexMethod(string $parameter, callable $function, TestService } class TestServiceMethodReturnsVoid { public function methodReturnsVoid(string $parameter): void { } } class TestServiceReturnReference { public function &returnReference() { Loading Loading
core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php +6 −1 Original line number Diff line number Diff line Loading @@ -300,8 +300,13 @@ protected function buildMethodBody(\ReflectionMethod $reflection_method) { $function_name = $reflection_method->getName(); if (!$reflection_method->isStatic()) { if ($reflection_method->getReturnType() && $reflection_method->getReturnType()->getName() === 'void') { $output .= ' $this->lazyLoadItself()->' . $function_name . '('; } else { $output .= ' return $this->lazyLoadItself()->' . $function_name . '('; } } else { $class_name = $reflection_method->getDeclaringClass()->getName(); $output .= " \\$class_name::$function_name("; Loading
core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +32 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,30 @@ public function complexMethod(string $parameter, callable $function, \Drupal\Tes return $this->lazyLoadItself()->complexMethod($parameter, $function, $test_service, $elements); } EOS; $this->assertEquals($this->buildExpectedClass($class, $method_body), $result); } /** * @covers ::buildMethodBody */ public function testBuildServiceMethodReturnsVoid() { $class = TestServiceMethodReturnsVoid::class; $result = $this->proxyBuilder->build($class); // @todo Solve the silly linebreak for array() $method_body = <<<'EOS' /** * {@inheritdoc} */ public function methodReturnsVoid(string $parameter): void { $this->lazyLoadItself()->methodReturnsVoid($parameter); } EOS; $this->assertEquals($this->buildExpectedClass($class, $method_body), $result); Loading Loading @@ -387,6 +411,14 @@ public function complexMethod(string $parameter, callable $function, TestService } class TestServiceMethodReturnsVoid { public function methodReturnsVoid(string $parameter): void { } } class TestServiceReturnReference { public function &returnReference() { Loading