File tree 2 files changed +3
-8
lines changed
src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator
tests/ProxyManagerTest/Functional
2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change 7
7
use Laminas \Code \Reflection \MethodReflection ;
8
8
use ProxyManager \Generator \MethodGenerator ;
9
9
use ProxyManager \Generator \Util \IdentifierSuffixer ;
10
- use ReflectionNamedType ;
11
10
12
11
/**
13
12
* Method decorator for null objects
@@ -19,14 +18,10 @@ class NullObjectMethodInterceptor extends MethodGenerator
19
18
*/
20
19
public static function generateMethod (MethodReflection $ originalMethod ): self
21
20
{
22
- $ method = static ::fromReflectionWithoutBodyAndDocBlock ($ originalMethod );
23
- $ originalReturnType = $ originalMethod ->getReturnType ();
21
+ $ method = static ::fromReflectionWithoutBodyAndDocBlock ($ originalMethod );
24
22
25
- if ($ originalReturnType instanceof ReflectionNamedType && $ originalReturnType ->getName () === 'never ' ) {
26
- $ method ->setBody ('throw new \Exception(); ' );
27
- } elseif ($ originalMethod ->returnsReference ()) {
23
+ if ($ originalMethod ->returnsReference ()) {
28
24
$ reference = IdentifierSuffixer::getIdentifier ('ref ' );
29
-
30
25
$ method ->setBody ("\$reference = null; \nreturn \$" . $ reference . '; ' );
31
26
}
32
27
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public function testNeverReturningMethodCalls(): void
145
145
self ::assertIsCallable ($ method );
146
146
147
147
$ this ->expectException (Throwable::class);
148
- $ this ->expectExceptionMessage ('' );
148
+ $ this ->expectExceptionMessage ('never-returning function must not implicitly return ' );
149
149
$ method (random_int (10 , 1000 ));
150
150
}
151
151
You can’t perform that action at this time.
0 commit comments