pestphp / drift

[WIP] Command-line tool to migrate your PHPUnit tests to Pest
https://pestphp.com/docs/guides/drift
MIT License
28 stars 7 forks source link

[Rector] Remove $this #4

Closed olivernybroe closed 4 years ago

olivernybroe commented 4 years ago

Create a new rector which is responsible for removing $this on methods that doesn't need them.

it('asserts true is true', function () {
    $this->assertTrue(true);

    // Same as
    assertTrue(true);
});

The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.

Pest docs

owenvoke commented 4 years ago

I guess this is no longer relevant in v0.3 of Pest. 🤔

The expect() API is now preferred (although the Global Assertions does exist as a polyfill). Obviously the functions are also still available directly in PHPUnit under the PHPUnit\Framework\* namespace.

olivernybroe commented 4 years ago

@owenvoke So you are thinking we should have a rector that converts to the expect api?

owenvoke commented 4 years ago

Probably not as it doesn't map 1 to 1 with existing assertions. But could do for some of them. 🤷🏻 I was more saying that this issue probably isn't really necessary now.

olivernybroe commented 4 years ago

Alright, let's close it then 👍