-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7775Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.2.14 or last dev-main @ rectorphp/rector-src@d1ff945 |
| Installed as | composer dependency or demo |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/ce545fab-575f-41f4-b901-a5467ac4ace2
<?php
declare(strict_types=1);
/** @throws Exception */
function get_body(): string {
static $i = 0;
var_dump($i);
return $i++ === 0 ? "foo" : throw new Exception("Failed to get body");
}
foreach ([1, 2, 3] as $value) {
try {
$body = null;
$body = get_body();
var_dump($body);
} catch (Exception) {
var_dump($body);
}
}Responsible rules
RemoveDoubleAssignRector
Expected Behavior
It should not remove the null assignment since that changes program behaviour:
string(3) "foo"
string(3) "foo"
string(3) "foo"instead of the expected:
string(3) "foo"
NULL
NULLCheers, and Happy Holidays!