replace php constant index to named index #8279
-
In php 4, and php 5 a constant if not found is automatically converted to string so a code like this is ok:
is equivalent to
How to use rector to convert these types of indexes to work correctly in php 7 / 8? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think you can create custom rule for that, as creating rule for core is too risky for core:
if ($this->reflectionProvider->hasConstant(new Name($constantName), $scope)) { If not, change to string, you can check rector's rector/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php Lines 78 to 80 in ae4c0b7 and create custom rule based on your needs. |
Beta Was this translation helpful? Give feedback.
I think you can create custom rule for that, as creating rule for core is too risky for core:
$rectorConfig->bootstrapFiles()
, ensure that it actually not a constantIf not, change to string, you can check rector's
SensitiveConstantNameRector
which change to case sensitive constant name instead:rector/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php
Lines 78 to 80 in ae4c0b7