
PHP Enums From the Query String: tryFrom() vs from()
You add ?status=paid filtering to an endpoint, write Status::from($_GET['status']), and it works....
Oct 17, 20264 min read0 reactions2 comments
Tag archive

You add ?status=paid filtering to an endpoint, write Status::from($_GET['status']), and it works....

Most PHP enums stop at cases() and from(). Six more methods replace whole helper classes: labels, transitions, factories, state machines.

PHP 8.1 Enums: Backed Enums and Laravel Eloquent Casts PHP enums landed in version 8.1,...
I could not agree more with Brent when he says concerning the "new in initializers"[1] feature: PHP...
enum Status { case draft; case published; case archived; public function color():...
TL;DR The basic and backed enums of this RFC are a nice implementation of enums in PHP, bu...