From 90601cf681a07bed51eeb13634e27509276b5af6 Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Tue, 3 May 2022 10:46:02 +0200 Subject: [PATCH] remove unneeded generated code for never returning methods --- .../MethodGenerator/NullObjectMethodInterceptor.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php b/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php index 08baed4c..ead15318 100644 --- a/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php +++ b/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php @@ -19,14 +19,10 @@ class NullObjectMethodInterceptor extends MethodGenerator */ public static function generateMethod(MethodReflection $originalMethod): self { - $method = static::fromReflectionWithoutBodyAndDocBlock($originalMethod); - $originalReturnType = $originalMethod->getReturnType(); + $method = static::fromReflectionWithoutBodyAndDocBlock($originalMethod); - if ($originalReturnType instanceof ReflectionNamedType && $originalReturnType->getName() === 'never') { - $method->setBody('throw new \Exception();'); - } elseif ($originalMethod->returnsReference()) { + if ($originalMethod->returnsReference()) { $reference = IdentifierSuffixer::getIdentifier('ref'); - $method->setBody("\$reference = null;\nreturn \$" . $reference . ';'); }