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

[CS] Fix dynamic and broken indent detection, allow to configure spacing via RectorConfig::indent() method #2442

Merged
merged 3 commits into from
Jun 6, 2022

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Jun 6, 2022

Closes rectorphp/rector#7210

At the moment, the indent detection depens on every single space token in the code. If there is one tab, the code will be changed to tabs, which is non-sense.

When we look at the php-parser issue related to indentation, there is a possible way to configure the printer via options:
nikic/PHP-Parser#723 (comment)

Saying that, instead of magical indent guessing per file, we should let user configure the default space indent:

// 4 spaces
$rectorConfig->indent(' ', 4);

// one tab
$rectorConfig->indent("\t", 1);

Files must respect one indent way.


The rest code should be handled by CS tool like before: https://github.com/rectorphp/rector#how-to-apply-coding-standards

@samsonasik
Copy link
Member

@TomasVotruba
Copy link
Member Author

I see. Few fixtures are using the tabs, let's update it

@TomasVotruba
Copy link
Member Author

TomasVotruba commented Jun 6, 2022

CI is passing 🎉

@TomasVotruba TomasVotruba merged commit 38a9718 into main Jun 6, 2022
@TomasVotruba TomasVotruba deleted the tv-fix-indent-2 branch June 6, 2022 09:51
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.

Tab character in file causes unexpected indention in docblock
2 participants