Rector: UnderscoreToPascalCaseVariableAndPropertyNameRector trying to rename mysqli_result properties

Created on 12 Jun 2020  路  4Comments  路  Source: rectorphp/rector

Bug Report

| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | v0.7.33 |
| Installed as | composer dependency |

The rector is trying to rename the properties of a built-in PHP object

-        return $result->num_rows;
+        return $result->numRows;

Minimal PHP Code Causing Issue

function reproduceBug(mysqli_result $result): int {
        return $result->num_rows;
}

Expected Behaviour

This rector should leave the built-in PHP objects alone

bug

Most helpful comment

All 4 comments

Hi,

could yo uprovide minimal failing demo, so we can replicate the issue?
https://getrector.org/demo

Same issue for me too. I'm using CakePHP framework, so when we retrieve the data it returns instance of \Cake\ORM\Entity which includes table rows(which is underscored as db column should be underscored not PascalCase/camelCase) as a property name.

It's good if we separate this one rule into two separate rules like:
1. Rector\CodingStyle\Rector\Variable\UnderscoreToPascalCaseVariableRector
2. Rector\CodingStyle\Rector\Variable\UnderscoreToPascalCasePropertyNameRector

So we have option to enable/disable the rules according to code base.

I see this discussion is already going on in #3436.

Closing as duplicated of #3436

Was this page helpful?
0 / 5 - 0 ratings