shortnames.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Alias classes and functions listed in this file are available only when directive "swoole.use_shortname" is not
  5. * explicitly turned off.
  6. *
  7. * PHP directive `swoole.use_shortname` can only be set in `php.ini` files.
  8. */
  9. class_alias(Swoole\Coroutine::class, co::class);
  10. class_alias(Swoole\Coroutine\Channel::class, chan::class);
  11. class_alias(Swoole\Coroutine\Channel::class, Co\Channel::class);
  12. class_alias(Swoole\Coroutine\Client::class, Co\Client::class);
  13. class_alias(Swoole\Coroutine\Context::class, Co\Context::class);
  14. class_alias(Swoole\Coroutine\Curl\Exception::class, Co\Curl\Exception::class);
  15. class_alias(Swoole\Coroutine\Http2\Client::class, Co\Http2\Client::class);
  16. class_alias(Swoole\Coroutine\Http2\Client\Exception::class, Co\Http2\Client\Exception::class);
  17. class_alias(Swoole\Coroutine\Http\Client::class, Co\Http\Client::class);
  18. class_alias(Swoole\Coroutine\Http\Client\Exception::class, Co\Http\Client\Exception::class);
  19. class_alias(Swoole\Coroutine\Http\Server::class, Co\Http\Server::class);
  20. class_alias(Swoole\Coroutine\Iterator::class, Co\Iterator::class);
  21. class_alias(Swoole\Coroutine\PostgreSQL::class, Co\PostgreSQL::class);
  22. class_alias(Swoole\Coroutine\Scheduler::class, Co\Scheduler::class);
  23. class_alias(Swoole\Coroutine\Socket::class, Co\Socket::class);
  24. class_alias(Swoole\Coroutine\Socket\Exception::class, Co\Socket\Exception::class);
  25. class_alias(Swoole\Coroutine\System::class, Co\System::class);
  26. // Following classes are deprecated since Swoole 5.0.0 and will be removed in the future.
  27. class_alias(Swoole\Coroutine\MySQL::class, Co\MySQL::class);
  28. class_alias(Swoole\Coroutine\MySQL\Exception::class, Co\MySQL\Exception::class);
  29. class_alias(Swoole\Coroutine\MySQL\Statement::class, Co\MySQL\Statement::class);
  30. class_alias(Swoole\Coroutine\Redis::class, Co\Redis::class);
  31. /**
  32. * Create a coroutine.
  33. *
  34. * This function is available only when directive "swoole.use_shortname" is not explicitly turned off.
  35. *
  36. * @return int|false Returns the coroutine ID on success, or false on failure. Note that this method won't return
  37. * the coroutine ID back until the new coroutine yields its execution.
  38. * @alias This function has an alias function swoole_coroutine_create() and an alias method \Swoole\Coroutine::create().
  39. * @see swoole_coroutine_create()
  40. * @see \Swoole\Coroutine::create()
  41. */
  42. function go(callable $func, ...$params): int|false
  43. {
  44. }
  45. /**
  46. * Defers the execution of a callback function until the surrounding function of a coroutine returns.
  47. *
  48. * This function is available only when directive "swoole.use_shortname" is not explicitly turned off.
  49. *
  50. * @alias This function is an alias of function swoole_coroutine_defer().
  51. * @see swoole_coroutine_defer()
  52. *
  53. * @example
  54. * <pre>
  55. * go(function () { // The surrounding function of a coroutine.
  56. * echo '1';
  57. * defer(function () { // The callback function to be deferred.
  58. * echo '3';
  59. * });
  60. * echo '2';
  61. * });
  62. * <pre>
  63. */
  64. function defer(callable $callback): void
  65. {
  66. }