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 the current object.
14 * @since Class available since Release 1.1.0
16 class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub
18 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
20 if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) {
21 throw new PHPUnit_Framework_Exception(
22 'The current object can only be returned when mocking an ' .
23 'object, not a static class.'
27 return $invocation->object;
30 public function toString()
32 return 'return the current object';