<?php/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/namespacePHPUnit\Framework\MockObject\Stub;
usePHPUnit\Framework\MockObject\Invocation;
usePHPUnit\Framework\MockObject\Stub;
/**
* Stubs a method by returning an argument that was passed to the mocked method.
*/classReturnArgumentimplementsStub{
/**
* @var int
*/private$argumentIndex;
publicfunction__construct($argumentIndex)
{
$this->argumentIndex = $argumentIndex;
}
publicfunctioninvoke(Invocation $invocation)
{
if (isset($invocation->getParameters()[$this->argumentIndex])) {
return$invocation->getParameters()[$this->argumentIndex];
}
}
publicfunctiontoString(): string{
return \sprintf('return argument #%d', $this->argumentIndex);
}
}