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

[Core] Fix crash indentation on indent(\t, 1) config #3155

Merged
merged 4 commits into from
Dec 5, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Dec 5, 2022

Given the following config:

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->indent("\t", 1);
    $rectorConfig->rule(SimplifyIfElseWithSameContentRector::class);
};

It cause crash:

There was 1 failure:

1) Rector\Core\Tests\Issues\IndentationCrash\TabIndentationCrashTest::test with data set #0 ('/Users/samsonasik/www/rector-...hp.inc')
assert($this->indentLevel >= 4) in /Users/samsonasik/www/rector-src/src/PhpParser/Printer/BetterStandardPrinter.php:199

Caused by
AssertionError: assert($this->indentLevel >= 4) in /Users/samsonasik/www/rector-src/src/PhpParser/Printer/BetterStandardPrinter.php:199

Ref https://getrector.org/demo/1d6243b2-ab0c-4002-814c-86f36b465412
Fixes rectorphp/rector#7638

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @kkmuffme

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 3f1a285 into main Dec 5, 2022
@TomasVotruba TomasVotruba deleted the fix-crash-tab-indentation branch December 5, 2022 11:00
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.

0.15.0 Regression on SimplifyIfElseWithSameContentRector PHP notice
2 participants