-
Notifications
You must be signed in to change notification settings - Fork 63
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
Prohibit Rector from making Closures static #102
Comments
Links to rules: https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#staticclosurerector I'm open to something like this. Can you provide an example of where this has caused an issue? |
Oof, I don't think I have seen it not give problems. So.. I suppose it is always when you do something with Laravel Eloquent Models inside a closure? I think I've read Rector (?similar tool?) removing most of the automatic to static conversions in a recent or upcoming update. |
@driftingly @peterfox The rules mentioned above are part of sets in the core Rector repo, the Php 70, and the Coding Style sets. I found this old issue which probably has the same problem rectorphp/rector#8087. Their solution is to skip the rule for a file or the entire project. Digging deeper, there are these two rules (
For that reason, I suggest we skip these two rules in the Readme of the project and/or add a section with suggestions on rules to avoid in general. What do you think? |
Funnily enough, this is something I've already looked into a little recently and PHPStan will soon be able to detect when this is happening so actually, we'd just need to check for the param. phpstan/phpstan#9302 (reply in thread) I agree though that there shouldn't be any rules we write in this repo that make the closures static. That's for other rules to do the transformation. |
Since Laravel tends to depend on lots of behind the scene magic, using static on calls to functions and closures tends not give what you want. Rector should not introduce these things.
I propose adding these somewhere sensible (maybe to all the LARAVEL_number and LARAVEL_CODE_QUALITY):
The text was updated successfully, but these errors were encountered: