mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 05:07:36 +02:00
Add support for consumed generators in NormalizerFormatter, fixes #838
This commit is contained in:
@@ -74,6 +74,10 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
$normalized = array();
|
$normalized = array();
|
||||||
|
|
||||||
$count = 1;
|
$count = 1;
|
||||||
|
if ($data instanceof \Generator && !$data->valid()) {
|
||||||
|
return array('...' => 'Generator is already consumed, aborting');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if ($count++ >= 1000) {
|
if ($count++ >= 1000) {
|
||||||
$normalized['...'] = 'Over 1000 items, aborting normalization';
|
$normalized['...'] = 'Over 1000 items, aborting normalization';
|
||||||
|
Reference in New Issue
Block a user