-
-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore autoload and includes #4330
Comments
Hi Anna, thanks for reaching out. What exactly technically does "not care about autoloading or includes"? Could you share some minimal PHP snippet example what should be skipped/ignored? |
As I said, those are really complex projects and it's always a different problem. I can try and come up with a few examples from the last few projects. I can imagine that it could be a config saying "don't try to autoload classes when you encounter them". Most of the changes that I need to do are localized and don't need cross-file inspection. |
I see. We could use static reflection from PHPStan: https://phpstan.org/blog/zero-config-analysis-with-static-reflection |
This honestly sounds like a total game-changer. I'll try to write a few test cases. |
👍 Here are some basic steps: #3490 |
Hello @TomasVotruba, is static reflection in any workable shape with rector ? Following the link you gave we didn't really understand if it was underway or if we need to activate some flag to be able to use it. |
Hi @Driky, there is no integration yet. We need a contributor who would add such a feature. |
Here are two scenarios. For both, I added the following to the phpstan.neon file at the root of the project: parameters:
featureToggles:
disableRuntimeReflectionProvider: true and this class in <?php
namespace App;
class MyClass extends ParentClass
{
public function MyClass()
{
}
} If I don't have any autoloading configured in rector.yaml or composer.json, I get this error:
Already, this is weird because how can it not find the class when it's right there in the file mentioned in the same error message. If I do have autoloading configured, which in most projects requires several days, I get this error:
Some classes will just not be available. Some of them are in library folders residing on the server and not par of the repo, some have to be autogenerated using a dev environment that we don't have, etc. Most of my changes are very localized and I don't want to be blocked by missing parents and such. This is pretty much what happens in every single project. |
The feature toggle in |
@TomasVotruba Two questions:
|
|
Right now, we're just catching the generic exception and complaining about rector/src/Application/RectorApplication.php Line 243 in c4cedab
|
|
@TomasVotruba I don't know enough about how Rector indexes the analyzed symbols to answer that. I will need to read a lot more code to have a mental model of that particular process. We can perhaps catch |
rectorphp/rector-src@0d2d1e3 [StaticTypeMapper] Remove parent attribute on StaticTypeMapper (#4330)
Feature Request
I'm wondering how feasible it is to make Rector not care about autoloading or includes.
I can't use it on the majority of my legacy projects. They were built pre-composer, routinely contain 1M+ LOC, have hundreds of libs loaded ten different ways that aren't really known upfront, missing entire folders from the repo, etc. My most recent project had 4M LOC. This makes autoloading so complex that it would not be practical to try and reverse-engineer it for Rector's purposes. We're talking days of effort per project, which usually eats up more time than the tool would save.
If it wasn't for the autoloading and include_path issues, I would have used Rector a lot more often. Right now, I use it maybe once every few months, despite needing it every single day. It's painful to brute-force changes that I know for a fact can be automated with Rector. Any way to make this easier?
The text was updated successfully, but these errors were encountered: