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 . ';'); }