-
-
Notifications
You must be signed in to change notification settings - Fork 737
Description
Bug Report
| Subject | Details |
|---|---|
| PHP Versions | 7.4 and 8.1 at least |
| Rector Version | 0.12.13 |
| Execution | Global |
Using the tool globally causes unexpected differences in behavior. Documented examples include:
- Errors during verbose output ([Parallel]: Class was not found while trying to analyse it #6903 (comment))
- Differing detection of parent class methods (Exempt tests from parent rule codeigniter4/devkit#8 (comment))
The docs contain a single buried reference to global execution (https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#call-command-with--a-option) stating it is "not recommended as autoload may overlapped".
Minimal PHP Code Causing Issue
See example repo with steps to reproduce at https://github.com/MGatner/rector-error.
Expected Behaviour
Two options in my mind:
- Global and local execution should result in identical results. The likely resolution is for
autoloadProjectAutoloaderFile()to be made more robust at detecting the correct autoload file (see Ensure autoloader is loaded in globally installed Rector rector-src#1683, but even better) - Remove support for global execution, or make one of the workarounds (https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#dealing-with-class--was-not-found-while-trying-to-analyse-it) mandatory. Rector should not "guess" at an autoload during global execution. This unannounced behavior is the source of the very confusing behavior noted above.
I have a strong preference for option 1). I believe static analysis tools that are not actual dependency should not be declared as such. That said, I don't have time to learn the Rector codebase to implement this solution, nor the institutional knowledge to declare it "best for the project".
I do not want to influence the decision about what is best, but should the team decide to go with option 1) I put forth a $40 bounty on its execution to go toward supporting this project.
References
- Initial resolution attempt: Ensure autoloader is loaded in globally installed Rector rector-src#1683
- Reversion of the first attempt: Revert load vendor/autoload from getcwd and add documentation for using globally (not recommended) rector-src#1685
- Repo demonstrating Problem 1: https://github.com/MGatner/rector-error
- Repo/conversation demonstrating Problem 2: Exempt tests from parent rule codeigniter4/devkit#8
- Tagging @PhilETaylor