Eloquent\Phony\Stub\StubData::forwards PHP Метод

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

Add an answer that calls the wrapped callback.
public forwards ( Arguments | array $arguments = [], boolean | null $prefixSelf = null, boolean $suffixArgumentsObject = false, boolean $suffixArguments = true )
$arguments Eloquent\Phony\Call\Arguments | array The arguments.
$prefixSelf boolean | null True if the self value should be prefixed.
$suffixArgumentsObject boolean True if the arguments object should be appended.
$suffixArguments boolean True if the arguments should be appended individually.
    public function forwards($arguments = array(), $prefixSelf = null, $suffixArgumentsObject = false, $suffixArguments = true)
    {
        if (null === $prefixSelf) {
            if ($this->callback instanceof WrappedCustomMethod) {
                $parameters = $this->invocableInspector->callbackReflector($this->callback->customCallback())->getParameters();
            } else {
                $parameters = $this->invocableInspector->callbackReflector($this->callback)->getParameters();
            }
            $prefixSelf = $parameters && 'phonySelf' === $parameters[0]->getName();
        }
        $invoker = $this->invoker;
        $callback = $this->callback;
        if (!$arguments instanceof Arguments) {
            $arguments = new Arguments($arguments);
        }
        return $this->doesWith(function ($self, $incoming) use($invoker, $callback, $arguments, $prefixSelf, $suffixArgumentsObject, $suffixArguments) {
            $request = new CallRequest($callback, $arguments, $prefixSelf, $suffixArgumentsObject, $suffixArguments);
            $finalArguments = $request->finalArguments($self, $incoming);
            return $invoker->callWith($callback, $finalArguments);
        }, array(), true, true, false);
    }