-
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
Rector 0.10 #134
Rector 0.10 #134
Conversation
# Conflicts: # .editorconfig # composer.json # config/drupal-8/drupal-8.0-deprecations.yml
Also adds PHPStan workflow to catch unused calls.
9cd61c9
to
b6298aa
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Found out why this is not working: we weren't analyzing any PHP files, setting the extensions is a full parameter overwrite Now we have a new failure that needs to be debugged BUT is consistent
I opened an issue for Rector that |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again, @mglaman.
Testing steps I used:
- Use the Drupal Rector Sandbox (which uses DDEV)
- Add your branch within local /drupal-rector
- Update the composer dependencies,
composer update palantirnet/drupal-rector -W
- Copy
rector.php
into the project root - Run Drupal Rector,
vendor/bin/rector process web/modules/custom/rector_examples --dry-run
(HAS SINCE BEEN RESOLVED) Got the error:
PHP Fatal error: Declaration of RectorPrefix20210420\Symfony\Component\DependencyInjection\ServiceLocator::has(string $id) must be compatible with RectorPrefix20210420\Psr\Container\ContainerInterface::has($id) in /Users/dan/Sites/drupal-rector-sandbox/vendor/rector/rector-prefixed/vendor/symfony/dependency-injection/ServiceLocator.php on line 25
Fatal error: Declaration of RectorPrefix20210420\Symfony\Component\DependencyInjection\ServiceLocator::has(string $id) must be compatible with RectorPrefix20210420\Psr\Container\ContainerInterface::has($id) in /Users/dan/Sites/drupal-rector-sandbox/vendor/rector/rector-prefixed/vendor/symfony/dependency-injection/ServiceLocator.php on line 25
Going to keep looking over the code for readability, etc.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP review. Have to jump on a call.
Overall this makes a lot of sense to me.
I left a few comments about developer experience.
I think the automated tests, Github Actions / Behat need to be reviewed. The Behat tests can likely be completely removed since they were replaced and the Github Actions jobs need to be consistent and we may be able to remove some of them if they are no longer needed.
I may be able to take a closer look at this later, but I wanted to post in-progress comments in case it's helpful.
Thanks again.
/** | ||
* @file | ||
* | ||
* This fixes Drupal testing namespace autoloading and PHPUnit compatibility. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ It's been a while and I'm not too familiar with all the specifics if we need updates down the road.
Can you comment on the places that were modified?
$parameters->set(Option::IMPORT_SHORT_CLASSES, false); | ||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false); | ||
|
||
$parameters->set('drupal_rector_notices_as_comments', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developer experience: Can we restore / replace comments?
People are expected to make small changes to this file and the comments may be helpful for common use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damontgomery actually this keeps comments. Commits like this fixed commenting, it was one of the first regressions found: 02c49a5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mglaman, sorry, this was a bad place to add my question / suggestion. :(.
I meant the comments like # This will add comments to call out edge cases in replacements.
in https://github.com/palantirnet/drupal-rector/blob/master/rector.yml.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for testing @shaal. I'm ok with pinning the release if you want for now. We've had to do that before. Downgraded with That works well! Can we update the README with directions on running PhpUnit locally now that that's a requirement for maintainers? This process from the Github Actions job seems to work, but I get errors.
0.10.9 version error:
0.10.6 error:
I've tried this within a Drupal Rector Sandbox install and with the repo by itself from my host machine.
Any thoughts on what I should try instead? Seen any of these errors? They seem weird since |
This comment has been minimized.
This comment has been minimized.
Try to be clear about copy & paste steps. We could share jobs, but these run faster. Removed Behat mentions since we aren't using it. Updated the local composer.json repository config to add names and split it up to be easier to read.
These are included directly in Github Actions.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@damontgomery Here's my go and providing feedback
Previously, with older versions of PHPStan, the original "point at this folder and autoload" worked OK. That broke. I copied over methods from phpstan-drupal. Once this merges, I'm actually making a new package called drupal-static-autoloader which drupal-rector, phpstan-drupal, and even the Psalm plugin can use. drupal-phpunit-bootstrap-file.php is used to register test namespaces and work around bug sin traits. It's a big topic to explain, it's covered in previous streams. But this blog helps explain:
I'd like to keep it open, but at a floating patch release. They fixed the regression fairly fast. |
Thanks for the comments @mglaman . I haven't dug into the details of the PhpUnit configuration, etc, but I think if it becomes an issues we can reference your comment in this PR. |
I added some commits to https://github.com/palantirnet/drupal-rector/tree/rector-0.10. I have tried adding your fork as a remote a few times and it doesn't let me push. 🤷. 2 remaining issues for me.
The codebase needs a copy of Drupal to run. PhpUnit has added that as a fixture. I'm fine using that copy to run functional tests, but I can't get them to work. We were previously running the Behat tests from within our Drupal Rector Sandbox... which now will have two copies of Drupal in it. :(. In addition to having Drupal / Rector available to use, the sandbox also makes it easy to develop with Rector using XDebug and I don't want to lose that feature.
Produces this error:
I think we are close and I'm not sure the best path forward. Maybe a call / discussion. I understand the feeling of urgency that this is a big change and blocks future work. However, I really don't want to lose features and I don't want to institute a brittle system that requires a lot of knowledge of other systems to maintain. This is currently in a state where I personally cannot use the tool as well without the things I mentioned. As we delve deeper into the PhpUnit space, it seems like we have made a lot of hacks to get PhpUnit tests to work with Rector and this seems like potentially a brittle system to me. I worry that we moved away from a fairly simple system with the sandbox / Behat functional tests towards one that only you can currently debug and work on. I feel like its just a matter of time that future versions of Rector or changes to PhpUnit or Drupal core will break this setup and we'll need to reconcile all those pieces to fix it. |
I've got a handful of errands to take care of and I'll read this tomorrow. All of the work was necessary to get it running. PHPUnit? Maybe not. But it made my velocity possible. If this PR is unsatisfactory or a different approach is desired (stay on Rector 0.7) I'm fine closing the PR and moving on |
It's probably bug in php-parser. We have the same in Rector now. Locking to php-parser |
I would try to bump Rector to |
Thanks, @TomasVotruba. This has a dev dependency on If I remove
|
That's your local dependency, not related to Rector. I would just add the package to have it: composer require symfony/console |
Thanks for the feedback @TomasVotruba & @mglaman. Apologies again if I've caused any stress the past few days / weeks. I've opened #144 which includes all the work I could verify. As commented there, I think PhpUnit support, PhpStan, and the other developer tools Matt has added are a good direction, particularly based on what Matt has said about them being helpful. I can't verify them right now and I may not have a lot of time to debug my issues with the tools until next week. These could all be issues with my local setup and additional testing from the community is greatly appreciated. Thanks again. |
I'm just closing this. PHPUnit was added to make testing possible, because Behat just ran Bash commands and I couldn't run it locally. PHPStan was added to catch some bugs that cropped up with the upgrade. Rector prefixed is a dependency, but rector/rector is dev so we can use test classes. I'm fine with the minimal. But I've spent too much time fighting the upgrade that I'll be stepping away |
@KarinG and @joeparsons I believe you tested this PR at DrupalCon, can you help test #144 as well, that is a simplified version of this so should be similar :) Thanks a lot! |
Fixes #133
Fixes #135
Remaining items
src/Plugin/WebformElement/WebformLikert
crashed PHPStan's doc parser (This should be a follow up, it's not a Rector or this package bug)Required follow ups
These are issues that need a fast follows once we merge this PR, otherwise the PR will just grow and grow and grow.
How to test
Add fork to your Drupal 8 site (assuming Composer build) composer.json
Require it
Configure it
Run it!
Test it on your own code
OR Grab the examples
Verify it!
Notes
Takes #122 commits and updates to 0.10