Skip to content

Rector to automatically remove return type that the function never returns #9309

@calebdw

Description

@calebdw

Feature Request

Hello!

I'm trying to convert most of my classes to final, and PHPStan is starting to complain about methods that have return types that are never returned (which is a good thing):

Method <class>::definition() never returns Illuminate\\Database\\Query\\Builder so it can be removed from the return type.

However, it would be awesome if Rector could detect this as well and automatically remove it for me.

For reference, here's the PHPStan rules that detect this:

Image

Diff

-public function definition(): Builder|string
+public function definition(): string

Thanks!

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