1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 12:47:39 +02:00

Add support for consumed generators in NormalizerFormatter, fixes #838

This commit is contained in:
Jordi Boggiano
2016-09-29 09:29:30 +02:00
parent 6bf91fa40a
commit 7f135e9ed0

View File

@@ -74,6 +74,10 @@ class NormalizerFormatter implements FormatterInterface
$normalized = array();
$count = 1;
if ($data instanceof \Generator && !$data->valid()) {
return array('...' => 'Generator is already consumed, aborting');
}
foreach ($data as $key => $value) {
if ($count++ >= 1000) {
$normalized['...'] = 'Over 1000 items, aborting normalization';