Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior of AssertCompareToSpecificMethodRector #8593

Closed
jlherren opened this issue Apr 10, 2024 · 2 comments · Fixed by rectorphp/rector-phpunit#337
Closed

Incorrect behavior of AssertCompareToSpecificMethodRector #8593

jlherren opened this issue Apr 10, 2024 · 2 comments · Fixed by rectorphp/rector-phpunit#337
Labels

Comments

@jlherren
Copy link

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 jlherren added the bug label Apr 10, 2024
@samsonasik
Copy link
Member

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.

@TomasVotruba
Copy link
Member

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: rectorphp/rector-phpunit#337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants