public function returnArg($arg_num = 1)
    {
        $arg_num = $this->assertValidArgNum($arg_num);

        $fqn = $this->function_name->fullyQualifiedName();

        \Patchwork\redefine($fqn, function (...$args) use ($fqn, $arg_num) {
            if ( ! array_key_exists($arg_num - 1, $args)) {
                $count = count($args);
                throw new Exception\InvalidArgumentForStub(
                    "{$fqn} was called with {$count} params, can't return argument \"{$arg_num}\"."
                );
            }

            return $args[$arg_num - 1];
        });
        $this->assertRedefined($fqn);
    }
public function returnArg($arg_num = 1)
    {
        $arg_num = $this->assertValidArgNum($arg_num);

        $fqn = $this->function_name->fullyQualifiedName();

        \Patchwork\redefine($fqn, function (...$args) use ($fqn, $arg_num) {
            if ( ! array_key_exists($arg_num - 1, $args)) {
                $count = count($args);
                throw new Exception\InvalidArgumentForStub(
                    "{$fqn} was called with {$count} params, can't return argument \"{$arg_num}\"."
                );
            }

            return $args[$arg_num - 1];
        });
        $this->assertRedefined($fqn);
    }
public function returnArg ( $ arg_num = 1 ) { $ arg_num = $ this -> assertValidArgNum ( $ arg_num ) ; $ fqn = $ this -> function_name -> fullyQualifiedName ( ) ; \ Patchwork \ redefine ( $ fqn , function ( ... $ args ) use ( $ fqn , $ arg_num ) { if ( ! array_key_exists ( $ arg_num - 1 , $ args ) ) { $ count = count ( $ args ) ; throw new Exception \ InvalidArgumentForStub ( "{$fqn} was called with {$count} params, can't return argument \"{$arg_num}\"." ) ; } return $ args [ $ arg_num - 1 ] ; } ) ; $ this -> assertRedefined ( $ fqn ) ; }
Redefine target function making it return one of the received arguments, the first by
default. Redefined function will throw an exception if the function does not receive desired
argument.

@param int $arg_num The position (1-based) of the argument to return
Redefine target function making it return one of the received arguments the first by default . Redefined function will throw an exception if the function does not receive desired argument .