3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Stubs a method by returning an argument that was passed to the mocked method.
14 * @since Class available since Release 1.0.0
16 class PHPUnit_Framework_MockObject_Stub_ReturnArgument extends PHPUnit_Framework_MockObject_Stub_Return
18 protected $argumentIndex;
20 public function __construct($argumentIndex)
22 $this->argumentIndex = $argumentIndex;
25 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
27 if (isset($invocation->parameters[$this->argumentIndex])) {
28 return $invocation->parameters[$this->argumentIndex];
34 public function toString()
36 return sprintf('return argument #%d', $this->argumentIndex);