Skip to content
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

[Scoped] Clean up bootstrap.php to load scoper autoload #2255

Closed
wants to merge 10 commits into from

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented May 7, 2022

@TomasVotruba @ondrejmirtes this PR cleanup bootstrap.php from scoped version of rector. In rector.php, I modified the sort autoload as follow:

  1. Include preload.php and constant first for PHP-Parser Node definitions and internal PHP constants.
  2. project autoload
  3. prefixed autoload
  4. global autoload
  5. command line autoload

prefixed autoload is included in bootstrap.php

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@ondrejmirtes
Copy link
Contributor

I don’t understand how can this work if there’s no autoload section in the target repository composer.json. How do I autoload Rector classes for example when running unit tests of custom Rectors or when analysing custom Rectors with PHPStan?

@samsonasik
Copy link
Member Author

@ondrejmirtes how about the bootstrap.php exists, but changed with:

# ensure only loaded once
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/scoper-autoload.php';

@samsonasik samsonasik changed the title [Scoped] Completely Remove bootstrap.php [Scoped] Clean up bootstrap.php to load scoper autoload May 7, 2022
@samsonasik
Copy link
Member Author

@ondrejmirtes I rolled back bootstrap.php, with updated to load prefixed vendor/autoload.php and vendor/scoper-autoload.php, do you think that will works?

@samsonasik
Copy link
Member Author

Ok, with above change, and running scoper script and it cause error in my local dev:


verify scoped rector with specify PHP72_BIN_PATH env

                                                                                                                        
 [ERROR] Class 'Symplify\SmartFileSystem\SmartFileInfo' not found                                                       
                                                                                                                        

@samsonasik samsonasik marked this pull request as draft May 7, 2022 13:04
@samsonasik
Copy link
Member Author

It seems broke the scoper when I run the full_build.sh, I am closing for now.

@ondrejmirtes feel free to create separate PR if you have better solution. To verify locally for updated code, you can run the following script:

export PHP72_BIN_PATH=/opt/homebrew/Cellar/php@7.2/7.2.34_4/bin/php PHP80_BIN_PATH=/opt/homebrew/Cellar/php@8.0/8.0.17/bin/php && sh ./full_build.sh

Update PHP72_BIN_PATH and PHP80_BIN_PATH with your local dev php location.

I am closing for now ;)

@samsonasik samsonasik closed this May 7, 2022
@samsonasik samsonasik deleted the completely-remove-bootstrap branch May 7, 2022 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants