Skip to content

[5.8] Fix collections with JsonSerializable items and mixed values#29205

Merged
taylorotwell merged 1 commit intolaravel:5.8from
staudenmeir:collection
Jul 18, 2019
Merged

[5.8] Fix collections with JsonSerializable items and mixed values#29205
taylorotwell merged 1 commit intolaravel:5.8from
staudenmeir:collection

Conversation

@staudenmeir
Copy link
Copy Markdown
Contributor

#11739 added support for collections with JsonSerializable items.

It only considered cases where jsonSerialize() returns an array, but the method can return mixed values.

If it does, you end up with an invalid collection where $items is not an array:

collect(new Carbon);

// expected
Collection { ▼
  #items: array:1 [▼
    0 => "2019-07-17T16:24:29.660974Z"
  ]
}

// actual
Collection { ▼
  #items: "2019-07-17T16:24:29.660974Z"
}

Fixes #29187.

@taylorotwell taylorotwell merged commit 7e9a7c6 into laravel:5.8 Jul 18, 2019
@staudenmeir staudenmeir deleted the collection branch July 18, 2019 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with collections

3 participants