You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to investigate the issue and as far as I can tell what happens is:
Rector applies the rules and on this first run the Command:SUCCESS expression (a ClassConstantFetch node) has the property class equal to "Symfony\Component\Console\Command\Command". The ConsoleExecuteReturnIntRector correctly identifies the type of this expression as an integer and does not change the code
The post rectors are applied and the NameImportingPostRector rector is called. This changes the class property of this expression to Command
Since there were changes applied, the rector rules are applied again. On this second run, when the ConsoleExecuteReturnIntRector rector tries to identify the type of the expression, since the node does not have the FQN, the getType() function in the MutatingScope returns an ErrorType and, since this is not an int, the (int) cast is added
I tried to figure out a solution but was unable to decide how to go about adding one, hope all these details can help someone else decide how to tackle this
Note: there needs to be another rector rule that changes this file for these erroneous changes to show, could be any rule, I used RemoveUnusedPrivatePropertyRector but any other that changes the file will do. Seems that if the only rector to change the file is ConsoleExecuteReturnIntRector then these changes are not applied
The text was updated successfully, but these errors were encountered:
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/753c3d4f-c1c8-4e40-aa91-96a739734d7e
Responsible rules
ConsoleExecuteReturnIntRector
Expected Behavior
Rector changes the line
to
And it shouldn't
I have tried to investigate the issue and as far as I can tell what happens is:
Command:SUCCESS
expression (aClassConstantFetch
node) has the propertyclass
equal to "Symfony\Component\Console\Command\Command". TheConsoleExecuteReturnIntRector
correctly identifies the type of this expression as an integer and does not change the codeNameImportingPostRector
rector is called. This changes theclass
property of this expression toCommand
ConsoleExecuteReturnIntRector
rector tries to identify the type of the expression, since the node does not have the FQN, thegetType()
function in theMutatingScope
returns anErrorType
and, since this is not an int, the(int)
cast is addedI tried to figure out a solution but was unable to decide how to go about adding one, hope all these details can help someone else decide how to tackle this
Note: there needs to be another rector rule that changes this file for these erroneous changes to show, could be any rule, I used
RemoveUnusedPrivatePropertyRector
but any other that changes the file will do. Seems that if the only rector to change the file isConsoleExecuteReturnIntRector
then these changes are not appliedThe text was updated successfully, but these errors were encountered: