[MinimalScope] Add ChangeLocalPropertyToVariableRector#2558
[MinimalScope] Add ChangeLocalPropertyToVariableRector#2558TomasVotruba merged 1 commit intomasterfrom
Conversation
4e813de to
3af1dbf
Compare
3af1dbf to
268480b
Compare
| class SomeClass | ||
| { | ||
| private $count; | ||
| public function run() |
There was a problem hiding this comment.
Wouldnt the rector fail when the method e.g. looks like
public function run()
{
If ($this->count == 5) {
$this->count = 10;
return $this->count;
}
$this->count = 5;
return $this->count;
}There was a problem hiding this comment.
I guess the logic will change because of the rector.
In case it gets transformed into
public function run()
{
If ($count == 5) {
$count = 10;
return $count;
}
$count = 5;
return $count;
}The method will return different values when invoked 2 times in a row
There was a problem hiding this comment.
The method will return different values when invoked 2 times in a row
I see. That's what I was missing.
How would you change the rule to make it work in these cases?
There was a problem hiding this comment.
I guess it could work when you made sure that there is only a single property-write (or zero)
There was a problem hiding this comment.
That sounds clear, I'll add fixture for that. Thanks for spotting this 👍
There was a problem hiding this comment.
It might needs full new service to analyze scope in the future. Let's see how it handles reality now
rectorphp/rector-src@2907687 Fix @return on StaticDoctrineAnnotationParser::resolveAnnotationValue() (#2558)
Closes #1900