Ensure filterByCallback returns object of called class

This change ensures that filterByCallback returns a filtered list of the same called class, if ArrayList is extended.

The current filterByCallback always instantiates an ArrayList with the filtered results, which is probably not what you want if you extend ArrayList.


eg; currently this occurs
```
class MyArrayList extends ArrayList {
   public function sayHello() {
      return 'hi'; 
   }
}

$list = MyArrayList::create();
//populate $list here
$filtered = $list::filterByCallback($someCallback);

$filtered->sayHello();  
// -> The method 'sayHello' does not exist on 'ArrayList' 
```
This commit is contained in:
Daniel Pickering 2016-02-10 23:14:07 +13:00
parent d5b4c90cb4
commit d41d601701

View File

@ -548,7 +548,7 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta
));
}
$output = ArrayList::create();
$output = self::create();
foreach($this as $item) {
if(call_user_func($callback, $item, $this)) $output->push($item);