Value listing

Both Pure Enums and Backed Enums implement an internal interface named UnitEnum. UnitEnum includes a static method cases(). cases() returns a packed array of all defined Cases in the order of declaration.

<?php

Suit
::cases();
// Produces: [Suit::Hearts, Suit::Diamonds, Suit::Clubs, Suit::Spades]
?>

Manually defining a cases() method on an Enum will result in a fatal error.

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top