Source: stitcher.io

PHP Enums before PHP 8.1

Category: PHP, PHP

Scout APM helps PHP developers pinpoint N+1 queries, memory leaks & more so you can troubleshoot fast & get back to coding faster. You can read all about built-in enums in PHP 8.1 in this post. If you're looking for more information on userland implementations of enums before PHP 8.1, you can continue to read this post. If you came here looking for our enum implementation in PHP, that's this way.

Here's the problem with the myclabs/php-enum package though: by relying on __callStatic(), we lose static analysis benefits like auto completion and refactoring: As you can see in this case, your IDE is unaware of the PostsStatus::DRAFT() method.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners