framework
framework copied to clipboard
add support for BackedEnums to Arr helper
Similar to https://github.com/laravel/framework/pull/52677, https://github.com/laravel/framework/pull/52679, and https://github.com/laravel/framework/pull/52792, using enums improves code readability, maintainability and reduces the hassle of using string values within the code itself.
This adds BackedEnum support to the Arr methods:
Arr::get($roles, Role::ADMIN);
This PR is backward compatible and shouldn't bring any breaking changes.
Why not supporting unit enums as well?
@macbookandrew what do you think about adding support Enums for https://laravel.com/docs/11.x/validation#complex-conditional-validation ?
Why not supporting unit enums as well?
Done
Thanks for your pull request to Laravel!
Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.
If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!