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
Rector should not modify the code. This issue is not related to a specific rector version. Instead it depends on the phpstan version used.
I was able to trace this down to a change introduces in phpstan version 1.10.49. And specifically this PR: phpstan/phpstan-src#2778
The problem is basically that rector has changed the return type from a VoidType to NullType which is an instance of ConstantType which then leads to this unexpected refactor.
But I think this is a problem of the TernaryFalseExpressionToIfRector in general. Because if method b has null as return type instead of void it happens regardless of the phpstan version used, which is wrong too: https://getrector.com/demo/5d99559b-c987-4e15-9ae8-c44fd2d33023
In my opinion, the rector should never perform a refactor if the else of the Ternary operator is a function call.
The text was updated successfully, but these errors were encountered:
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/66f82535-275a-4804-bdbe-cc6b10f9cabc
Responsible rules
TernaryFalseExpressionToIfRector
Expected Behavior
Rector should not modify the code. This issue is not related to a specific rector version. Instead it depends on the phpstan version used.
I was able to trace this down to a change introduces in phpstan version 1.10.49. And specifically this PR: phpstan/phpstan-src#2778
The problem is basically that rector has changed the return type from a
VoidType
toNullType
which is an instance ofConstantType
which then leads to this unexpected refactor.But I think this is a problem of the
TernaryFalseExpressionToIfRector
in general. Because if methodb
hasnull
as return type instead ofvoid
it happens regardless of the phpstan version used, which is wrong too: https://getrector.com/demo/5d99559b-c987-4e15-9ae8-c44fd2d33023In my opinion, the rector should never perform a refactor if the
else
of theTernary
operator is a function call.The text was updated successfully, but these errors were encountered: