Пример #1
0
 /**
  * Add an answer that calls the wrapped callback.
  *
  * @param Arguments|array $arguments             The arguments.
  * @param bool|null       $prefixSelf            True if the self value should be prefixed.
  * @param bool            $suffixArgumentsObject True if the arguments object should be appended.
  * @param bool            $suffixArguments       True if the arguments should be appended individually.
  *
  * @return $this This stub.
  */
 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);
 }