Skip to content

WillReturnCallbackFallbackToReturnFalseRector adds dead code after exception or method with return never #9931

Closed
rectorphp/rector-phpunit
#801

Description

@biozshock

Bug Report

First, thank you for the tool.

The rule does not check if the callback has an exception or has a method that has return never. In that case Rector should not add any modifications.

Subject Details
Rector version e.g. v2.7.0 (invoke vendor/bin/rector --version)

Minimal PHP Code Causing Issue

https://getrector.com/demo/41c4e548-46df-4121-bd92-41f7b7157660

or even

https://getrector.com/demo/50d4e374-fb02-4848-bc82-ff1bad5755b7

Expected Behaviour

Rector does nothing.

Activity

  1. changed the title [-]WillReturnCallbackFallbackToReturnFalseRector and `return never`[/-] [+]WillReturnCallbackFallbackToReturnFalseRector adds dead code after exception or method with `return never`[/+] on Oct 15, 2026
  2. TomasVotruba commented on Oct 15, 2026

    @TomasVotruba
    Member

    Thank you for reporting, that should never happen 👍

    Fixed in rectorphp/rector-phpunit#801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions