From e74af4d455a7dd6b03909b36189bf156c8893935 Mon Sep 17 00:00:00 2001 From: Edmond <1571649+EdmondDantes@users.noreply.github.com> Date: Sun, 20 Jul 2025 09:15:20 +0300 Subject: [PATCH] #48: rename CancellationException => CancellationError --- async.stub.php | 2 +- async_arginfo.h | 188 +++++------------- coroutine.c | 12 +- coroutine.stub.php | 4 +- coroutine_arginfo.h | 95 +++------ exceptions.c | 4 +- exceptions.stub.php | 2 +- exceptions_arginfo.h | 33 ++- scope.stub.php | 2 +- scope_arginfo.h | 138 +++++-------- .../await/066-await_cancelled_coroutine.phpt | 8 +- tests/await/068-await_multiple_times.phpt | 6 +- .../069-await_manual_vs_timeout_cancel.phpt | 16 +- tests/await/070-await_state_transitions.phpt | 6 +- ...tAll_with_cancellation_simultaneously.phpt | 2 +- .../coroutine/006-coroutine_cancel_basic.phpt | 8 +- .../028-coroutine_state_transitions.phpt | 2 +- ...coroutine_deferred_cancellation_basic.phpt | 4 +- ...outine_deferred_cancellation_multiple.phpt | 4 +- ...ferred_cancellation_during_protection.phpt | 6 +- ...34-coroutine_cancel_invalid_exception.phpt | 2 +- tests/coroutine/README.md | 2 +- tests/dns/010-dns_cancellation.phpt | 2 +- .../004-scope_provider_exceptions.phpt | 8 +- ...cheduler_graceful_shutdown_exceptions.phpt | 4 +- tests/pdo_mysql/009-pdo_cancellation.phpt | 4 +- .../005-protect_cancellation_immediate.phpt | 2 +- ..._awaitAfterCancellation_error_handler.phpt | 2 +- ...6-scope_cancel_with_active_coroutines.phpt | 6 +- ...28-scope_hierarchy_cancellation_basic.phpt | 2 +- .../029-scope_complex_tree_cancellation.phpt | 4 +- ...pe_inheritance_cancellation_isolation.phpt | 4 +- .../031-scope_concurrent_cancellation.phpt | 6 +- .../032-scope_mixed_cancellation_sources.phpt | 4 +- ...3-scope_cancellation_finally_handlers.phpt | 2 +- .../034-scope_cancellation_double_error.phpt | 2 +- .../008-spawn_cancellation_exception.phpt | 6 +- 37 files changed, 214 insertions(+), 390 deletions(-) diff --git a/async.stub.php b/async.stub.php index ac1c802..36e32e2 100644 --- a/async.stub.php +++ b/async.stub.php @@ -82,7 +82,7 @@ function getCoroutines(): array {} /** * Start the graceful shutdown of the Scheduler. */ -function gracefulShutdown(?CancellationException $cancellationException = null): void {} +function gracefulShutdown(?CancellationError $cancellationError = null): void {} /** * Execute an external program. diff --git a/async_arginfo.h b/async_arginfo.h index fd3ebe1..e764743 100644 --- a/async_arginfo.h +++ b/async_arginfo.h @@ -1,70 +1,70 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d217fc8dbb5aa518add60c4d99d3e7a356fbd41f */ + * Stub hash: aca45cee02a4df47e8e1bc3c2517e6925bd522a9 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_Async_spawn, 0, 1, Async\\Coroutine, 0) -ZEND_ARG_TYPE_INFO(0, task, IS_CALLABLE, 0) -ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, task, IS_CALLABLE, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_Async_spawnWith, 0, 2, Async\\Coroutine, 0) -ZEND_ARG_OBJ_INFO(0, provider, Async\\ScopeProvider, 0) -ZEND_ARG_TYPE_INFO(0, task, IS_CALLABLE, 0) -ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) + ZEND_ARG_OBJ_INFO(0, provider, Async\\ScopeProvider, 0) + ZEND_ARG_TYPE_INFO(0, task, IS_CALLABLE, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_suspend, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_protect, 0, 1, IS_MIXED, 0) -ZEND_ARG_OBJ_INFO(0, closure, Closure, 0) + ZEND_ARG_OBJ_INFO(0, closure, Closure, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_await, 0, 1, IS_MIXED, 0) -ZEND_ARG_OBJ_INFO(0, awaitable, Async\\Awaitable, 0) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_OBJ_INFO(0, awaitable, Async\\Awaitable, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOrFail, 0, 1, IS_MIXED, 0) -ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_END_ARG_INFO() #define arginfo_Async_awaitFirstSuccess arginfo_Async_awaitAnyOrFail ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAllOrFail, 0, 1, IS_ARRAY, 0) -ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") + ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAll, 0, 1, IS_ARRAY, 0) -ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fillNull, _IS_BOOL, 0, "false") + ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fillNull, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOfOrFail, 0, 2, IS_ARRAY, 0) -ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) -ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") + ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_awaitAnyOf, 0, 2, IS_ARRAY, 0) -ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) -ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fillNull, _IS_BOOL, 0, "false") + ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, triggers, Traversable, MAY_BE_ARRAY, NULL) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeyOrder, _IS_BOOL, 0, "true") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fillNull, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_delay, 0, 1, IS_VOID, 0) -ZEND_ARG_TYPE_INFO(0, ms, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, ms, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_Async_timeout, 0, 1, Async\\Awaitable, 0) -ZEND_ARG_TYPE_INFO(0, ms, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, ms, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_Async_currentContext, 0, 0, Async\\Context, 0) @@ -81,7 +81,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_getCoroutines, 0, 0, IS_AR ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Async_gracefulShutdown, 0, 0, IS_VOID, 0) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellationException, Async\\CancellationException, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellationError, Async\\CancellationError, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Async_Timeout___construct, 0, 0, 0) @@ -109,112 +109,32 @@ ZEND_FUNCTION(Async_gracefulShutdown); ZEND_METHOD(Async_Timeout, __construct); static const zend_function_entry ext_functions[] = { - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "spawn"), - zif_Async_spawn, - arginfo_Async_spawn, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "spawnWith"), - zif_Async_spawnWith, - arginfo_Async_spawnWith, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "suspend"), - zif_Async_suspend, - arginfo_Async_suspend, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "protect"), - zif_Async_protect, - arginfo_Async_protect, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "await"), zif_Async_await, arginfo_Async_await, 0, NULL, NULL) - ZEND_RAW_FENTRY( - ZEND_NS_NAME("Async", "awaitAnyOrFail"), - zif_Async_awaitAnyOrFail, - arginfo_Async_awaitAnyOrFail, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitFirstSuccess"), - zif_Async_awaitFirstSuccess, - arginfo_Async_awaitFirstSuccess, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAllOrFail"), - zif_Async_awaitAllOrFail, - arginfo_Async_awaitAllOrFail, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", - "awaitAll"), - zif_Async_awaitAll, - arginfo_Async_awaitAll, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOfOrFail"), - zif_Async_awaitAnyOfOrFail, - arginfo_Async_awaitAnyOfOrFail, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOf"), - zif_Async_awaitAnyOf, - arginfo_Async_awaitAnyOf, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "delay"), - zif_Async_delay, - arginfo_Async_delay, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "timeout"), - zif_Async_timeout, - arginfo_Async_timeout, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "currentContext"), - zif_Async_currentContext, - arginfo_Async_currentContext, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY( - ZEND_NS_NAME("Async", "coroutineContext"), - zif_Async_coroutineContext, - arginfo_Async_coroutineContext, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "currentCoroutine"), - zif_Async_currentCoroutine, - arginfo_Async_currentCoroutine, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "rootContext"), - zif_Async_rootContext, - arginfo_Async_rootContext, - 0, - NULL, - NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", - "getCoroutines"), - zif_Async_getCoroutines, - arginfo_Async_getCoroutines, - 0, - NULL, - NULL) - ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "gracefulShutdown"), - zif_Async_gracefulShutdown, - arginfo_Async_gracefulShutdown, - 0, - NULL, - NULL) ZEND_FE_END + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "spawn"), zif_Async_spawn, arginfo_Async_spawn, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "spawnWith"), zif_Async_spawnWith, arginfo_Async_spawnWith, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "suspend"), zif_Async_suspend, arginfo_Async_suspend, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "protect"), zif_Async_protect, arginfo_Async_protect, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "await"), zif_Async_await, arginfo_Async_await, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOrFail"), zif_Async_awaitAnyOrFail, arginfo_Async_awaitAnyOrFail, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitFirstSuccess"), zif_Async_awaitFirstSuccess, arginfo_Async_awaitFirstSuccess, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAllOrFail"), zif_Async_awaitAllOrFail, arginfo_Async_awaitAllOrFail, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAll"), zif_Async_awaitAll, arginfo_Async_awaitAll, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOfOrFail"), zif_Async_awaitAnyOfOrFail, arginfo_Async_awaitAnyOfOrFail, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "awaitAnyOf"), zif_Async_awaitAnyOf, arginfo_Async_awaitAnyOf, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "delay"), zif_Async_delay, arginfo_Async_delay, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "timeout"), zif_Async_timeout, arginfo_Async_timeout, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "currentContext"), zif_Async_currentContext, arginfo_Async_currentContext, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "coroutineContext"), zif_Async_coroutineContext, arginfo_Async_coroutineContext, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "currentCoroutine"), zif_Async_currentCoroutine, arginfo_Async_currentCoroutine, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "rootContext"), zif_Async_rootContext, arginfo_Async_rootContext, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "getCoroutines"), zif_Async_getCoroutines, arginfo_Async_getCoroutines, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Async", "gracefulShutdown"), zif_Async_gracefulShutdown, arginfo_Async_gracefulShutdown, 0, NULL, NULL) + ZEND_FE_END }; -static const zend_function_entry class_Async_Timeout_methods[] = { ZEND_ME( - Async_Timeout, __construct, arginfo_class_Async_Timeout___construct, ZEND_ACC_PRIVATE) ZEND_FE_END }; +static const zend_function_entry class_Async_Timeout_methods[] = { + ZEND_ME(Async_Timeout, __construct, arginfo_class_Async_Timeout___construct, ZEND_ACC_PRIVATE) + ZEND_FE_END +}; static zend_class_entry *register_class_Async_Awaitable(void) { diff --git a/coroutine.c b/coroutine.c index 722f5cf..f657421 100644 --- a/coroutine.c +++ b/coroutine.c @@ -255,9 +255,11 @@ METHOD(cancel) { zend_object *exception = NULL; + zend_class_entry *ce_cancellation_exception = ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL; - Z_PARAM_OBJ_OF_CLASS_OR_NULL(exception, zend_ce_cancellation_exception) + Z_PARAM_OBJ_OF_CLASS_OR_NULL(exception, ce_cancellation_exception) ZEND_PARSE_PARAMETERS_END(); ZEND_ASYNC_CANCEL(&THIS_COROUTINE->coroutine, exception, false); @@ -566,7 +568,7 @@ void async_coroutine_finalize(zend_fiber_transfer *transfer, async_coroutine_t * // Hold the exception inside coroutine if it is not NULL. if (exception != NULL) { if (coroutine->coroutine.exception != NULL) { - if (false == instanceof_function(exception->ce, zend_ce_cancellation_exception)) { + if (false == instanceof_function(exception->ce, ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION))) { zend_exception_set_previous(exception, coroutine->coroutine.exception); coroutine->coroutine.exception = exception; GC_ADDREF(exception); @@ -611,7 +613,7 @@ void async_coroutine_finalize(zend_fiber_transfer *transfer, async_coroutine_t * // Cancellation-type exceptions are considered handled in all cases and are not propagated further. if (exception != NULL && (ZEND_COROUTINE_IS_EXCEPTION_HANDLED(&coroutine->coroutine) || - instanceof_function(exception->ce, zend_ce_cancellation_exception))) { + instanceof_function(exception->ce, ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION)))) { OBJ_RELEASE(exception); exception = NULL; } @@ -968,7 +970,7 @@ void async_coroutine_resume(zend_coroutine_t *coroutine, zend_object *error, con if (error != NULL) { if (coroutine->waker->error != NULL) { - if (false == instanceof_function(error->ce, zend_ce_cancellation_exception)) { + if (false == instanceof_function(error->ce, ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION))) { zend_exception_set_previous(error, coroutine->waker->error); coroutine->waker->error = error; @@ -1123,7 +1125,7 @@ void async_coroutine_cancel(zend_coroutine_t *zend_coroutine, } if (was_cancelled && waker->error != NULL && - instanceof_function(waker->error->ce, zend_ce_cancellation_exception)) { + instanceof_function(waker->error->ce, ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION))) { if (transfer_error) { OBJ_RELEASE(error); } diff --git a/coroutine.stub.php b/coroutine.stub.php index b816de0..1893dfa 100644 --- a/coroutine.stub.php +++ b/coroutine.stub.php @@ -34,7 +34,7 @@ public function getResult(): mixed {} /** * Returns the Coroutine exception when finished. * If the Coroutine is not finished, it will return null. - * If the Coroutine is cancelled, it will return a CancellationException. + * If the Coroutine is cancelled, it will return a CancellationError. * * @throws \RuntimeException if the Coroutine is running */ @@ -105,7 +105,7 @@ public function getAwaitingInfo(): array {} /** * Cancel the coroutine. */ - public function cancel(?\CancellationException $cancellationException = null): void {} + public function cancel(?CancellationError $CancellationError = null): void {} /** * Define a callback to be executed when the coroutine is finished. diff --git a/coroutine_arginfo.h b/coroutine_arginfo.h index 9c477c3..e741424 100644 --- a/coroutine_arginfo.h +++ b/coroutine_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bee063ddc53348cc4a6ad23b9fc3415acc6d86f2 */ + * Stub hash: 866a851c4d87feafd6585532d622426dc453710f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Coroutine_getId, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -45,11 +45,11 @@ ZEND_END_ARG_INFO() #define arginfo_class_Async_Coroutine_getAwaitingInfo arginfo_class_Async_Coroutine_getTrace ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Coroutine_cancel, 0, 0, IS_VOID, 0) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellationException, CancellationException, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, CancellationError, Async\\CancellationError, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Coroutine_onFinally, 0, 1, IS_VOID, 0) -ZEND_ARG_OBJ_INFO(0, callback, Closure, 0) + ZEND_ARG_OBJ_INFO(0, callback, Closure, 0) ZEND_END_ARG_INFO() ZEND_METHOD(Async_Coroutine, getId); @@ -74,71 +74,27 @@ ZEND_METHOD(Async_Coroutine, cancel); ZEND_METHOD(Async_Coroutine, onFinally); static const zend_function_entry class_Async_Coroutine_methods[] = { - ZEND_ME(Async_Coroutine, getId, arginfo_class_Async_Coroutine_getId, ZEND_ACC_PUBLIC) ZEND_ME( - Async_Coroutine, - asHiPriority, - arginfo_class_Async_Coroutine_asHiPriority, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - getContext, - arginfo_class_Async_Coroutine_getContext, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - getResult, - arginfo_class_Async_Coroutine_getResult, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, getException, arginfo_class_Async_Coroutine_getException, ZEND_ACC_PUBLIC) ZEND_ME( - Async_Coroutine, - getTrace, - arginfo_class_Async_Coroutine_getTrace, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - getSpawnFileAndLine, - arginfo_class_Async_Coroutine_getSpawnFileAndLine, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - getSpawnLocation, - arginfo_class_Async_Coroutine_getSpawnLocation, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - getSuspendFileAndLine, - arginfo_class_Async_Coroutine_getSuspendFileAndLine, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - getSuspendLocation, - arginfo_class_Async_Coroutine_getSuspendLocation, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - isStarted, - arginfo_class_Async_Coroutine_isStarted, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - isQueued, - arginfo_class_Async_Coroutine_isQueued, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - isRunning, - arginfo_class_Async_Coroutine_isRunning, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - isSuspended, - arginfo_class_Async_Coroutine_isSuspended, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - isCancelled, - arginfo_class_Async_Coroutine_isCancelled, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - isCancellationRequested, - arginfo_class_Async_Coroutine_isCancellationRequested, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Coroutine, - isFinished, - arginfo_class_Async_Coroutine_isFinished, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - getAwaitingInfo, - arginfo_class_Async_Coroutine_getAwaitingInfo, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - cancel, - arginfo_class_Async_Coroutine_cancel, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Coroutine, - onFinally, - arginfo_class_Async_Coroutine_onFinally, - ZEND_ACC_PUBLIC) ZEND_FE_END + ZEND_ME(Async_Coroutine, getId, arginfo_class_Async_Coroutine_getId, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, asHiPriority, arginfo_class_Async_Coroutine_asHiPriority, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getContext, arginfo_class_Async_Coroutine_getContext, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getResult, arginfo_class_Async_Coroutine_getResult, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getException, arginfo_class_Async_Coroutine_getException, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getTrace, arginfo_class_Async_Coroutine_getTrace, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getSpawnFileAndLine, arginfo_class_Async_Coroutine_getSpawnFileAndLine, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getSpawnLocation, arginfo_class_Async_Coroutine_getSpawnLocation, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getSuspendFileAndLine, arginfo_class_Async_Coroutine_getSuspendFileAndLine, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getSuspendLocation, arginfo_class_Async_Coroutine_getSuspendLocation, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isStarted, arginfo_class_Async_Coroutine_isStarted, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isQueued, arginfo_class_Async_Coroutine_isQueued, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isRunning, arginfo_class_Async_Coroutine_isRunning, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isSuspended, arginfo_class_Async_Coroutine_isSuspended, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isCancelled, arginfo_class_Async_Coroutine_isCancelled, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isCancellationRequested, arginfo_class_Async_Coroutine_isCancellationRequested, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, isFinished, arginfo_class_Async_Coroutine_isFinished, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, getAwaitingInfo, arginfo_class_Async_Coroutine_getAwaitingInfo, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, cancel, arginfo_class_Async_Coroutine_cancel, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Coroutine, onFinally, arginfo_class_Async_Coroutine_onFinally, ZEND_ACC_PUBLIC) + ZEND_FE_END }; static zend_class_entry *register_class_Async_Coroutine(zend_class_entry *class_entry_Async_Awaitable) @@ -146,8 +102,7 @@ static zend_class_entry *register_class_Async_Coroutine(zend_class_entry *class_ zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "Async", "Coroutine", class_Async_Coroutine_methods); - class_entry = zend_register_internal_class_with_flags( - &ce, NULL, ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES | ZEND_ACC_NOT_SERIALIZABLE); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE); zend_class_implements(class_entry, 1, class_entry_Async_Awaitable); return class_entry; diff --git a/exceptions.c b/exceptions.c index 4093263..9db0108 100644 --- a/exceptions.c +++ b/exceptions.c @@ -61,7 +61,7 @@ PHP_METHOD(Async_CompositeException, getExceptions) void async_register_exceptions_ce(void) { async_ce_async_exception = register_class_Async_AsyncException(zend_ce_exception); - async_ce_cancellation_exception = register_class_Async_CancellationException(zend_ce_cancellation_exception); + async_ce_cancellation_exception = register_class_Async_CancellationError(zend_ce_error); async_ce_input_output_exception = register_class_Async_InputOutputException(zend_ce_exception); async_ce_timeout_exception = register_class_Async_TimeoutException(zend_ce_exception); async_ce_poll_exception = register_class_Async_PollException(zend_ce_exception); @@ -308,7 +308,7 @@ void async_apply_exception(zend_object **to_exception) { if (UNEXPECTED(EG(exception) && false == - (instanceof_function(EG(exception)->ce, zend_ce_cancellation_exception) || + (instanceof_function(EG(exception)->ce, ZEND_ASYNC_GET_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION)) || zend_is_graceful_exit(EG(exception)) || zend_is_unwind_exit(EG(exception))))) { zend_object *exception = async_extract_exception(); diff --git a/exceptions.stub.php b/exceptions.stub.php index 1d6209a..5899d8c 100644 --- a/exceptions.stub.php +++ b/exceptions.stub.php @@ -8,7 +8,7 @@ * Exception thrown when a Coroutine is canceled. * Code inside the Coroutine must properly handle this exception to ensure graceful termination. */ -class CancellationException extends \CancellationException {} +class CancellationError extends \Error {} /** * Common type of exception. diff --git a/exceptions_arginfo.h b/exceptions_arginfo.h index e71a590..a065739 100644 --- a/exceptions_arginfo.h +++ b/exceptions_arginfo.h @@ -1,8 +1,8 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9bd64d6113fa23a91c46300cf51db636fea98124 */ + * Stub hash: 6ee15183630fa16055647deb278f0222bf5db317 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_CompositeException_addException, 0, 1, IS_VOID, 0) -ZEND_ARG_OBJ_INFO(0, exception, Throwable, 0) + ZEND_ARG_OBJ_INFO(0, exception, Throwable, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_CompositeException_getExceptions, 0, 0, IS_ARRAY, 0) @@ -11,21 +11,18 @@ ZEND_END_ARG_INFO() ZEND_METHOD(Async_CompositeException, addException); ZEND_METHOD(Async_CompositeException, getExceptions); -static const zend_function_entry class_Async_CompositeException_methods[] = { ZEND_ME( - Async_CompositeException, - addException, - arginfo_class_Async_CompositeException_addException, - ZEND_ACC_PUBLIC) ZEND_ME(Async_CompositeException, - getExceptions, - arginfo_class_Async_CompositeException_getExceptions, - ZEND_ACC_PUBLIC) ZEND_FE_END }; +static const zend_function_entry class_Async_CompositeException_methods[] = { + ZEND_ME(Async_CompositeException, addException, arginfo_class_Async_CompositeException_addException, ZEND_ACC_PUBLIC) + ZEND_ME(Async_CompositeException, getExceptions, arginfo_class_Async_CompositeException_getExceptions, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; -static zend_class_entry *register_class_Async_CancellationException(zend_class_entry *class_entry_CancellationException) +static zend_class_entry *register_class_Async_CancellationError(zend_class_entry *class_entry_Error) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "Async", "CancellationException", NULL); - class_entry = zend_register_internal_class_with_flags(&ce, class_entry_CancellationException, 0); + INIT_NS_CLASS_ENTRY(ce, "Async", "CancellationError", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_Error, 0); return class_entry; } @@ -85,18 +82,12 @@ static zend_class_entry *register_class_Async_CompositeException(zend_class_entr zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "Async", "CompositeException", class_Async_CompositeException_methods); - class_entry = zend_register_internal_class_with_flags( - &ce, class_entry_Exception, ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_Exception, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES); zval property_exceptions_default_value; ZVAL_UNDEF(&property_exceptions_default_value); zend_string *property_exceptions_name = zend_string_init("exceptions", sizeof("exceptions") - 1, 1); - zend_declare_typed_property(class_entry, - property_exceptions_name, - &property_exceptions_default_value, - ZEND_ACC_PRIVATE, - NULL, - (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); + zend_declare_typed_property(class_entry, property_exceptions_name, &property_exceptions_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); zend_string_release(property_exceptions_name); return class_entry; diff --git a/scope.stub.php b/scope.stub.php index 8d8e653..83b155c 100644 --- a/scope.stub.php +++ b/scope.stub.php @@ -53,7 +53,7 @@ public function asNotSafely(): Scope {} public function spawn(\Closure $callable, mixed ...$params): Coroutine {} - public function cancel(?CancellationException $cancellationException = null): void {} + public function cancel(?CancellationError $cancellationError = null): void {} public function awaitCompletion(Awaitable $cancellation): void {} diff --git a/scope_arginfo.h b/scope_arginfo.h index 35d8f1a..0729e62 100644 --- a/scope_arginfo.h +++ b/scope_arginfo.h @@ -1,21 +1,21 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 655728a28912cc420f1fe0ae483291cff8153fdc */ + * Stub hash: a93e0b70e865dea520f8d9d22e73b6640e1c0ebc */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Async_ScopeProvider_provideScope, 0, 0, Async\\Scope, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_SpawnStrategy_beforeCoroutineEnqueue, 0, 2, IS_ARRAY, 0) -ZEND_ARG_OBJ_INFO(0, coroutine, Async\\Coroutine, 0) -ZEND_ARG_OBJ_INFO(0, scope, Async\\Scope, 0) + ZEND_ARG_OBJ_INFO(0, coroutine, Async\\Coroutine, 0) + ZEND_ARG_OBJ_INFO(0, scope, Async\\Scope, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_SpawnStrategy_afterCoroutineEnqueue, 0, 2, IS_VOID, 0) -ZEND_ARG_OBJ_INFO(0, coroutine, Async\\Coroutine, 0) -ZEND_ARG_OBJ_INFO(0, scope, Async\\Scope, 0) + ZEND_ARG_OBJ_INFO(0, coroutine, Async\\Coroutine, 0) + ZEND_ARG_OBJ_INFO(0, scope, Async\\Scope, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Async_Scope_inherit, 0, 0, Async\\Scope, 0) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, parentScope, Async\\Scope, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, parentScope, Async\\Scope, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Async_Scope_provideScope, 0, 0, Async\\Scope, 0) @@ -27,21 +27,21 @@ ZEND_END_ARG_INFO() #define arginfo_class_Async_Scope_asNotSafely arginfo_class_Async_Scope_provideScope ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Async_Scope_spawn, 0, 1, Async\\Coroutine, 0) -ZEND_ARG_OBJ_INFO(0, callable, Closure, 0) -ZEND_ARG_VARIADIC_TYPE_INFO(0, params, IS_MIXED, 0) + ZEND_ARG_OBJ_INFO(0, callable, Closure, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, params, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_cancel, 0, 0, IS_VOID, 0) -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellationException, Async\\CancellationException, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellationError, Async\\CancellationError, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_awaitCompletion, 0, 1, IS_VOID, 0) -ZEND_ARG_OBJ_INFO(0, cancellation, Async\\Awaitable, 0) + ZEND_ARG_OBJ_INFO(0, cancellation, Async\\Awaitable, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_awaitAfterCancellation, 0, 0, IS_VOID, 0) -ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, errorHandler, IS_CALLABLE, 1, "null") -ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, errorHandler, IS_CALLABLE, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, cancellation, Async\\Awaitable, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_isFinished, 0, 0, _IS_BOOL, 0) @@ -52,13 +52,13 @@ ZEND_END_ARG_INFO() #define arginfo_class_Async_Scope_isCancelled arginfo_class_Async_Scope_isFinished ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_setExceptionHandler, 0, 1, IS_VOID, 0) -ZEND_ARG_TYPE_INFO(0, exceptionHandler, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, exceptionHandler, IS_CALLABLE, 0) ZEND_END_ARG_INFO() #define arginfo_class_Async_Scope_setChildScopeExceptionHandler arginfo_class_Async_Scope_setExceptionHandler ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_onFinally, 0, 1, IS_VOID, 0) -ZEND_ARG_OBJ_INFO(0, callback, Closure, 0) + ZEND_ARG_OBJ_INFO(0, callback, Closure, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_dispose, 0, 0, IS_VOID, 0) @@ -67,7 +67,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_Async_Scope_disposeSafely arginfo_class_Async_Scope_dispose ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_disposeAfterTimeout, 0, 1, IS_VOID, 0) -ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Async_Scope_getChildScopes, 0, 0, IS_ARRAY, 0) @@ -92,76 +92,37 @@ ZEND_METHOD(Async_Scope, disposeSafely); ZEND_METHOD(Async_Scope, disposeAfterTimeout); ZEND_METHOD(Async_Scope, getChildScopes); -static const zend_function_entry class_Async_ScopeProvider_methods[] = { ZEND_RAW_FENTRY( - "provideScope", - NULL, - arginfo_class_Async_ScopeProvider_provideScope, - ZEND_ACC_PUBLIC | ZEND_ACC_ABSTRACT, - NULL, - NULL) ZEND_FE_END }; - -static const zend_function_entry class_Async_SpawnStrategy_methods[] = { ZEND_RAW_FENTRY( - "beforeCoroutineEnqueue", - NULL, - arginfo_class_Async_SpawnStrategy_beforeCoroutineEnqueue, - ZEND_ACC_PUBLIC | ZEND_ACC_ABSTRACT, - NULL, - NULL) ZEND_RAW_FENTRY("afterCoroutineEnqueue", - NULL, - arginfo_class_Async_SpawnStrategy_afterCoroutineEnqueue, - ZEND_ACC_PUBLIC | ZEND_ACC_ABSTRACT, - NULL, - NULL) ZEND_FE_END }; +static const zend_function_entry class_Async_ScopeProvider_methods[] = { + ZEND_RAW_FENTRY("provideScope", NULL, arginfo_class_Async_ScopeProvider_provideScope, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_FE_END +}; + +static const zend_function_entry class_Async_SpawnStrategy_methods[] = { + ZEND_RAW_FENTRY("beforeCoroutineEnqueue", NULL, arginfo_class_Async_SpawnStrategy_beforeCoroutineEnqueue, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("afterCoroutineEnqueue", NULL, arginfo_class_Async_SpawnStrategy_afterCoroutineEnqueue, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_FE_END +}; static const zend_function_entry class_Async_Scope_methods[] = { - ZEND_ME(Async_Scope, inherit, arginfo_class_Async_Scope_inherit, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_ME( - Async_Scope, - provideScope, - arginfo_class_Async_Scope_provideScope, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, __construct, arginfo_class_Async_Scope___construct, ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, asNotSafely, arginfo_class_Async_Scope_asNotSafely, ZEND_ACC_PUBLIC) ZEND_ME( - Async_Scope, spawn, arginfo_class_Async_Scope_spawn, ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, cancel, arginfo_class_Async_Scope_cancel, ZEND_ACC_PUBLIC) ZEND_ME( - Async_Scope, - awaitCompletion, - arginfo_class_Async_Scope_awaitCompletion, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, - awaitAfterCancellation, - arginfo_class_Async_Scope_awaitAfterCancellation, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, - isFinished, - arginfo_class_Async_Scope_isFinished, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, isClosed, arginfo_class_Async_Scope_isClosed, ZEND_ACC_PUBLIC) ZEND_ME( - Async_Scope, - isCancelled, - arginfo_class_Async_Scope_isCancelled, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, - setExceptionHandler, - arginfo_class_Async_Scope_setExceptionHandler, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, - setChildScopeExceptionHandler, - arginfo_class_Async_Scope_setChildScopeExceptionHandler, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, - onFinally, - arginfo_class_Async_Scope_onFinally, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, - dispose, - arginfo_class_Async_Scope_dispose, - ZEND_ACC_PUBLIC) ZEND_ME(Async_Scope, - disposeSafely, - arginfo_class_Async_Scope_disposeSafely, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, - disposeAfterTimeout, - arginfo_class_Async_Scope_disposeAfterTimeout, - ZEND_ACC_PUBLIC) - ZEND_ME(Async_Scope, - getChildScopes, - arginfo_class_Async_Scope_getChildScopes, - ZEND_ACC_PUBLIC) ZEND_FE_END + ZEND_ME(Async_Scope, inherit, arginfo_class_Async_Scope_inherit, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Async_Scope, provideScope, arginfo_class_Async_Scope_provideScope, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, __construct, arginfo_class_Async_Scope___construct, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, asNotSafely, arginfo_class_Async_Scope_asNotSafely, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, spawn, arginfo_class_Async_Scope_spawn, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, cancel, arginfo_class_Async_Scope_cancel, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, awaitCompletion, arginfo_class_Async_Scope_awaitCompletion, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, awaitAfterCancellation, arginfo_class_Async_Scope_awaitAfterCancellation, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, isFinished, arginfo_class_Async_Scope_isFinished, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, isClosed, arginfo_class_Async_Scope_isClosed, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, isCancelled, arginfo_class_Async_Scope_isCancelled, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, setExceptionHandler, arginfo_class_Async_Scope_setExceptionHandler, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, setChildScopeExceptionHandler, arginfo_class_Async_Scope_setChildScopeExceptionHandler, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, onFinally, arginfo_class_Async_Scope_onFinally, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, dispose, arginfo_class_Async_Scope_dispose, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, disposeSafely, arginfo_class_Async_Scope_disposeSafely, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, disposeAfterTimeout, arginfo_class_Async_Scope_disposeAfterTimeout, ZEND_ACC_PUBLIC) + ZEND_ME(Async_Scope, getChildScopes, arginfo_class_Async_Scope_getChildScopes, ZEND_ACC_PUBLIC) + ZEND_FE_END }; static zend_class_entry *register_class_Async_ScopeProvider(void) @@ -190,17 +151,12 @@ static zend_class_entry *register_class_Async_Scope(zend_class_entry *class_entr zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "Async", "Scope", class_Async_Scope_methods); - class_entry = zend_register_internal_class_with_flags( - &ce, NULL, ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES | ZEND_ACC_NOT_SERIALIZABLE); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE); zend_class_implements(class_entry, 1, class_entry_Async_ScopeProvider); - zend_string *attribute_name_Override_func_providescope_0 = - zend_string_init_interned("Override", sizeof("Override") - 1, 1); - zend_add_function_attribute( - zend_hash_str_find_ptr(&class_entry->function_table, "providescope", sizeof("providescope") - 1), - attribute_name_Override_func_providescope_0, - 0); + zend_string *attribute_name_Override_func_providescope_0 = zend_string_init_interned("Override", sizeof("Override") - 1, 1); + zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "providescope", sizeof("providescope") - 1), attribute_name_Override_func_providescope_0, 0); zend_string_release(attribute_name_Override_func_providescope_0); return class_entry; diff --git a/tests/await/066-await_cancelled_coroutine.phpt b/tests/await/066-await_cancelled_coroutine.phpt index c1e9732..1fe3a8b 100644 --- a/tests/await/066-await_cancelled_coroutine.phpt +++ b/tests/await/066-await_cancelled_coroutine.phpt @@ -16,13 +16,13 @@ $coroutine1 = spawn(function() { return "result1"; }); -$coroutine1->cancel(new \Async\CancellationException("Manual cancellation")); +$coroutine1->cancel(new \Async\CancellationError("Manual cancellation")); echo "coroutine1 cancelled\n"; try { $result1 = await($coroutine1); echo "await should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "caught cancellation: " . $e->getMessage() . "\n"; } catch (Throwable $e) { echo "caught unexpected: " . get_class($e) . ": " . $e->getMessage() . "\n"; @@ -39,13 +39,13 @@ $coroutine2 = spawn(function() { // Let coroutine start suspend(); -$coroutine2->cancel(new \Async\CancellationException("Cancelled during execution")); +$coroutine2->cancel(new \Async\CancellationError("Cancelled during execution")); echo "coroutine2 cancelled during execution\n"; try { $result2 = await($coroutine2); echo "await should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "caught cancellation: " . $e->getMessage() . "\n"; } catch (Throwable $e) { echo "caught unexpected: " . get_class($e) . ": " . $e->getMessage() . "\n"; diff --git a/tests/await/068-await_multiple_times.phpt b/tests/await/068-await_multiple_times.phpt index c8445d2..171d337 100644 --- a/tests/await/068-await_multiple_times.phpt +++ b/tests/await/068-await_multiple_times.phpt @@ -58,13 +58,13 @@ $coroutine3 = spawn(function() { return "never_reached"; }); -$coroutine3->cancel(new \Async\CancellationException("Shared cancellation")); +$coroutine3->cancel(new \Async\CancellationError("Shared cancellation")); echo "first await on cancelled coroutine\n"; try { $result3a = await($coroutine3); echo "should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "first caught cancellation: " . $e->getMessage() . "\n"; } @@ -72,7 +72,7 @@ echo "second await on cancelled coroutine\n"; try { $result3b = await($coroutine3); echo "should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "second caught cancellation: " . $e->getMessage() . "\n"; } diff --git a/tests/await/069-await_manual_vs_timeout_cancel.phpt b/tests/await/069-await_manual_vs_timeout_cancel.phpt index f0fcdd0..ea1ce23 100644 --- a/tests/await/069-await_manual_vs_timeout_cancel.phpt +++ b/tests/await/069-await_manual_vs_timeout_cancel.phpt @@ -22,13 +22,13 @@ $manual_coroutine = spawn(function() { // Let it start suspend(); -$manual_coroutine->cancel(new \Async\CancellationException("Manual cancel message")); +$manual_coroutine->cancel(new \Async\CancellationError("Manual cancel message")); echo "manual coroutine cancelled\n"; try { $result = await($manual_coroutine); echo "manual await should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "manual cancellation caught: " . get_class($e) . ": " . $e->getMessage() . "\n"; } catch (Throwable $e) { echo "manual unexpected: " . get_class($e) . ": " . $e->getMessage() . "\n"; @@ -49,8 +49,8 @@ try { echo "timeout await should not succeed\n"; } catch (\Async\TimeoutException $e) { echo "timeout cancellation caught: " . get_class($e) . ": " . $e->getMessage() . "\n"; - $timeout_coroutine->cancel(new \Async\CancellationException("Timeout after 1 milliseconds")); -} catch (\Async\CancellationException $e) { + $timeout_coroutine->cancel(new \Async\CancellationError("Timeout after 1 milliseconds")); +} catch (\Async\CancellationError $e) { echo "timeout as cancellation: " . get_class($e) . ": " . $e->getMessage() . "\n"; } catch (Throwable $e) { echo "timeout unexpected: " . get_class($e) . ": " . $e->getMessage() . "\n"; @@ -68,12 +68,12 @@ $race_coroutine = spawn(function() { suspend(); // Cancel manually before timeout -$race_coroutine->cancel(new \Async\CancellationException("Manual wins")); +$race_coroutine->cancel(new \Async\CancellationError("Manual wins")); try { $result = await($race_coroutine, timeout(1000)); // Should get manual cancel, not timeout echo "race await should not succeed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "race cancellation caught: " . get_class($e) . ": " . $e->getMessage() . "\n"; } catch (\Async\TimeoutException $e) { echo "race timeout caught: " . get_class($e) . ": " . $e->getMessage() . "\n"; @@ -88,10 +88,10 @@ echo "end\n"; start manual coroutine started manual coroutine cancelled -manual cancellation caught: Async\CancellationException: Manual cancel message +manual cancellation caught: Async\CancellationError: Manual cancel message timeout coroutine spawned timeout coroutine started timeout cancellation caught: Async\TimeoutException: Timeout occurred after 1 milliseconds race coroutine started -race cancellation caught: Async\CancellationException: Manual wins +race cancellation caught: Async\CancellationError: Manual wins end \ No newline at end of file diff --git a/tests/await/070-await_state_transitions.phpt b/tests/await/070-await_state_transitions.phpt index 4e9f409..33722af 100644 --- a/tests/await/070-await_state_transitions.phpt +++ b/tests/await/070-await_state_transitions.phpt @@ -20,7 +20,7 @@ await($completed_coroutine); echo "coroutine finished: " . ($completed_coroutine->isFinished() ? "true" : "false") . "\n"; // Try to cancel already completed coroutine -$completed_coroutine->cancel(new \Async\CancellationException("Too late")); +$completed_coroutine->cancel(new \Async\CancellationError("Too late")); echo "attempted to cancel completed coroutine\n"; // Await should still return original result @@ -44,7 +44,7 @@ try { echo "exception coroutine finished: " . ($exception_coroutine->isFinished() ? "true" : "false") . "\n"; // Try to cancel coroutine that already failed -$exception_coroutine->cancel(new \Async\CancellationException("Post-error cancel")); +$exception_coroutine->cancel(new \Async\CancellationError("Post-error cancel")); echo "attempted to cancel failed coroutine\n"; // Should still get original exception @@ -57,7 +57,7 @@ try { } else { echo "unexpected exception: " . get_class($e) . ": " . $e->getMessage() . "\n"; } -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "unexpected cancellation: " . $e->getMessage() . "\n"; } diff --git a/tests/await/071-awaitAll_with_cancellation_simultaneously.phpt b/tests/await/071-awaitAll_with_cancellation_simultaneously.phpt index 8c8a60e..38849ee 100644 --- a/tests/await/071-awaitAll_with_cancellation_simultaneously.phpt +++ b/tests/await/071-awaitAll_with_cancellation_simultaneously.phpt @@ -19,7 +19,7 @@ $coroutine2 = spawn(function() { try { $result = awaitAll([$coroutine1, $coroutine2], $coroutine2); var_dump($result); -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { } echo "end\n"; diff --git a/tests/coroutine/006-coroutine_cancel_basic.phpt b/tests/coroutine/006-coroutine_cancel_basic.phpt index 241f916..08b8aa2 100644 --- a/tests/coroutine/006-coroutine_cancel_basic.phpt +++ b/tests/coroutine/006-coroutine_cancel_basic.phpt @@ -1,17 +1,17 @@ --TEST-- -Coroutine: cancel() - basic usage with CancellationException +Coroutine: cancel() - basic usage with CancellationError --FILE-- cancel($cancellation); var_dump($coroutine->isCancellationRequested()); @@ -19,7 +19,7 @@ var_dump($coroutine->isCancelled()); try { await($coroutine); -} catch (CancellationException $e) { +} catch (CancellationError $e) { echo "Caught: " . $e->getMessage() . "\n"; } diff --git a/tests/coroutine/028-coroutine_state_transitions.phpt b/tests/coroutine/028-coroutine_state_transitions.phpt index 8c689c2..1416429 100644 --- a/tests/coroutine/028-coroutine_state_transitions.phpt +++ b/tests/coroutine/028-coroutine_state_transitions.phpt @@ -92,7 +92,7 @@ suspend(); // Let it start echo "before cancel request - isCancellationRequested: " . ($cancel_request_coroutine->isCancellationRequested() ? "true" : "false") . "\n"; echo "before cancel request - isCancelled: " . ($cancel_request_coroutine->isCancelled() ? "true" : "false") . "\n"; -$cancel_request_coroutine->cancel(new \Async\CancellationException("Test cancellation")); +$cancel_request_coroutine->cancel(new \Async\CancellationError("Test cancellation")); echo "after cancel request - isCancellationRequested: " . ($cancel_request_coroutine->isCancellationRequested() ? "true" : "false") . "\n"; diff --git a/tests/coroutine/029-coroutine_deferred_cancellation_basic.phpt b/tests/coroutine/029-coroutine_deferred_cancellation_basic.phpt index bcb3fa5..de4b1af 100644 --- a/tests/coroutine/029-coroutine_deferred_cancellation_basic.phpt +++ b/tests/coroutine/029-coroutine_deferred_cancellation_basic.phpt @@ -28,7 +28,7 @@ $protected_coroutine = spawn(function() { suspend(); echo "cancelling protected coroutine\n"; -$protected_coroutine->cancel(new \Async\CancellationException("Deferred cancellation")); +$protected_coroutine->cancel(new \Async\CancellationError("Deferred cancellation")); echo "protected coroutine cancelled: " . ($protected_coroutine->isCancelled() ? "true" : "false") . "\n"; echo "cancellation requested: " . ($protected_coroutine->isCancellationRequested() ? "true" : "false") . "\n"; @@ -40,7 +40,7 @@ echo "after protected completion - cancelled: " . ($protected_coroutine->isCance try { await($protected_coroutine); -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { } $result = $protected_coroutine->getResult(); diff --git a/tests/coroutine/030-coroutine_deferred_cancellation_multiple.phpt b/tests/coroutine/030-coroutine_deferred_cancellation_multiple.phpt index 9aad519..59078a3 100644 --- a/tests/coroutine/030-coroutine_deferred_cancellation_multiple.phpt +++ b/tests/coroutine/030-coroutine_deferred_cancellation_multiple.phpt @@ -33,12 +33,12 @@ $multi_protected = spawn(function() { suspend(); // Enter first protection -$multi_protected->cancel(new \Async\CancellationException("Multi deferred")); +$multi_protected->cancel(new \Async\CancellationError("Multi deferred")); echo "multi cancelled during first protection\n"; try { await($multi_protected); -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "multi deferred cancellation: " . $e->getMessage() . "\n"; } diff --git a/tests/coroutine/031-coroutine_deferred_cancellation_during_protection.phpt b/tests/coroutine/031-coroutine_deferred_cancellation_during_protection.phpt index f8ec75d..d8298be 100644 --- a/tests/coroutine/031-coroutine_deferred_cancellation_during_protection.phpt +++ b/tests/coroutine/031-coroutine_deferred_cancellation_during_protection.phpt @@ -21,7 +21,7 @@ $already_protected = spawn(function() { echo "protection completed\n"; }); echo "after protection block\n"; - } catch (\Async\CancellationException $e) { + } catch (\Async\CancellationError $e) { echo "caught cancellation in coroutine: " . $e->getMessage() . "\n"; throw $e; } @@ -32,11 +32,11 @@ $already_protected = spawn(function() { suspend(); // Enter protection // Cancel while protected -$already_protected->cancel(new \Async\CancellationException("Cancel during protection")); +$already_protected->cancel(new \Async\CancellationError("Cancel during protection")); try { await($already_protected); -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "protection cancellation: " . $e->getMessage() . "\n"; } diff --git a/tests/coroutine/034-coroutine_cancel_invalid_exception.phpt b/tests/coroutine/034-coroutine_cancel_invalid_exception.phpt index 3e2c664..4fbd31c 100644 --- a/tests/coroutine/034-coroutine_cancel_invalid_exception.phpt +++ b/tests/coroutine/034-coroutine_cancel_invalid_exception.phpt @@ -35,7 +35,7 @@ try { } // Valid cancellation -$invalid_cancel_coroutine->cancel(new \Async\CancellationException("Valid cancellation")); +$invalid_cancel_coroutine->cancel(new \Async\CancellationError("Valid cancellation")); echo "end\n"; diff --git a/tests/coroutine/README.md b/tests/coroutine/README.md index fcdf258..29dd675 100644 --- a/tests/coroutine/README.md +++ b/tests/coroutine/README.md @@ -15,7 +15,7 @@ This directory contains tests for the Coroutine class methods implementation. - `013-coroutine_running_detection.phpt` - Tests isRunning() method ### Cancellation -- `006-coroutine_cancel_basic.phpt` - Tests cancel() method with CancellationException +- `006-coroutine_cancel_basic.phpt` - Tests cancel() method with CancellationError ### Location Information - `007-coroutine_spawn_location.phpt` - Tests getSpawnFileAndLine() and getSpawnLocation() diff --git a/tests/dns/010-dns_cancellation.phpt b/tests/dns/010-dns_cancellation.phpt index e3681c2..59154b2 100644 --- a/tests/dns/010-dns_cancellation.phpt +++ b/tests/dns/010-dns_cancellation.phpt @@ -20,7 +20,7 @@ $coroutine = spawn(function() { try { $result = await($dns_coroutine); echo "DNS lookup result: $result\n"; - } catch (Async\CancellationException $e) { + } catch (Async\CancellationError $e) { echo "DNS lookup was cancelled\n"; } catch (Throwable $e) { echo "DNS lookup failed with: " . get_class($e) . "\n"; diff --git a/tests/edge_cases/004-scope_provider_exceptions.phpt b/tests/edge_cases/004-scope_provider_exceptions.phpt index 2b756ea..5293ea9 100644 --- a/tests/edge_cases/004-scope_provider_exceptions.phpt +++ b/tests/edge_cases/004-scope_provider_exceptions.phpt @@ -23,7 +23,7 @@ class ThrowingScopeProvider implements \Async\ScopeProvider case 'runtime': throw new \RuntimeException("Runtime error in provider"); case 'cancellation': - throw new \Async\CancellationException("Cancelled in provider"); + throw new \Async\CancellationError("Cancelled in provider"); case 'invalid_argument': throw new \InvalidArgumentException("Invalid argument in provider"); case 'logic': @@ -43,8 +43,8 @@ foreach ($exceptionTypes as $type) { return "test"; }); echo "ERROR: Should have thrown exception for {$type}\n"; - } catch (\Async\CancellationException $e) { - echo "Caught CancellationException: " . $e->getMessage() . "\n"; + } catch (\Async\CancellationError $e) { + echo "Caught CancellationError: " . $e->getMessage() . "\n"; } catch (\RuntimeException $e) { echo "Caught RuntimeException: " . $e->getMessage() . "\n"; } catch (\InvalidArgumentException $e) { @@ -64,7 +64,7 @@ echo "end\n"; --EXPECT-- start Caught RuntimeException: Runtime error in provider -Caught CancellationException: Cancelled in provider +Caught CancellationError: Cancelled in provider Caught InvalidArgumentException: Invalid argument in provider Caught LogicException: Logic error in provider Caught Exception: Generic error in provider diff --git a/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt b/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt index 8cf34b7..87c7f82 100644 --- a/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt +++ b/tests/edge_cases/006-scheduler_graceful_shutdown_exceptions.phpt @@ -28,10 +28,10 @@ echo "coroutines spawned\n"; // Trigger graceful shutdown with custom cancellation try { - $cancellation = new \Async\CancellationException("Custom shutdown message"); + $cancellation = new \Async\CancellationError("Custom shutdown message"); awaitAll([$error_coroutine, $cleanup_coroutine]); echo "graceful shutdown with custom cancellation completed\n"; -} catch (\Async\CancellationException $e) { +} catch (\Async\CancellationError $e) { echo "caught shutdown cancellation: " . $e->getMessage() . "\n"; } catch (Throwable $e) { echo "caught shutdown exception: " . get_class($e) . ": " . $e->getMessage() . "\n"; diff --git a/tests/pdo_mysql/009-pdo_cancellation.phpt b/tests/pdo_mysql/009-pdo_cancellation.phpt index c20e55b..1175d5c 100644 --- a/tests/pdo_mysql/009-pdo_cancellation.phpt +++ b/tests/pdo_mysql/009-pdo_cancellation.phpt @@ -31,7 +31,7 @@ $coroutine = spawn(function() { $result = $stmt->fetch(PDO::FETCH_ASSOC); return "completed"; - } catch (Async\CancellationException $e) { + } catch (Async\CancellationError $e) { return "cancelled"; } }); @@ -46,7 +46,7 @@ $coroutine->cancel(); try { $result = await($coroutine); echo "original query result: " . $result . "\n"; -} catch (Async\CancellationException $e) { +} catch (Async\CancellationError $e) { echo "original query was cancelled\n"; } diff --git a/tests/protect/005-protect_cancellation_immediate.phpt b/tests/protect/005-protect_cancellation_immediate.phpt index 568ca57..6522c0e 100644 --- a/tests/protect/005-protect_cancellation_immediate.phpt +++ b/tests/protect/005-protect_cancellation_immediate.phpt @@ -18,7 +18,7 @@ $coroutine = spawn(function() { suspend(); echo "finished protect\n"; }); - } catch (\CancellationException $e) { + } catch (Async\CancellationError $e) { echo "caught exception: " . $e->getMessage() . "\n"; } }); diff --git a/tests/scope/025-scope_awaitAfterCancellation_error_handler.phpt b/tests/scope/025-scope_awaitAfterCancellation_error_handler.phpt index 2febaed..3e3e0bc 100644 --- a/tests/scope/025-scope_awaitAfterCancellation_error_handler.phpt +++ b/tests/scope/025-scope_awaitAfterCancellation_error_handler.phpt @@ -19,7 +19,7 @@ $error_coroutine = $scope->spawn(function() { try { suspend(); // Suspend to simulate work - } catch (\CancellationException $e) { + } catch (\CancellationError $e) { echo "coroutine cancelled\n"; suspend(); throw new \RuntimeException("Coroutine error after cancellation"); diff --git a/tests/scope/026-scope_cancel_with_active_coroutines.phpt b/tests/scope/026-scope_cancel_with_active_coroutines.phpt index 3297c2f..f52b212 100644 --- a/tests/scope/026-scope_cancel_with_active_coroutines.phpt +++ b/tests/scope/026-scope_cancel_with_active_coroutines.phpt @@ -19,7 +19,7 @@ $coroutine1 = $scope->spawn(function() { suspend(); echo "coroutine1 should not reach here\n"; return "result1"; - } catch (\Async\CancellationException $e) { + } catch (\Async\CancellationError $e) { echo "coroutine1 caught cancellation: " . $e->getMessage() . "\n"; throw $e; } @@ -32,7 +32,7 @@ $coroutine2 = $scope->spawn(function() { suspend(); echo "coroutine2 should not reach here\n"; return "result2"; - } catch (\Async\CancellationException $e) { + } catch (\Async\CancellationError $e) { echo "coroutine2 caught cancellation: " . $e->getMessage() . "\n"; throw $e; } @@ -44,7 +44,7 @@ echo "spawned coroutines\n"; suspend(); echo "cancelling scope\n"; -$scope->cancel(new \Async\CancellationException("Custom cancellation message")); +$scope->cancel(new \Async\CancellationError("Custom cancellation message")); // Let cancellation propagate suspend(); diff --git a/tests/scope/028-scope_hierarchy_cancellation_basic.phpt b/tests/scope/028-scope_hierarchy_cancellation_basic.phpt index ec94433..9ef149d 100644 --- a/tests/scope/028-scope_hierarchy_cancellation_basic.phpt +++ b/tests/scope/028-scope_hierarchy_cancellation_basic.phpt @@ -56,7 +56,7 @@ echo "child2 scope cancelled: " . ($child2_scope->isCancelled() ? "true" : "fals // Cancel parent scope - should cascade to children echo "cancelling parent scope\n"; -$parent_scope->cancel(new \Async\CancellationException("Parent cancelled")); +$parent_scope->cancel(new \Async\CancellationError("Parent cancelled")); // Let cancellation propagate suspend(); diff --git a/tests/scope/029-scope_complex_tree_cancellation.phpt b/tests/scope/029-scope_complex_tree_cancellation.phpt index 62d82a4..0d8f50b 100644 --- a/tests/scope/029-scope_complex_tree_cancellation.phpt +++ b/tests/scope/029-scope_complex_tree_cancellation.phpt @@ -56,7 +56,7 @@ foreach ($scopes_and_coroutines as $name => $data) { // Cancel middle node (child_scope) - should cancel its descendants but not ancestors echo "cancelling child scope (middle node)\n"; -$child_scope->cancel(new \Async\CancellationException("Child cancelled")); +$child_scope->cancel(new \Async\CancellationError("Child cancelled")); // Let cancellation propagate suspend(); @@ -70,7 +70,7 @@ foreach ($scopes_and_coroutines as $name => $data) { // Now cancel parent - should cancel everything remaining echo "cancelling parent scope (root)\n"; -$parent_scope->cancel(new \Async\CancellationException("Parent cancelled")); +$parent_scope->cancel(new \Async\CancellationError("Parent cancelled")); // Let cancellation propagate suspend(); diff --git a/tests/scope/030-scope_inheritance_cancellation_isolation.phpt b/tests/scope/030-scope_inheritance_cancellation_isolation.phpt index 5d2b6e5..3c8f338 100644 --- a/tests/scope/030-scope_inheritance_cancellation_isolation.phpt +++ b/tests/scope/030-scope_inheritance_cancellation_isolation.phpt @@ -60,7 +60,7 @@ suspend(); // Cancel only child1 - should not affect parent or other children echo "cancelling child1 scope only\n"; -$child1_scope->cancel(new \Async\CancellationException("Child1 cancelled")); +$child1_scope->cancel(new \Async\CancellationError("Child1 cancelled")); suspend(); @@ -76,7 +76,7 @@ suspend(); // Cancel child3 as well echo "cancelling child3 scope\n"; -$child3_scope->cancel(new \Async\CancellationException("Child3 cancelled")); +$child3_scope->cancel(new \Async\CancellationError("Child3 cancelled")); // Let cancellation propagate suspend(); diff --git a/tests/scope/031-scope_concurrent_cancellation.phpt b/tests/scope/031-scope_concurrent_cancellation.phpt index 5de1867..bf1f178 100644 --- a/tests/scope/031-scope_concurrent_cancellation.phpt +++ b/tests/scope/031-scope_concurrent_cancellation.phpt @@ -50,17 +50,17 @@ suspend(); // Spawn concurrent cancellation operations $canceller1 = spawn(function() use ($scope1) { echo "canceller1 starting\n"; - $scope1->cancel(new \Async\CancellationException("Concurrent cancel 1")); + $scope1->cancel(new \Async\CancellationError("Concurrent cancel 1")); }); $canceller2 = spawn(function() use ($scope2) { echo "canceller2 starting\n"; - $scope2->cancel(new \Async\CancellationException("Concurrent cancel 2")); + $scope2->cancel(new \Async\CancellationError("Concurrent cancel 2")); }); $canceller3 = spawn(function() use ($scope3) { echo "canceller3 starting\n"; - $scope3->cancel(new \Async\CancellationException("Concurrent cancel 3")); + $scope3->cancel(new \Async\CancellationError("Concurrent cancel 3")); }); echo "cancellers spawned\n"; diff --git a/tests/scope/032-scope_mixed_cancellation_sources.phpt b/tests/scope/032-scope_mixed_cancellation_sources.phpt index a2426d9..0a8e9f3 100644 --- a/tests/scope/032-scope_mixed_cancellation_sources.phpt +++ b/tests/scope/032-scope_mixed_cancellation_sources.phpt @@ -43,7 +43,7 @@ suspend(); // Cancel individual coroutine first echo "cancelling coroutine2 individually\n"; -$coroutine2->cancel(new \Async\CancellationException("Individual cancel")); +$coroutine2->cancel(new \Async\CancellationError("Individual cancel")); // Let cancellation propagate suspend(); @@ -57,7 +57,7 @@ echo "coroutine3 cancelled: " . ($coroutine3->isCancelled() ? "true" : "false") // Now cancel the entire scope echo "cancelling entire scope\n"; -$scope->cancel(new \Async\CancellationException("Scope cancel")); +$scope->cancel(new \Async\CancellationError("Scope cancel")); suspend(); // Let cancellation propagate diff --git a/tests/scope/033-scope_cancellation_finally_handlers.phpt b/tests/scope/033-scope_cancellation_finally_handlers.phpt index 59b49c0..c46ce60 100644 --- a/tests/scope/033-scope_cancellation_finally_handlers.phpt +++ b/tests/scope/033-scope_cancellation_finally_handlers.phpt @@ -67,7 +67,7 @@ echo "scope finally handler added\n"; // Cancel the parent scope - should trigger all finally handlers echo "cancelling parent scope\n"; -$scope->cancel(new \Async\CancellationException("Scope cancelled with finally")); +$scope->cancel(new \Async\CancellationError("Scope cancelled with finally")); // Let cancellation propagate suspend(); diff --git a/tests/scope/034-scope_cancellation_double_error.phpt b/tests/scope/034-scope_cancellation_double_error.phpt index 5a4f282..b60dd6c 100644 --- a/tests/scope/034-scope_cancellation_double_error.phpt +++ b/tests/scope/034-scope_cancellation_double_error.phpt @@ -53,7 +53,7 @@ echo "scope finally handler added\n"; // Cancel the parent scope - should trigger all finally handlers echo "cancelling parent scope\n"; -$scope->cancel(new \Async\CancellationException("Scope cancelled with finally")); +$scope->cancel(new \Async\CancellationError("Scope cancelled with finally")); // Let cancellation propagate suspend(); diff --git a/tests/spawn/008-spawn_cancellation_exception.phpt b/tests/spawn/008-spawn_cancellation_exception.phpt index a6f6534..2828469 100644 --- a/tests/spawn/008-spawn_cancellation_exception.phpt +++ b/tests/spawn/008-spawn_cancellation_exception.phpt @@ -1,16 +1,16 @@ --TEST-- -Future: spawn() - CancellationException handling (special case) +Future: spawn() - CancellationError handling (special case) --FILE--