PHP 8.1 to 8.4 catch-up
| Fibers recap | |
| Readonly recap | |
| Enums recap | |
| 8.3 and 8.4 |
Fibers recap
Fibers pause a task mid run and resume it later without threads or callbacks. Servers use them to juggle many slow waits inside one process while each task keeps its simple top to bottom shape.
$fiber = new Fiber(function (): void { echo "inside\n"; }); $fiber->start(); echo "back\n";
Readonly recap
Readonly properties lock a value after construction, which makes small value objects safe to share. Set every field once in the constructor and the shape can never drift later.
class Point { public function __construct( public readonly int $x, public readonly int $y ) { } } $p = new Point(3, 4); echo $p->x . "\n";
Enums recap
Enums replace magic strings with named cases the engine checks for you. A Role of Admin or Guest beats a bare admin string that any typo can silently invent.
enum Role: string { case Admin = "admin"; case Guest = "guest"; } $role = Role::Admin; echo $role->value . "\n";
8.3 and 8.4
Version 8.3 added typed class constants, so constant values now carry declared types that the engine verifies. Version 8.4 added property hooks, which let getters and setters live directly on the property with short blocks. Both ideas reward the same habits from PHP 8.0: declare types early and let the engine guard them.
Next: Capstone: pastebin app
Article author: Arthur Isaev