analogueorm / analogue

Analogue ORM : Data Mapper ORM for Laravel/PHP
MIT License
632 stars 51 forks source link

CollectionProxy does not implement some Collection methods correctly #235

Closed michaelsadlon closed 6 years ago

michaelsadlon commented 6 years ago

I was working on upgrading to 5.5 and ran into some issues with the CollectionProxy. To be exact I upgraded analogue/orm from 5.4.0 to 5.5.18.

Specifically:

Creating a new Collection from the CollectionProxy and then calling the above methods works as expected.

In the case of random passing in null will emulate the correct behavior since that is the default value in the base Collection random method. The contains method I think just needs to pass the arguments correctly.

There may be other methods with issues. I did not extensively test them all.

RemiCollin commented 6 years ago

Found the issue. Some of base Collection class methods use func_num_args() to change their behavior when some optional arguments are omitted, mostly to handle passing a callback as an argument to methods like contains().

That means we just cannot pass blindly all arguments to the parent class, but use the same approach to call the parent method with exactly what the method was called.

RemiCollin commented 6 years ago

Fixed : https://github.com/analogueorm/analogue/commit/ef5e537df170f62bcd9d97ddd78033d797f07b58