[php-src] Issue #24624: Feature request: native async/await syntax built on Fibers
| From: | Eng3bbas | Date: | Fri, 23 Oct 2026 19:09:02 +0000 |
| Subject: | [php-src] Issue #24624: Feature request: native async/await syntax built on Fibers | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-253142@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/24624
Author: Eng3bbas
### Description
PHP 8.1 added Fibers, but writing concurrent code still means picking a userland library (Amp,
ReactPHP, Revolt) and its own Promise/Future types. This issue proposes native
async/await syntax built on top of Fibers, so the engine can express
concurrent code directly:
```php
async function fetch(string $name, float $secs): string {
await Async\delay($secs);
return "$name done";
}
$a = fetch("a", 0.2); // starts immediately and returns an Async\Future
$b = fetch("b", 0.2);
echo await $a, await $b; // ~0.2s total
```
A working prototype is in draft PR #24623. In short:
- async (functions, methods, closures, arrow functions) is a contextual keyword, so
existing async() functions keep working.
- await is a new reserved keyword, still allowed as a member name.
- Both are desugared in the parser into calls to a small Fiber-based scheduler
(Async\Future, Async\async(), Async\wait(),
Async\delay(), Async\suspend()). No new opcodes are needed.
Open questions for discussion:
- whether await as a reserved keyword is an acceptable BC break
- how this should relate to the separate True Async RFC
- what I/O / event-loop integration should look like (the prototype only has timers and cooperative
yielding)
I understand a change like this needs an RFC and discussion on the internals list. This issue and
the draft PR are meant to make that discussion concrete.