Comments (3)
I see, reopen then.
from rector.
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.
@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)
- Incorrect behavior of RemoveAlwaysTrueIfConditionRector HOT 1
- Tests failing with PHPStan 1.11.x-dev HOT 1
- Typos HOT 1
- Incorrect behavior of ExplicitReturnNullRector
- Rule to rewrite `$arr['idx'] += $value` to `$arr['idx'] = ($arr['idx'] ?? null) + $value` to avoid Undefined index error HOT 4
- Upgrade each method inside a while loop to foreach HOT 1
- JSON output formatter outputs invalid JSON HOT 2
- Incorrect behavior of AddArrowFunctionReturnTypeRector
- Mysql to Mysqli migration rector HOT 1
- Incorrect behavior of AssertCompareToSpecificMethodRector HOT 1
- Incorrect behaviour of FirstClassCallableRector with __invoke HOT 3
- Incorrect behavior of RemoveAlwaysTrueIfConditionRector and RemoveDeadInstanceOfRector
- RenameClass not working HOT 2
- Incorrect behavior of NullToStrictStringFuncCallArgRector HOT 1
- some are files not processed HOT 1
- Call to a member function mapToPhpParserNode() on null HOT 2
- turn private properties into private constants HOT 1
- Incorrect behavior of NullToStrictStringFuncCallArgRector
- [ERROR] Could not process due to "System error: "Undefined constant "RepoName\Shell\CONSTANT_NAME"" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rector.