final class PostsController
{
#[AccessControl(fn(Request $request, Post $post)
=> $request->user === $post->getAuthor()
)]
public function update(Request $request, Post $post): Response {
// ...
}
}
Native (and optionally value-backed) enums:
enum Status
{
case Draft;
case Published;
case Archived;
}
Proper class property hooks, fully replacing getters and setters:
class Data
{
public string $fullName {
get => "{$this->firstName} {$this->lastName}";
set(string $value) {
[$first, $last] = explode(' ', $value);
$this->firstName = $first;
$this->lastName = $last;
}
}
}
And tons of other features—among them asymmetric property visibility, fibres/green threads, DNF types, lazy object instantiation, an ever-improving yet fully opt-in static type system with runtime validation, a JIT compiler, an amazing package ecosystem and -manager, annotation-backed deprecation, and more.
Let me convince you! :-)
There are match expressions and arrow functions:
There is meta-programming with annotations: Native (and optionally value-backed) enums: Proper class property hooks, fully replacing getters and setters: And tons of other features—among them asymmetric property visibility, fibres/green threads, DNF types, lazy object instantiation, an ever-improving yet fully opt-in static type system with runtime validation, a JIT compiler, an amazing package ecosystem and -manager, annotation-backed deprecation, and more.