-
Notifications
You must be signed in to change notification settings - Fork 74
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
WIP: Fix phpstan issues #226
Conversation
Some of these will be... interesting. Anyways; this might be relevant: https://phpstan.org/blog/preprocessing-ast-for-custom-rules |
Some notes
|
I simply don't follow how to replace these calls: https://github.com/search?q=repo%3Arectorphp%2Frector-src+findParentType()&type=commits |
For LinkGeneratorTraitLRector:
The findParentType probably needs to use reflection on the method, then ask reflection the class and from there continue to find the traits. Unfortunately there are no tests, and no example. I think this might be because it needed a stub. |
Same logic for |
Seems logic is actually a little different, it might need to change de Node\Expr to make sure you can get the class the expression lives in. Not completely sure without actually debugging the output :P |
I took this as far as I could today. Here's the error on phpunit:
This likely means that we are passing the wrong var to the method:
|
Ok, comments thing broke because of this: https://github.com/rectorphp/rector/releases/tag/0.17.3 0.17.2 is not broken. (perhaps its time for some matrix tests on last x releases or something xD) And i think because of this: rectorphp/rector-src#4463 Now it cannot resolve the parent we change in the comment. So basically, we wither need a personal base which loads that connector if possible, or we have to change the one using comments to always require the node that is worked on to be the Stmt. Then we can add comments. So i guess, choose your poison ;) Thats all the help i can give right now. |
One thing I discovered: the current way we attach comments, php-parser ends up treating them as
The comments end up on |
Found more in php-parser PrettyPrinterAbstract: if ($comments !== $origComments) {
if ($comments) {
$result .= $this->pComments($comments) . $this->nl;
} The current way comments are added, as previously stated have them treated as original comments. That means |
My thought was to:
We cannot register PostRectors. They are hardcoded in I also tried changing a rule to listen for |
Here's an example with checking against the root rexpression: https://github.com/palantirnet/drupal-rector/compare/stan-fails...mglaman:drupal-rector:parent-traverse-fix?expand=1 |
listen for expression if needing to add comment
… you are working in the rector. Therefor, a comment should always be passed an Expression.
… methods for working with assignements
This reverts commit 0813381.
This reverts commit 0c4acd2.
This reverts commit 331bc38.
…etup-ddev > We have moved here: > https://github.com/ddev/github-action-setup-ddev > Please update your usages: > uses: ddev/github-action-setup-ddev@v1
Refactor last rectors to work with stmt's
Wooo! Getting there <3 |
I think we should close this in favor of #238 which is a cleaned up version with also less changes. :) |
Description
Explain the technical implementation of the work done.
To Test
Drupal.org issue
Provide a link to the issue from https://www.drupal.org/project/rector/issues. If no issue exists, please create one and link to this PR.