File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -880,6 +880,10 @@ function last() {
880
880
return $ this [$ count -1 ];
881
881
}
882
882
883
+ function toArray () {
884
+ return iterator_to_array ($ this );
885
+ }
886
+
883
887
#[\ReturnTypeWillChange]
884
888
function count () {
885
889
$ this ->run_if_missing ();
Original file line number Diff line number Diff line change @@ -429,6 +429,11 @@ function test_11_scope() {
429
429
$ FirstTeenager = Person::scope ('first_teenager ' );
430
430
$ this ->assert (count ($ FirstTeenager ) === 1 );
431
431
$ this ->assert ($ FirstTeenager [0 ]->name === 'Ellie ' );
432
+
433
+ $ array = $ FirstTeenager ->toArray ();
434
+ $ this ->assert (!is_array ($ FirstTeenager ));
435
+ $ this ->assert (is_array ($ array ));
436
+ $ this ->assert ($ array [0 ]->name === 'Ellie ' );
432
437
}
433
438
434
439
// * has_many: works with scoping
You can’t perform that action at this time.
0 commit comments