Mark Selectable::matching as a mutation free - #124
Conversation
It returns a new collection by contract: https://github.com/doctrine/collections/blob/1.6.x/lib/Doctrine/Common/Collections/Selectable.php#L24
|
Note: I don't know Doctrine enough so I may ask stupid questions :) Is the creation of a new Collection necessarily mutable-free (if so, should Collection::__construct be flagged as mutation-free)? Does it clone the provided Collection maybe? |
Collection interface doesn't specify any requirements for realizations' constructor. The only implementation Doctrine has is ArrayCollection, which takes an array. It doesn't clone deeply array values, so if it's an array of objects, objects will be copied by ref. |
It returns a new collection by the contract:
https://github.com/doctrine/collections/blob/1.6.x/lib/Doctrine/Common/Collections/Selectable.php#L24