rector icon indicating copy to clipboard operation
rector copied to clipboard

Incorrect behavior of AssertCompareToSpecificMethodRector

Open jlherren opened this issue 1 year ago • 1 comments

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).

jlherren avatar Apr 10 '24 12:04 jlherren

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.

samsonasik avatar Apr 11 '24 15:04 samsonasik

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

TomasVotruba avatar Jun 22 '24 02:06 TomasVotruba