{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/1576","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/1576/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/1576/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/1576/events","html_url":"https://github.com/doctrine/doctrine2/pull/1576","id":120059998,"number":1576,"title":"Chained selectable matching","user":{"login":"fabiocarneiro","id":1375034,"avatar_url":"https://avatars.githubusercontent.com/u/1375034?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiocarneiro","html_url":"https://github.com/fabiocarneiro","followers_url":"https://api.github.com/users/fabiocarneiro/followers","following_url":"https://api.github.com/users/fabiocarneiro/following{/other_user}","gists_url":"https://api.github.com/users/fabiocarneiro/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiocarneiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiocarneiro/subscriptions","organizations_url":"https://api.github.com/users/fabiocarneiro/orgs","repos_url":"https://api.github.com/users/fabiocarneiro/repos","events_url":"https://api.github.com/users/fabiocarneiro/events{/privacy}","received_events_url":"https://api.github.com/users/fabiocarneiro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-02T23:32:17Z","updated_at":"2015-12-29T16:40:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/doctrine/doctrine2/pulls/1576","html_url":"https://github.com/doctrine/doctrine2/pull/1576","diff_url":"https://github.com/doctrine/doctrine2/pull/1576.diff","patch_url":"https://github.com/doctrine/doctrine2/pull/1576.patch"},"body":"The purpose is to make it possible to do selectable matching keeping the ***lazy behavior***, aggregating the criterias until the collection is initialized(used)\r\n\r\n```php\r\n$selectable->matching(Criteria::create())->matching(Criteria::create())->matching(Criteria::create());\r\n```\r\nThe current behavior get the results as soon as you call the matching, and it forces us to build the full criteria before calling matching, however, if this change is approved it will do the query only when the selectable is in fact used (any other method)\r\n\r\nPS: I ended up in this solution because the second call to matching (which should filter it on ArrayCollection) was giving me a collection with results I didn't expect to see, and that probably means that there is some sort of issue with ArrayCollection matching, but maybe I am missing something.\r\n\r\n*I also would like some advice in the `$this->any()` on the tests. I did it  to make sure that the cloned mock will receive the same value provided in the original one, but I couldn't use `$this->once()`, because it would fail in the original mock.*"},"comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments/167827362","html_url":"https://github.com/doctrine/doctrine2/pull/1576#issuecomment-167827362","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/1576","id":167827362,"user":{"login":"asm89","id":657357,"avatar_url":"https://avatars.githubusercontent.com/u/657357?v=3","gravatar_id":"","url":"https://api.github.com/users/asm89","html_url":"https://github.com/asm89","followers_url":"https://api.github.com/users/asm89/followers","following_url":"https://api.github.com/users/asm89/following{/other_user}","gists_url":"https://api.github.com/users/asm89/gists{/gist_id}","starred_url":"https://api.github.com/users/asm89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asm89/subscriptions","organizations_url":"https://api.github.com/users/asm89/orgs","repos_url":"https://api.github.com/users/asm89/repos","events_url":"https://api.github.com/users/asm89/events{/privacy}","received_events_url":"https://api.github.com/users/asm89/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T16:40:30Z","updated_at":"2015-12-29T16:40:30Z","body":"> PS: I ended up in this solution because the second call to matching (which should filter it on ArrayCollection) was giving me a collection with results I didn't expect to see, and that probably means that there is some sort of issue with ArrayCollection matching, but maybe I am missing something.\r\n\r\nThat sounds pretty bad. Can you provide a reproducing test case that shows the behavior?"}}