RFC: Shall we remove the Craftzing\Laravel\Contracts\Ability
interface
#5
Replies: 1 comment 1 reply
-
My first thoughts were something along the lines of this:
but this already happens in
I'm not sure what to vote at the moment. What else could the alternative be to not having the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While I get why the
Craftzing\Laravel\Contracts\Ability
interface was added (and I would probably have done so myself), I feel like forcing it within the loosely-typed nature of theGate
API kinda worsten the DX.Because the
Gate
API is loosely-typed,Craftzing\Laravel\Contracts\Ability::granted()
has to use amixed
type for the$user
argument in its method signature. And lead devs to either rely on docblocks or manual type checks in their code to ensure the actual type:I believe the DX may be better if we were to implement it without an interface as I proposed on the original PR to Laravel: laravel/framework#53729. Allowing devs to rely on proper argument type checks for me outweights the contract that is provided by the interface.
2 votes ·
Beta Was this translation helpful? Give feedback.
All reactions