rectorphp / rector-phpunit

Rector upgrade rules for PHPUnit
http://getrector.com
MIT License
62 stars 47 forks source link

Add ProphecyPHPDocRector rule #114

Closed alexander-schranz closed 1 year ago

alexander-schranz commented 1 year ago

fixes #83

This rule update the Mock PHPDoc correctly:

class MyClassTest extends TestCase {
    /**
     * @var MyClass
     */
    private $my;

    /**
     * @var ObjectProphecy
     */
    private $my2;

    public function setUp(): void
    {
         $this->my = $this->prophesize(MyClass::class);
         $this->my2 = $this->prophesize(MyClass::class);
    }
}

it depends on the call of $this->prophesize:

class MyClassTest extends TestCase {
    /**
     * @var ObjectProphecy<MyClass>
     */
    private $my;

    /**
     * @var ObjectProphecy<MyClass>
     */
    private $my2;

    public function setUp(): void
    {
         $this->my = $this->prophesize(MyClass::class);
         $this->my2 = $this->prophesize(MyClass::class);
    }
}

Also ObjectProphecy|MyClass is upgraded to ObjectProphecy<MyClass> or other false typehints.

TomasVotruba commented 1 year ago

Thanks 👍 seems almost finished 🎉

Do you need help with PHPStan or can you handle it?

TomasVotruba commented 1 year ago

I've cherry picked your rule and fixed the PHPStan errors here: https://github.com/rectorphp/rector-phpunit/pull/115

I made many small commits, so you can see how the rule can re-use existing helper methods.

TomasVotruba commented 1 year ago

Thank you for your work :+1: :clap:

alexander-schranz commented 1 year ago

@TomasVotruba Thx for fixing the open issues 👍

TomasVotruba commented 1 year ago

👍