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

Add possibility to add multiple phpstan configs #4798

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Aug 16, 2023

@samsonasik
Copy link
Member

would be great to have both available imo, that's like $rectorConfig->rule() and $rectorConfig->rules()

@alexander-schranz
Copy link
Contributor Author

alexander-schranz commented Aug 16, 2023

@samsonasik Okay then we need to discuss the defaults of the following:

Case A: Using phpstanConfigs without phpstanConfig e.g.:

$rectorConfig->phpstanConfigs(['some-test.neon'])

Should the current default phpstan.neon still be loaded or not?

Case B: Using phpstanConfigs and phpstanConfig:

$rectorConfig->phpstanConfig('some-test.neon');
$rectorConfig->phpstanConfigs(['some-test.neon']);

Does phpstanConfigs overwrite phpstanConfig or not?

Case C: Using phpstanConfigs before phpstanConfig:

$rectorConfig->phpstanConfigs(['some-test.neon']);
$rectorConfig->phpstanConfig('some-test.neon');

Does phpstanConfig overwrite phpstanConfigs or not?

Case D: Multiple phpstanConfigs calls:

$rectorConfig->phpstanConfigs(['some-test.neon']);
$rectorConfig->phpstanConfigs(['some-other.neon']);

Does it replace or not load both?

Case E: Multiple phpstanConfig calls:

$rectorConfig->phpstanConfig('some-test.neon');
$rectorConfig->phpstanConfig('some-other.neon');

Does it replace or not load both?

@samsonasik
Copy link
Member

I think the config should merge like when we define:

$rectorConfig->rule(FirstRector::class);

$rectorConfig->rules([
        SecondRector::class,
        ThirdRector::class,
]);

The result of rules are 3.

@alexander-schranz
Copy link
Contributor Author

@samsonasik what I'm currently not understand how currently the fallback to phpstan.neon works if there is nothing configured.

@alexander-schranz alexander-schranz force-pushed the feature/add-phpstan-configs-parameter branch 2 times, most recently from adcedd9 to 788ae23 Compare August 16, 2023 11:42
@alexander-schranz
Copy link
Contributor Author

Or is this comment here:

* By default, the "phpstan.neon" path is used.
not longer true?

@samsonasik
Copy link
Member

That seems no longer true afaik

@alexander-schranz alexander-schranz force-pushed the feature/add-phpstan-configs-parameter branch from 788ae23 to c915c41 Compare August 16, 2023 11:48
rector.php Outdated Show resolved Hide resolved
Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Copy link
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be covered by a test?

@TomasVotruba
Copy link
Member

@alexander-schranz Thank you 👍

@TomasVotruba TomasVotruba merged commit 41de617 into rectorphp:main Aug 16, 2023
@alexander-schranz alexander-schranz deleted the feature/add-phpstan-configs-parameter branch August 16, 2023 21:54
@bloep
Copy link

bloep commented Aug 17, 2023

@TomasVotruba do you see any chance that we can get a Rector release with this fix in the near future?
That would solve a pain point for us 🙏

@TomasVotruba
Copy link
Member

@bloep Sure, I'm on it :)

@TomasVotruba
Copy link
Member

TomasVotruba commented Aug 17, 2023

There you /~https://github.com/rectorphp/rector/releases/tag/0.17.14 💪

@TomasVotruba
Copy link
Member

TomasVotruba commented Aug 17, 2023

I have just realized the container switch might be a BC break for anyone using Symfony internals (though they should not) 🤦

So I changed replaced the tag to a minor version jump, just to be sure:
/~https://github.com/rectorphp/rector/releases/tag/0.18.0

Use the Rector 0.18.0 tag instead. My appologies for confusion 🙏

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.

Add possibility of adding multiple phpstan neon files
5 participants