Skip to content

Add possibility to add multiple phpstan configs#4798

Merged
TomasVotruba merged 4 commits intorectorphp:mainfrom
alexander-schranz:feature/add-phpstan-configs-parameter
Aug 16, 2023
Merged

Add possibility to add multiple phpstan configs#4798
TomasVotruba merged 4 commits intorectorphp:mainfrom
alexander-schranz:feature/add-phpstan-configs-parameter

Conversation

@alexander-schranz
Copy link
Copy Markdown
Contributor

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

@samsonasik
Copy link
Copy Markdown
Member

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

@alexander-schranz
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Or is this comment here:

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

@samsonasik
Copy link
Copy Markdown
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
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Member

@bloep Sure, I'm on it :)

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented Aug 17, 2023

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

@TomasVotruba
Copy link
Copy Markdown
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