Skip to content

[RemoveDeadZeroAndOneOperationRector] $float + 0 is a valid operation #9827

Description

@aschempp

Bug Report

Subject Details
Rector version 2.5.7

The RemoveDeadZeroAndOneOperationRector removes a + 0 operation assuming it has no functionality. That isn't fully true though, it converts a negative zero to a positive zero.

Minimal PHP Code Causing Issue

$value = round(-0.001, 2);
var_dump((string) $value); // output: "-0"

$value = $value + 0;
var_dump((string) $value); // output: "0"

Expected Behaviour

Not sure if it is possible to check the previous value could be a negative zero.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions