From e4fa03447be559f4c5a835d788e408c06a31ff62 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Fri, 29 Jan 2021 22:25:11 +0100 Subject: [PATCH] fix: Update behavior of Apply operation. BREAKING CHANGE: yes --- src/Operation/Apply.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Operation/Apply.php b/src/Operation/Apply.php index 72afc2ca9..28680c805 100644 --- a/src/Operation/Apply.php +++ b/src/Operation/Apply.php @@ -33,13 +33,17 @@ public function __invoke(): Closure * @psalm-return Generator */ static function (Iterator $iterator) use ($callbacks): Generator { + $continue = true; + foreach ($iterator as $key => $value) { - foreach ($callbacks as $callback) { - if (true === $callback($value, $key)) { - continue; - } + if ($continue !== false) { + foreach ($callbacks as $callback) { + if (true === $continue = $callback($value, $key)) { + continue; + } - break; + $continue = false; + } } yield $key => $value;