From 3de22a84e85ddeb43f9f3321056845b0f82e7907 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 5 Jan 2025 01:10:21 +0000 Subject: [PATCH] ext/spl: Add trampoline test for iterator_apply() --- .../spl_iterator_apply_with_trampoline.phpt | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ext/spl/tests/spl_iterator_apply_with_trampoline.phpt diff --git a/ext/spl/tests/spl_iterator_apply_with_trampoline.phpt b/ext/spl/tests/spl_iterator_apply_with_trampoline.phpt new file mode 100644 index 00000000000..7247506b85b --- /dev/null +++ b/ext/spl/tests/spl_iterator_apply_with_trampoline.phpt @@ -0,0 +1,48 @@ +--TEST-- +SPL: iterator_apply() with a trampoline +--FILE-- +getMessage(), PHP_EOL; +} +try { + iterator_apply($it, $callbackThrow); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + iterator_apply($it, $callback, 'not an array'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +Trampoline for trampoline +array(0) { +} +int(1) +Trampoline for trampolineThrow +array(0) { +} +Exception: boo +TypeError: iterator_apply(): Argument #3 ($args) must be of type ?array, string given