Skip to content

replace php constant index to named index #8279

Closed Answered by samsonasik
rakucmr asked this question in Q&A
Discussion options

You must be logged in to vote

I think you can create custom rule for that, as creating rule for core is too risky for core:

  • You need to ensure all constants loaded via $rectorConfig->bootstrapFiles(), ensure that it actually not a constant
  • then, change the ArrayDimFetch, if its dim is a ConstFetch that not exists via :
if ($this->reflectionProvider->hasConstant(new Name($constantName), $scope)) {

If not, change to string, you can check rector's SensitiveConstantNameRector which change to case sensitive constant name instead:

if ($this->reflectionProvider->hasConstant(new Name($constantName), $scope)) {
return

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by samsonasik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants