-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[9.x] Universal HigherOrderWhenProxy #37632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[9.x] Universal HigherOrderWhenProxy #37632
Conversation
JosephSilber
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great 👍
Was actually my first thought when I saw the new Conditionable trait.
My only gripe is that it feels weird having this now-totally-generic HigherOrderWhenProxy living under the Collections package, but I don't have a better solution ATM.
|
@inxilpro this PR seems to have coupled the Support component to the Collections component again because Conditionable is now used in the Collections component. We splitted the Collections out of the Support package for the exact reason to never do this. We'll either need to revert this PR or think of a way to do the conditionable features from this PR differently. |
|
Hm. Give me a bit to see if I can come up with something. |
|
Can't |
Yeah, that would work. See my comment on #38389 — the only issue is that it doesn't exactly "belong" in the collections package, since it's more general than that, but moving it into that package is the simplest solution. |
|
Would it be possible to execute the tests for each package in isolation? That could help noticing such hidden dependencies more quickly. 🤔 |
This PR picks up the work in #37504 and #37561 to unify the behavior of
when()andunless()across every implementation by:HigherOrderWhenProxyto support any proxied object, not justEnumerablesHigherOrderWhenProxyin theConditionabletraitwhen()andunless()inEnumeratesValueswithConditionableIt's necessary to implement these changes in
9.xbecause:when()method onEnumerableand thewhen()method onConditionable(related to type hints)HigherOrderWhenProxy::__constructneeds to be changed slightly to allow for any type of proxied objectEnumeratesValues::whenwas not defaulted to$thislike it is inConditionableI want to call out that third item because it is a subtle change.
In Laravel
8.x, the following code will returnnull. After this PR, the same code will return theCollectionwith"c"appended to it. I think that is preferable, and means thatwhen()behaves the same way everywhere in the framework.