Skip to content

Commit 774dedb

Browse files
authored
Merge pull request #891 from naderman/t/do-not-iterate-non-arrays
Do not iterate non-array Traversables
2 parents e94929e + 45de570 commit 774dedb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Monolog/Formatter/NormalizerFormatter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,13 @@ protected function normalize($data)
7070
return $data;
7171
}
7272

73-
if (is_array($data) || $data instanceof \Traversable) {
73+
if (is_array($data)) {
7474
$normalized = array();
7575

7676
$count = 1;
77-
if ($data instanceof \Generator && !$data->valid()) {
78-
return array('...' => 'Generator is already consumed, aborting');
79-
}
80-
8177
foreach ($data as $key => $value) {
8278
if ($count++ >= 1000) {
83-
$normalized['...'] = 'Over 1000 items ('.($data instanceof \Generator ? 'generator function' : count($data).' total').'), aborting normalization';
79+
$normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization';
8480
break;
8581
}
8682
$normalized[$key] = $this->normalize($value);

0 commit comments

Comments
 (0)