Replies: 1 comment 6 replies
-
Hi, As the complexity of rules grows, some of the rules might overlap. Yet, this doesn't seem like a bug, but rather 2 rules doing some work together. If you figure out a fix to make them unique and separate, please send PR 👍 |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Quite new using Rector and still finding my feet. In general it does seem awesome. But running it on a code base of ~10 years old is, well, overwhelming. So, as seems to be the general advice, I'm applying rule by rule and checking / validating the results (does it do anything unexpected, possibly introduce bugs, etc).
At the moment I'm checking the results of adding
ReturnTypeFromStrictScalarReturnExprRector
, but there are more changes then I would have assumed / expected.See for example: https://getrector.com/demo/24d86086-9520-4c46-9569-3f25b7b5083f
With only
ReturnTypeFromStrictScalarReturnExprRector
enabled I wouldn't expect that this code would add a return type tobar()
Personally I would expect that with
ReturnTypeFromStrictScalarReturnExprRector
enabled it would only add return types when the return is a literal value. The result I'm currently getting would, from my expectations, only be possible when also having rules named likeReturnTypeFromStrictParamRector
,ReturnTypeFromStrictTypedCallRector
andReturnTypeFromStrictTernaryRector
enabled. As this code returns a value based on a ternary which then involves both a typed method call and a typed parameter, and not (/never) a literal value.Do mind that I find it awesome that Rector is able to do this. But it's not what I expected to happen when enabling just this rule. And it makes it harder to review the changes made.
Furthermore it makes me wonder what the other mentioned rules like
ReturnTypeFromStrictParamRector
,ReturnTypeFromStrictTypedCallRector
andReturnTypeFromStrictTernaryRector
will do, as the things I would expect them to do based on the name, are already involved by theReturnTypeFromStrictScalarReturnExprRector
rule. This is also confirmed by for example using the example for ReturnTypeFromStrictTernaryRector in the demo withReturnTypeFromStrictScalarReturnExprRector
, the result is identical 😄So I'm not sure whether this would be a lack of understanding on my end (/having different expectations based on the name), possibly oversimplified documentation (which then creates the misunderstanding) or maybe even a "bug" in that it does (way) more then it was intended to.
Beta Was this translation helpful? Give feedback.
All reactions