Skip to content

Commit

Permalink
Start to replace @var with assert()
Browse files Browse the repository at this point in the history
While `@var` annotations are good for convincing static analyzers of
types, we could still encounter runtime warnings. Using assert() will
convert those warnings/notices into exceptions.

If folks like this approach I can apply it to the remaining classes in
managable chunks.
  • Loading branch information
markstory committed Oct 8, 2022
1 parent 4866330 commit 5575a99
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Iterator/MapReduce.php
Expand Up @@ -185,10 +185,11 @@ protected function _execute(): void
throw new LogicException('No reducer function was provided');
}

/** @var callable $reducer */
$reducer = $this->_reducer;
foreach ($this->_intermediate as $key => $list) {
$reducer($list, $key, $this);
if ($reducer !== null) {
foreach ($this->_intermediate as $key => $list) {
$reducer($list, $key, $this);
}
}
$this->_intermediate = [];
$this->_executed = true;
Expand Down

0 comments on commit 5575a99

Please sign in to comment.