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

RenameMethodRector / NodeTypeResolver should skip never type #8334

Closed
buffcode opened this issue Nov 30, 2023 · 0 comments · Fixed by rectorphp/rector-src#5305
Closed

RenameMethodRector / NodeTypeResolver should skip never type #8334

buffcode opened this issue Nov 30, 2023 · 0 comments · Fixed by rectorphp/rector-src#5305
Labels

Comments

@buffcode
Copy link
Contributor

Bug Report

Subject Details
Rector version 0.18.11

When PHPStan detects a never type (eg. because the parsed type-hints have no valid intersection) the checks in \Rector\NodeTypeResolver\NodeTypeResolver::isMatchingUnionType will return true and RenameMethodRector will update the method call (incorrectly).

Minimal PHP Code Causing Issue

https://getrector.com/demo/7bc8c761-d9eb-436f-ad99-29bda4016273

<?php

class DemoFile
{
    /** @var never **/
    public $messageBus;

    public function run(): void
    {
        $this->messageBus->reset();
    }
}
@@ -7,6 +7,6 @@
 
     public function run(): void
     {
-        $this->messageBus->reset();
+        $this->messageBus->clear();
     }
 }

Expected Behaviour

No update, skip never types.

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

Successfully merging a pull request may close this issue.

1 participant