framework icon indicating copy to clipboard operation
framework copied to clipboard

add support for BackedEnums to Arr helper

Open macbookandrew opened this issue 1 year ago • 2 comments

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.

macbookandrew avatar Oct 18 '24 17:10 macbookandrew

Why not supporting unit enums as well?

henzeb avatar Oct 18 '24 21:10 henzeb

@macbookandrew what do you think about adding support Enums for https://laravel.com/docs/11.x/validation#complex-conditional-validation ?

siarheipashkevich avatar Oct 19 '24 08:10 siarheipashkevich

Why not supporting unit enums as well?

Done

macbookandrew avatar Oct 21 '24 13:10 macbookandrew

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!

taylorotwell avatar Oct 21 '24 14:10 taylorotwell