src/Stub/Answer/Builder/GeneratorAnswerBuilder.php
public function answer(): callable
    {
        return function ($self, $arguments) {
            foreach ($this->iterations as $iteration) {
                foreach ($iteration->requests as $request) {
                    $this->invoker->callWith(
                        $request->callback(),
                        $request->finalArguments($self, $arguments)
                    );
                }

                if ($iteration instanceof GeneratorYieldFromIteration) {
                    foreach ($iteration->values as $key => $value) {
                        if ($key instanceof InstanceHandle) {
                            $key = $key->get();
                        }

                        if ($value instanceof InstanceHandle) {
                            $value = $value->get();
                        }

                        yield $key => $value;
                    }
                } else {
                    if ($iteration->hasKey) {
                        yield $iteration->key => $iteration->value;
                    } elseif ($iteration->hasValue) {
                        yield $iteration->value;
                    } else {
                        yield;
                    }
                }
            }

            foreach ($this->requests as $request) {
                $this->invoker->callWith(
                    $request->callback(),
                    $request->finalArguments($self, $arguments)
                );
            }

            if ($this->exception) {
                throw $this->exception;
            }

            if ($this->returnsSelf) {
                return $self;
            }

            if (null !== $this->returnsArgument) {
                return $arguments->get($this->returnsArgument);
            }

            return $this->returnValue;
        };
    }
public function answer(): callable
    {
        return function ($self, $arguments) {
            foreach ($this->iterations as $iteration) {
                foreach ($iteration->requests as $request) {
                    $this->invoker->callWith(
                        $request->callback(),
                        $request->finalArguments($self, $arguments)
                    );
                }

                if ($iteration instanceof GeneratorYieldFromIteration) {
                    foreach ($iteration->values as $key => $value) {
                        if ($key instanceof InstanceHandle) {
                            $key = $key->get();
                        }

                        if ($value instanceof InstanceHandle) {
                            $value = $value->get();
                        }

                        yield $key => $value;
                    }
                } else {
                    if ($iteration->hasKey) {
                        yield $iteration->key => $iteration->value;
                    } elseif ($iteration->hasValue) {
                        yield $iteration->value;
                    } else {
                        yield;
                    }
                }
            }

            foreach ($this->requests as $request) {
                $this->invoker->callWith(
                    $request->callback(),
                    $request->finalArguments($self, $arguments)
                );
            }

            if ($this->exception) {
                throw $this->exception;
            }

            if ($this->returnsSelf) {
                return $self;
            }

            if (null !== $this->returnsArgument) {
                return $arguments->get($this->returnsArgument);
            }

            return $this->returnValue;
        };
    }
public function answer ( ) : callable { return function ( $ self , $ arguments ) { foreach ( $ this -> iterations as $ iteration ) { foreach ( $ iteration -> requests as $ request ) { $ this -> invoker -> callWith ( $ request -> callback ( ) , $ request -> finalArguments ( $ self , $ arguments ) ) ; } if ( $ iteration instanceof GeneratorYieldFromIteration ) { foreach ( $ iteration -> values as $ key => $ value ) { if ( $ key instanceof InstanceHandle ) { $ key = $ key -> get ( ) ; } if ( $ value instanceof InstanceHandle ) { $ value = $ value -> get ( ) ; } yield $ key => $ value ; } } else { if ( $ iteration -> hasKey ) { yield $ iteration -> key => $ iteration -> value ; } elseif ( $ iteration -> hasValue ) { yield $ iteration -> value ; } else { yield ; } } } foreach ( $ this -> requests as $ request ) { $ this -> invoker -> callWith ( $ request -> callback ( ) , $ request -> finalArguments ( $ self , $ arguments ) ) ; } if ( $ this -> exception ) { throw $ this -> exception ; } if ( $ this -> returnsSelf ) { return $ self ; } if ( null !== $ this -> returnsArgument ) { return $ arguments -> get ( $ this -> returnsArgument ) ; } return $ this -> returnValue ; } ; }
Get the answer.

@return callable The answer.
Get the answer .