Skip to content

OrdSingleByteRector rule replaces parameter when it shouldn't #9503

@robiningelbrecht

Description

@robiningelbrecht

Bug Report

Subject Details
Rector version v2.2.8

Minimal PHP Code Causing Issue

While running rector with php8.5, I got this

    ---------- begin diff ----------
@@ @@
         while ($i < strlen($encodedPolyline) && count($points) < 2) {
             $shift = $result = 0x00;
             do {
-                $bit = ord($encodedPolyline[$i++]) - 63;
+                $bit = ord($encodedPolyline[$i++][0]) - 63;
                 $result |= ($bit & 0x1F) << $shift;
                 $shift += 5;
             } while ($bit >= 0x20);
@@ @@
         while ($i < strlen($encodedPolyline)) {
             $shift = $result = 0x00;
             do {
-                $bit = ord($encodedPolyline[$i++]) - 63;
+                $bit = ord($encodedPolyline[$i++][0]) - 63;
                 $result |= ($bit & 0x1F) << $shift;
                 $shift += 5;
             } while ($bit >= 0x20);
    ----------- end diff -----------

The $encodedPolyline[$i++] is already a single byte, no need to add an extra [0]

Weirdly enough, this does not happen on the demo instance: https://getrector.com/demo/7b48d1f0-c0f1-4bac-898b-614658e5d266

Live demo in a GitHub action of mine: https://github.com/robiningelbrecht/statistics-for-strava/actions/runs/19574398963/job/56055773761

Expected Behaviour

In this case, to not alter the code .

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions