Skip to content

Commit

Permalink
Possible bug: in factory dont call toArray on Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-redfern committed Jun 26, 2018
1 parent 592b93b commit 82cf33c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

2018-06-26
----------

* added `ExportableInterface` (thanks to @Garethp)
* possible bug: in Collection factory, Collection used toArray now uses all() to get contents

2018-06-14
----------

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ Nested arrays are automatically converted to new Collections when accessed.
This Collection does not allow adding duplicate values in the Collection. They can be set
on create, but calls to `add()` or `offsetSet()` will ignore the value.

As of 2.2.0 an interface has been added `ExportableInterface` allowing `toArray` to cascade transform
sub-objects contained within a Collection.

### Available Methods

#### Factory Methods
Expand Down
2 changes: 2 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static function convertToArray($var, $deep = false)
if (is_object($var)) {
if ($var instanceof \stdClass) {
$var = (array)$var;
} elseif ($var instanceof Collection) {
$var = $var->all();
} elseif ($var instanceof \Iterator) { // @codeCoverageIgnore
$var = iterator_to_array($var);
} elseif ($var instanceof \ArrayObject) { // @codeCoverageIgnore
Expand Down

0 comments on commit 82cf33c

Please sign in to comment.