Changeset View
Changeset View
Standalone View
Standalone View
src/utils/PhutilCallbackFilterIterator.php
Show All 12 Lines | final class PhutilCallbackFilterIterator extends FilterIterator { | ||||
public function __construct(Iterator $iterator, $callback) { | public function __construct(Iterator $iterator, $callback) { | ||||
parent::__construct($iterator); | parent::__construct($iterator); | ||||
if (!is_callable($callback)) { | if (!is_callable($callback)) { | ||||
throw new Exception(pht('Callback must be callable.')); | throw new Exception(pht('Callback must be callable.')); | ||||
} | } | ||||
$this->callback = $callback; | $this->callback = $callback; | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function accept() { | public function accept() { | ||||
return call_user_func($this->callback, $this->current()); | return call_user_func($this->callback, $this->current()); | ||||
} | } | ||||
} | } |