public function __invoke($args = [], $self = null)
{
if ($this->_closures !== null) {
if (isset($this->_closures[$this->_returnIndex])) {
$closure = $this->_closures[$this->_returnIndex++];
} else {
$closure = end($this->_closures);
}
if (is_string($self)) {
$closure = $closure->bindTo(null, $self);
} elseif ($self) {
$closure = $closure->bindTo($self, get_class($self));
}
$this->_return = call_user_func_array($closure, $args);
} elseif ($this->_returns && array_key_exists($this->_returnIndex, $this->_returns)) {
$this->_return = $this->_returns[$this->_returnIndex++];
} else {
$this->_return = $this->_returns ? end($this->_returns) : null;
}
return $this->_return;
}