Skip to content
Advertisement

Tag: enums

Generic enum type in php

How can I specify an argument type to take any enum value? Something like function processEnum(enum $value) would be ideal, however nothing seems to exist? Additionally it would be nice to separate backed vs non-backed enums or additionally backed types; enums that are backed as strings for example. Answer All enums implement the UnitEnum interface, and backed enums (those with

User Redirection accordingly an enum input. PHP code

I’m trying to redirect the logged-in user to a different page according to the enum input was stored at db. I was trying those lines, but it always redirects me at pro.php. How can I do this with the right way? What is the issue with the code? Here is my table definition: # Name Type Null Default 1 id

Type hinting with enumerations?

I’ve read here about enumarations and their “implementation” PHP and Enumerations point is, why use enums, when not for type hinting? but this implementation does not allow use for type hinting. Because the enum entries are all strings. is there a way I can say $a must be ‘foo’, ‘bar’ or ‘baz’ in PHP? I use phpstorm/intellij so if there

Advertisement