Incorrect behavior of AssertCompareToSpecificMethodRector
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/a2c93c41-3204-4ef7-ace6-e8d03300c6ca
<?php
use PHPUnit\Framework\TestCase;
final class DemoFile extends TestCase {
private function testSomething($handle) {
self::assertSame('resource', gettype($handle));
}
}
Responsible rules
-
AssertCompareToSpecificMethodRector
Expected Behavior
Rector changes the code to use assertInternalType(), but this method has been deprecated in PHPUnit 8 and removed in PHPUnit 9.
Rector should transform code to the the new assert methods (also see the assertions about closed resources).
I think the rule is fine, it just need another rule to change deprecated assertInternal* under phpunit80 config set, set continuation change will apply based on version applied.
Thanks for reporting!
Looking at PHPUnit change back and forth, I think the best way is to skip gettype() as it would work only for a year :)
Fixed in: https://github.com/rectorphp/rector-phpunit/pull/337