pennant icon indicating copy to clipboard operation
pennant copied to clipboard

Using multiple scopes across features disables use of `all()` and `values()`

Open joshrainwater opened this issue 7 months ago • 3 comments

My project requires scoping features across multiple different models. Quick example:

Feature::define('beta-design', function(Team $team)...)
Feature::define('password', function(User $user)...)

When I configure this a Service provider, all calls to all() or values() functions throw 500 errors with incorrect parameter types. A call to Feature::for($user)->all() also throws errors.

I think my ideal in this situation would be instead to return a list of all features under the current model type scope, rather than throwing an error and checking them. The other alternative would be to return false for all features that are not under the scope of the model being tested. So either Feature::all() would not return any value for beta-design in this case, or it would return false.

I am happy to code this up and add a Reflection into PendingScopedFeatureInteraction (or drivers, if that makes more sense) but wanted to confirm which expected behavior seems better. Either way, I don't like working with a system where both of these functions are completely disabled.

joshrainwater avatar Jul 17 '24 17:07 joshrainwater