-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[8.x] Move contracts #32506
[8.x] Move contracts #32506
Conversation
It doesn't really makes sense that Enumerable is also array accesible or has anything to do with JSON manipulations. These interfaces should be defined on the implementing class. It does makes sense however to keep Countable and IteratorAggregate as we're still talking about collections here. But we shouldn't force people to also implement ArrayAccess or also any JSON contracts.
b006f6d
to
ad73e65
Compare
Is this about semantics, or does it have an actual benefit to some user out there?
|
That's a different discussion atm. This is the bare minimum that I did with the current contracts. We did the exact same thing for the container a while back because the container shouldn't be worried with being a way for people to use it as an array, just like collections here.
That's not really an argument I think because if so then the entire purpose of a contract in the first place is defeated. Using the Enumerable contract with the bare minimum features allows to let us use it in the internals and not exploit any user-land syntactic sugar (which array access is here if we have to be honest).
In which situation do you need this? Ps. appreciating the feedback! |
Why is that? Having the contract means that, as I said before, I can use the contract's type-hint and accept either collection type.
How does removing stuff from the contract help with that? No one is forcing us to use anything in the internals!? I feel like I'm missing something here.
Frankly, in every situation. If I don't need specific methods only available on the In fact, if we could reverse the clock, I would default to using lazy collections everywhere (like C# does with LINQ, where even a none-lazy list becomes lazy as soon as you call additional methods on it). But that ship has sailed.
Always the gentleman 🥰 |
@JosephSilber you made some good arguments against this. I'm closing this 👍 |
Since that sentiment was not applied to Eloquent Builder & Query Builder, I'm dying to get PHP 8 so that I can start using Union Type as a workaround for the lack of interface there. |
It doesn't really makes sense that Enumerable is also array accesible or has anything to do with JSON manipulations. These interfaces should be defined on the implementing class.
It does makes sense however to keep Countable and IteratorAggregate as we're still talking about collections here. But we shouldn't force people to also implement ArrayAccess or also any JSON contracts.
Doing this on 8.x with the new collections component is a good moment to do this.
@JosephSilber does this seem reasonable to you?