I want to iterate over enum:
enum Shapes
{
case RECTANGLE;
case SQUARE;
case CIRCLE;
case OVAL;
}
I get Shapes
const not defined if I do this:
foreach (Shapes as $shape) { }
The best solution I came with is to manually create array for enum:
$shapes = [
Shapes::RECTANGLE,
Shapes::SQUARE,
Shapes::CIRCLE,
Shapes::OVAL,
];
foreach ($shapes as $shape) { }
Is there any better way to iterate over the enum?