From 535b74839445d166f3ae20539326319a790342a0 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 9 Dec 2024 04:31:27 +0900 Subject: [PATCH] Add test for RayAOP void return handling. This test ensures that the interception works correctly with methods that have no explicit return statement and those with an empty return. It validates that the interceptor processes both void and empty return methods as expected, returning null in each case. --- tests/010-rayaop-void-return.phpt | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/010-rayaop-void-return.phpt diff --git a/tests/010-rayaop-void-return.phpt b/tests/010-rayaop-void-return.phpt new file mode 100644 index 0000000..19c3798 --- /dev/null +++ b/tests/010-rayaop-void-return.phpt @@ -0,0 +1,52 @@ +--TEST-- +RayAOP void return handling test +--FILE-- +$method(...$params); + echo "After void method\n"; + return $result; + } +} + +class TestClass { + public function voidMethod() { + echo "Executing void method\n"; + // 明示的なreturnなし + } + + public function emptyReturnMethod() { + echo "Executing empty return method\n"; + return; // 明示的な空return + } +} + +method_intercept_init(); +method_intercept(TestClass::class, 'voidMethod', new VoidTestInterceptor()); +method_intercept(TestClass::class, 'emptyReturnMethod', new VoidTestInterceptor()); +method_intercept_enable(true); + +$test = new TestClass(); + +echo "Testing void method:\n"; +$result = $test->voidMethod(); +var_dump($result); + +echo "\nTesting empty return method:\n"; +$result = $test->emptyReturnMethod(); +var_dump($result); + +--EXPECT-- +Testing void method: +Before void method +Executing void method +After void method +NULL + +Testing empty return method: +Before void method +Executing empty return method +After void method +NULL \ No newline at end of file