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

[CodingStyle] Add DataProviderArrayItemsNewlinedRector #3271

Merged
merged 2 commits into from
Jan 10, 2023

Conversation

TomasVotruba
Copy link
Member

No description provided.

@TomasVotruba TomasVotruba changed the title [CodingStyle] Add DataProviderArrayItemsNewlinedRector [WIP] [CodingStyle] Add DataProviderArrayItemsNewlinedRector Jan 10, 2023
@TomasVotruba TomasVotruba force-pushed the tv-data-provider-indents branch from a2ea5d5 to 640bdf4 Compare January 10, 2023 00:46
@samsonasik
Copy link
Member

Handle new line may need handle <=0 check tweak to avoid crash or infinite loop on multiple rules usage, see NewlineAfterStatementRector;

// skip same line or < 0 that cause infinite loop or crash
if ($rangeLine <= 0) {
return null;
}


public function provideData(): array
{
return [
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe turn them into one yield per array item instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

There another rule for that already :)
This rule is mainly for Test Gen AI styling.

@TomasVotruba TomasVotruba changed the title [WIP] [CodingStyle] Add DataProviderArrayItemsNewlinedRector [CodingStyle] Add DataProviderArrayItemsNewlinedRector Jan 10, 2023
@TomasVotruba TomasVotruba force-pushed the tv-data-provider-indents branch 2 times, most recently from af7c7b7 to e9f90bf Compare January 10, 2023 10:56
@TomasVotruba
Copy link
Member Author

TomasVotruba commented Jan 10, 2023

Handle new line may need handle <=0 check tweak to avoid crash or infinite loop on multiple rules usage, see NewlineAfterStatementRector;

That could work too, thanks!
I've a handy method from standard printer that handles this by itself :) I'm happy php-parser has exact method we need here.

@TomasVotruba TomasVotruba force-pushed the tv-data-provider-indents branch from e9f90bf to 67c9e66 Compare January 10, 2023 10:59
@TomasVotruba TomasVotruba enabled auto-merge (squash) January 10, 2023 10:59
@TomasVotruba TomasVotruba merged commit 58c8f17 into main Jan 10, 2023
@TomasVotruba TomasVotruba deleted the tv-data-provider-indents branch January 10, 2023 11:03
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.

3 participants