Giter Club home page Giter Club logo

Comments (3)

samsonasik avatar samsonasik commented on July 17, 2024 1

I see, reopen then.

from rector.

samsonasik avatar samsonasik commented on July 17, 2024

That is expected, if no return in root last stmt, then add return null, except on finally, you specify return as well, see https://getrector.com/demo/a9aa21cf-63ad-4593-9d43-5e9328ebcc38

You can skip the rule if that not what you want https://getrector.com/documentation/ignoring-rules-or-paths

from rector.

KorDum avatar KorDum commented on July 17, 2024

@samsonasik
This is incorrect behaviour, see example:

final class ExampleTest extends UnitTestCase
{
    public function testExample(): void
    {
        $result = $this->example();

        $this->assertSame(1, $result); // Failed asserting that null is identical to 1.
    }

    private function example()
    {
        try {
            return 1;
        } finally {
            return null;
        }
    }
}

Rector changes the behavior of the code, making it incorrect.

If we do as the rector suggests initially, we get errors from static analyzers. They say that this line of code will never be executed. And they are right:

try {
    return 1;
} finally {
    // do something
}

// unreachable statement
return null;

Yeah, I turned off the rule. But its incorrect behavior will result in nobody using it.

from rector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.