Modern PHP’s Reuse of Keywords

· Alan Storm · Nov. 8, 2021, 1:40 p.m.
Summary
I was looking at some of the new features that are coming to PHP 8.1 and I saw enums were on the list. I also saw that PHP’s continuing its pattern of reusing keywords in different contexts to mean different things. An enum in PHP 8.1 looks like this enum Status { case DRAFT; case PUBLISHED; case ARCHIVED; } That’s the case keyword reused. Normally, case is used in a switch statment. switch($foo) { case 'bar': // do something if $foo = 'bar' break; } However, if used inside an enum, case means s...
AUTHOR