-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add compatibility with Doctrine Collection interface #51
Comments
If your goal is to have a Doctrine Collection compatible interface, why not use that package instead? What would be the point if having the same interface as a different package? |
@shadowhand because there are no strictly typed collections in Doctrine package (no classes like AbstractCollection or AbstractMap) and we have to implement this intermediate logic in our projects. I like this library and I think it is good example of OOP. |
A trait would be a reasonable approach, if the maintainers think this is a good idea. |
I would be open to accepting a trait to make it compatible with Doctrine. |
@strider2038, the best way is to create your own class Collection (inherit it from Ramsey\Collection\AbstractCollection) and add the necessary methods to it. |
+1 to this! |
I noticed some incompatibilities between this library and |
It seems like Doctrine has reasons to only accept @ramsey would you be up for tightening the type for 3.0? |
Is your feature request related to a problem? Please describe.
On our projects we use strictly typed collections for Doctrine. I think it will be nice if AbstractCollection class can implement methods from Doctrine Collection interface.
Describe the solution you'd like
I suggest to add methods to AbstractCollection and/or AbstractArray that will be compatible with Collection
public function removeElement($element)
public function containsKey($key)
public function get($key)
public function getKeys()
public function getValues()
public function set($key, $value)
public function key()
public function current()
public function next()
public function exists(Closure $p)
public function forAll(Closure $p)
public function partition(Closure $p)
public function indexOf($element)
public function slice($offset, $length = null)
Then user of the library can do something like this.
Describe alternatives you've considered
Maybe better approach is to add a trait?
The text was updated successfully, but these errors were encountered: