Skip to content

Commit 11b8235

Browse files
committed
Add the 3v4l reproducer of a non-redundant zero assignment to the test
https://3v4l.org/GiSbY: `$f === 0.0` holds for -0.0, yet `$f = 0.0` in that branch changes what `echo $f` prints from "-0" to "0".
1 parent 5be8ab0 commit 11b8235

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/DeadCode/data/unused-variable-redundant-signed-zero.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,14 @@ function repeatedPositiveZeroIsNotReportedEither(): void
8383
$x = 0.0;
8484
sink($x);
8585
}
86+
87+
// https://3v4l.org/GiSbY
88+
function h(): void {
89+
$f = -0.0;
90+
var_dump($f === 0.0); // bool(true)
91+
echo $f, "\n"; // -0
92+
if ($f === 0.0) {
93+
$f = 0.0; // not redundant: turns -0.0 into 0.0
94+
}
95+
echo $f, "\n"; // 0
96+
}

0 commit comments

Comments
 (0)