Rector is a powerful tool for automated code refactoring and upgrades. Among its many features, it can enforce coding standards and apply fixes across your entire codebase.
One setting I find particularly useful is ->withTreatClassesAsFinal().
When enabled, Rector analyzes your code as if all classes were declared final, even when they're not.
return RectorConfig::configure()
->withTreatClassesAsFinal();
There's a whole debate about whether classes should be final by default.
I'll sidestep that.
But this setting helps Rector in a very useful and specific way.
It tells Rector to assume your classes won't be extended and this lets it make smarter decisions about method visibility and inheritance.
You get the stricter analysis without actually committing to final in your code.
Here to help,
Aaron
P.S. Want help configuring Rector or improving other parts of your codebase? Schedule a code review and we'll dig in together.