Skip to content

Add Rector rule to clean up nullsafe checks on returns that dont return null values #7781

@ghost

Description

Feature Request

With php 8 nullsafe operator was introduced more info: https://stitcher.io/blog/php-8-nullsafe-operator
I would like a rule that cleans up nullsafe checks on returns that dont return null

Diff

class HelloWorld {
    public function getString(): string
    {
         return 'hello world';
    }
}

public function get(): HelloWorld
{
     return new HelloWorld();
}

-echo $this->get()?->getHelloWorld();
+echo $this->get()->getHelloWorld();

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