Kahlan\Plugin\Stub\Method::__invoke PHP Метод

__invoke() публичный Метод

Runs the stub.
public __invoke ( array $args = [], string $self = null ) : mixed
$args array The call arguments array.
$self string The context from which the stub need to be executed.
Результат mixed The returned stub result.
    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;
    }