Adds support for Prophecy autocompletion when referencing a property, argument variable or method return type. Requirement is though, that property, method parameter or method return type are type hinted properly via PHP DocBlocks.
Examples:
Property
class FooTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Prophecy\Prophecy\ObjectProphecy|\Bar
*/
private $bar;
/**
* @var \Foo
*/
private $foo;
protected function setUp()
{
$this->bar = $this->prophesize(\Bar::class);
$this->foo = new \Foo($this->bar->reveal());
}
public function testDoSomething()
{
$this->bar->foo()->willReturn('foo');
$this->assertSame('foo', $this->foo->doSomething());
}
}
Argument
class EvaNovaTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Foo
*/
private $foo;
protected function setUp()
{
$this->foo = new \Foo();
}
public function testDoSomething()
{
$bar = $this->prophesize(\Bar::class);
$this->doSomething($bar);
}
/**
* @param \Prophecy\Prophecy\ObjectProphecy|\Bar $bar
*/
private function doSomething($bar)
{
$bar->foo()->willReturn('foo');
$this->assertSame('foo', $this->foo->doSomething($bar->reveal()));
}
}
Method return type
class FooTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Foo
*/
private $foo;
protected function setUp()
{
$this->foo = new \Foo();
}
public function testDoSomething()
{
$bar = $this->createBar();
$bar->foo()->willReturn('foo');
$this->assertSame('foo', $this->foo->doSomething($bar->reveal()));
}
/**
* @return \Prophecy\Prophecy\ObjectProphecy|\Bar
*/
private function createBar()
{
return $this->prophesize(\Bar::class);
}
}
Closes #20
Adds support for Prophecy autocompletion when referencing a property, argument variable or method return type. Requirement is though, that property, method parameter or method return type are type hinted properly via PHP DocBlocks.
Examples:
Property
Argument
Method return type