I would like to be able to pass enums to functions. I know PHP doesn't support them per se, but there are instances where an enum would make sense.
For instance, take:
function doPayment($payment_method = 'paypal')
{ // ... code goes here }
You can call it via doPayment('paypal'), doPayment(), doPayment('creditcard'), or doPayment('creditcadr');
This introduces the chance of typos plus it's a pain to keep strings consistent and to debug. We could pass them as ints such as doPayment(2) but that's ugly and we'd have to keep track of them or put them in defines, which is the next example: doPayment(PAYMENT_METHOD_PAYPAL); but then we'd have to put the define in some global file that is accessible by all. Also I find that you end up with a class of hundreds of defines and it's hard to keep track of what belongs to what.
Meanwhile in Java, it's easy:
doPayment(PaymentClass.PaymentMethod.PayPal); // or doPayment(PaymentMethod.PayPal);
That's really what I'm looking for if possible. I guess I could create an external class for each set of enums but that adds a lot of files as well (while the Java example you can create an enum within the parent class).
I was wondering if Laravel has added a method to do this, if it's not doable in PHP.