Closed carlos-granados closed 2 weeks ago
The cache itself is a rather complicated topic.
If possible I think it would be best to re-use as much from PHPStan as possible instead of re-implementing
Closing per https://github.com/rectorphp/rector-src/pull/6256#issuecomment-2312160243
Thanks for understanding :pray:
Feature Request
Currently, if we are using the cache, Rector will only process the files that have changed or which are not cached. But there may be dependent files of these files which Rector will not analyse and Rector might have found changes for these files if it analysed them. Rector should analyse any dependent files of any non cached file for completeness, to make sure it has handled all possible changes.
One example, suppose we have these two classes:
and
If we run Rector with the
NumericReturnTypeFromStrictReturnsRector
rule it will add this change to the second file:If we run rector again using the cache, it will not find any more changes to apply because it will only process the
DependencyClass.php
file. But if we had run Rector without the cache it would have found a new change for theDependentClass.php
file:If Rector had processed the dependent classes for any class that is not cached, this second change would have been detected and Rector would have been able to process a complete set of changes
This is currently causing issues in our setup. We run Rector locally using the cache and we run it until no more changes are applied. Then in CI Rector is run without a cache and it may find changes that have not been incorporated, forcing us to modify the pull request and re-run all the tests again, which is expensive in time and resources
I think I have an idea of how this could be implemented using PHPStan's
DependencyResolver
, if you agree this is a good feature, I can give it a go