Skip to content

Commit cc374af

Browse files
authored
Resolve itemType outside the closure (#49137)
1 parent 9337c0e commit cc374af

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ public function value($key, $default = null)
328328
*/
329329
public function ensure($type)
330330
{
331-
return $this->each(function ($item) use ($type) {
332-
$itemType = get_debug_type($item);
331+
$allowedTypes = is_array($type) ? $type : [$type];
333332

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

336336
foreach ($allowedTypes as $allowedType) {
337337
if ($itemType === $allowedType || $item instanceof $allowedType) {

0 commit comments

Comments
 (0)