Add skip helper function for calling events

This commit is contained in:
crazywhalecc
2026-01-26 00:43:57 +08:00
parent c27ed8b0b4
commit a709221223
3 changed files with 28 additions and 1 deletions

View File

@@ -331,6 +331,20 @@ function spc_container(): DI\Container
return \StaticPHP\DI\ApplicationContext::getContainer();
}
/**
* Skip the current operation if the condition is true.
* You should ALWAYS use this function inside an attribute callback.
*
* @param bool $condition Condition to evaluate
* @param string $message Optional message for the skip exception
*/
function spc_skip_if(bool $condition, string $message = ''): void
{
if ($condition) {
throw new StaticPHP\Exception\SkipException($message);
}
}
/**
* Parse extension list from string, replace alias and filter internal extensions.
*