rectorphp / rector-pest

MIT License
10 stars 2 forks source link

Pest rule set not available #9

Closed shaffe-fr closed 1 year ago

shaffe-fr commented 1 year ago

Hi, I installed the rector/rector as indicated in the README but PestSetList rules set is not installed.

I'm using PHP 8.1, the latest rector/rector (^0.15.24), PHPStan (^1.10.4).

I tried to installed the latest dev-main rector/rector-pest using a composer custom repository, but it fails because of the rector/rector-phpunit dependency.

 Problem 1
    - rector/rector-phpunit 0.11.0 requires rector/rector ^0.11 -> found rector/
rector[0.11.0, ..., 0.11.60] but it conflicts with your root composer.json requi
re (^0.15.20).
    - Root composer.json requires rector/rector ^0.15.20 -> satisfiable by recto
r/rector[0.15.20, ..., 0.15.24].
    - rector/rector-pest dev-main requires rector/rector-phpunit ^0.11.0@dev ->
satisfiable by rector/rector-phpunit[0.11.0, ..., 0.11.26].
    - rector/rector[0.15.20, ..., 0.15.24] conflict with rector/rector-phpunit *
.
    - Root composer.json requires rector/rector-pest dev-main -> satisfiable by
rector/rector-pest[dev-main].

I also tried to install rector/rector on a fresh Laravel 10.7.1 install, and the rule set is not installed.

What am I missing?

Thanks,

Karel

TomasVotruba commented 1 year ago

Hi, this is standalone experimental package at the moment. It would require more rules to be included in the core.

You have to install it as a new package with composer.

TomasVotruba commented 1 year ago

I've just added it packagist.

Here you go :)

https://packagist.org/packages/rector/rector-pest

shaffe-fr commented 1 year ago

Thanks for the quick reply!

The following dependency prevents the package to be installed "rector/rector-phpunit": "^0.11.0@dev". After some tries, I made it work by removing it.

I have the following error message when running rector for \Rector\Pest\Set\PestSetList::PHPUNIT_TO_PEST:

@php vendor/bin/rector process --debug
 [ERROR] Cannot autowire service
         "Rector\Pest\Rector\ClassMethod\TestClassMethodToPestTestFuncCallRector": argument "$pestFuncCallFactory" of method "__construct()" references class "Rector\Pest\NodeFactory\PestFuncCallFactory" but no such service exists.

Thanks

TomasVotruba commented 1 year ago

That might require some changes here: https://github.com/rectorphp/rector-pest/blob/main/composer.json#L8

To run the rules, services must be included in your rector.php too:

$rectorConfig->import(...');