Skip to content

Incorrect behavior of ExplicitReturnNullRector #9276

@calebdw

Description

@calebdw

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/27ca355e-ce93-439a-9124-842cf791ecca

<?php

final class DemoFile
{
    public function download(Upload $file, array $headers = [])
    {
        try {
            try {
                return $this->storage->download($file, $headers);
            } catch (RemoteFileNotFoundException $e) {
                return $this->localStorage->download($file, $headers);
            }
        } catch (FileNotFoundException $e) {
            abort(404);
-       }
+       }
+       return null;
    }
}

Responsible rules

  • ExplicitReturnNullRector

Expected Behavior

Hello!

This rule is causing PHPStan to error with Unreachable statement - code above always terminates.

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