From d41d601701b37be18c341a1d9a41dd9374151381 Mon Sep 17 00:00:00 2001 From: Daniel Pickering Date: Wed, 10 Feb 2016 23:14:07 +1300 Subject: [PATCH 1/2] 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' ``` --- model/ArrayList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ArrayList.php b/model/ArrayList.php index 8fed45df7..0f8756459 100644 --- a/model/ArrayList.php +++ b/model/ArrayList.php @@ -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); From 9f95c76e5b803b5550a575ec97a6a8c799042b67 Mon Sep 17 00:00:00 2001 From: Daniel Pickering Date: Thu, 11 Feb 2016 08:19:29 +1300 Subject: [PATCH 2/2] Update ArrayList.php --- model/ArrayList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ArrayList.php b/model/ArrayList.php index 0f8756459..c9625bd95 100644 --- a/model/ArrayList.php +++ b/model/ArrayList.php @@ -548,7 +548,7 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta )); } - $output = self::create(); + $output = static::create(); foreach($this as $item) { if(call_user_func($callback, $item, $this)) $output->push($item);