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

[Scoper] Make phpstan/phpdoc-parser part of preload.php and preload-split-package.php #2908

Merged
merged 10 commits into from
Sep 5, 2022

Conversation

samsonasik
Copy link
Member

This PR make phpstan/phpdoc-parser part of preload.php, so it loaded early by default when run rector, so no need to make part of conflict config:

    "conflict": {
-        "phpstan/phpdoc-parser": "<1.7",

@samsonasik samsonasik changed the title [Scoper] Make phpstan/phpdoc-parser part of preload.php [Scoper] Make phpstan/phpdoc-parser part of preload.php and preload-split-package.php Sep 4, 2022
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba
Copy link
Member

Could you elaborate more on what was the issue here?

@samsonasik
Copy link
Member Author

For example, I want to run rector on laminas components that has require-dev laminas/laminas-coding-standard that require slevomat/coding-standard:7.2.1 that uses phpstan/phpdoc-parser ^1.5.1, that make installing rector cause error:

composer require --dev rector/rector
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^0.14.2 for rector/rector
./composer.json has been updated
Running composer update rector/rector
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laminas/laminas-coding-standard is locked to version 2.4.0 and an update of this package was not requested.
    - slevomat/coding-standard 7.2.1 requires phpstan/phpdoc-parser ^1.5.1 -> satisfiable by phpstan/phpdoc-parser[1.5.1].
    - rector/rector 0.14.2 conflicts with phpstan/phpdoc-parser <1.7.
    - laminas/laminas-coding-standard 2.4.0 requires slevomat/coding-standard ^7.0 -> satisfiable by slevomat/coding-standard[7.2.1].
    - Root composer.json requires rector/rector ^0.14.2 -> satisfiable by rector/rector[0.14.2].

Running rector from global will make error as well as different __construct() params:

rector process 
PHP Fatal error:  Uncaught _PHPStan_9a6ded56a\Nette\DI\ServiceCreationException: Service of type PHPStan\PhpDocParser\Parser\PhpDocParser: Unable to pass specified arguments to PhpDocParser::__construct(). in phar:///Users/samsonasik/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:421

The workaround was to:

  1. Remove temporary laminas/laminas-coding-standard
  2. Require-dev rector
  3. Run Rector
  4. Remove rector
  5. add back laminas/laminas-coding-standard

But I think make it part on preload.php should solve it.

By add this to preload, Rector should use the phpstan/phpdoc-parser from scoped vendor, while original laminas/laminas-coding-standard will use old phpstan/phpdoc-parser.

@TomasVotruba
Copy link
Member

I see. That makes sense 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants