Skip to content

Commit

Permalink
Resolve itemType outside the closure (#49137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored Nov 27, 2023
1 parent 9337c0e commit cc374af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ public function value($key, $default = null)
*/
public function ensure($type)
{
return $this->each(function ($item) use ($type) {
$itemType = get_debug_type($item);
$allowedTypes = is_array($type) ? $type : [$type];

$allowedTypes = is_array($type) ? $type : [$type];
return $this->each(function ($item) use ($allowedTypes) {
$itemType = get_debug_type($item);

foreach ($allowedTypes as $allowedType) {
if ($itemType === $allowedType || $item instanceof $allowedType) {
Expand Down

0 comments on commit cc374af

Please sign in to comment.