src/Stub/StubData.php
public function returns(...$values): Stub
    {
        if (empty($values)) {
            $callback = $this->callback;
            $invocableInspector = $this->invocableInspector;
            $emptyValueFactory = $this->emptyValueFactory;

            $value = null;
            $valueIsSet = false;

            return $this->doesWith(
                function () use (
                    &$value,
                    &$valueIsSet,
                    $callback,
                    $invocableInspector,
                    $emptyValueFactory
                ) {
                    if (!$valueIsSet) {
                        if (
                            $type = $invocableInspector
                                ->callbackReturnType($callback)
                        ) {
                            try {
                                $value = $emptyValueFactory->fromType($type);
                            } catch (FinalClassException $e){
                                throw new FinalReturnTypeException(
                                    $this->exporter->exportCallable($callback),
                                    strval($type),
                                    $e
                                );
                            }
                        } else {
                            $value = null;
                        }

                        $valueIsSet = true;
                    }

                    return $value;
                },
                [],
                false,
                false,
                false
            );
        }

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

            $this->doesWith(
                function () use ($value) {
                    return $value;
                },
                [],
                false,
                false,
                false
            );
        }

        return $this;
    }
public function returns(...$values): Stub
    {
        if (empty($values)) {
            $callback = $this->callback;
            $invocableInspector = $this->invocableInspector;
            $emptyValueFactory = $this->emptyValueFactory;

            $value = null;
            $valueIsSet = false;

            return $this->doesWith(
                function () use (
                    &$value,
                    &$valueIsSet,
                    $callback,
                    $invocableInspector,
                    $emptyValueFactory
                ) {
                    if (!$valueIsSet) {
                        if (
                            $type = $invocableInspector
                                ->callbackReturnType($callback)
                        ) {
                            try {
                                $value = $emptyValueFactory->fromType($type);
                            } catch (FinalClassException $e){
                                throw new FinalReturnTypeException(
                                    $this->exporter->exportCallable($callback),
                                    strval($type),
                                    $e
                                );
                            }
                        } else {
                            $value = null;
                        }

                        $valueIsSet = true;
                    }

                    return $value;
                },
                [],
                false,
                false,
                false
            );
        }

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

            $this->doesWith(
                function () use ($value) {
                    return $value;
                },
                [],
                false,
                false,
                false
            );
        }

        return $this;
    }
public function returns ( ... $ values ) : Stub { if ( empty ( $ values ) ) { $ callback = $ this -> callback ; $ invocableInspector = $ this -> invocableInspector ; $ emptyValueFactory = $ this -> emptyValueFactory ; $ value = null ; $ valueIsSet = false ; return $ this -> doesWith ( function ( ) use ( & $ value , & $ valueIsSet , $ callback , $ invocableInspector , $ emptyValueFactory ) { if ( ! $ valueIsSet ) { if ( $ type = $ invocableInspector -> callbackReturnType ( $ callback ) ) { try { $ value = $ emptyValueFactory -> fromType ( $ type ) ; } catch ( FinalClassException $ e ) { throw new FinalReturnTypeException ( $ this -> exporter -> exportCallable ( $ callback ) , strval ( $ type ) , $ e ) ; } } else { $ value = null ; } $ valueIsSet = true ; } return $ value ; } , [ ] , false , false , false ) ; } foreach ( $ values as $ value ) { if ( $ value instanceof InstanceHandle ) { $ value = $ value -> get ( ) ; } $ this -> doesWith ( function ( ) use ( $ value ) { return $ value ; } , [ ] , false , false , false ) ; } return $ this ; }
Add an answer that returns a value.

Calling this method with no arguments is equivalent to calling it with a
single argument of `null`.

@param mixed ...$values The return values.

@return $this This stub.
Add an answer that returns a value .