-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Fix crash indentation on indent(\t, 1) config (#3155)
- Loading branch information
1 parent
f4ff24c
commit 3f1a285
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/Issues/IndentationCrash/FixtureTab/if_else_tab_indentation.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\IndentationCrash\FixtureTab; | ||
|
||
final class IfElseTabIndentation | ||
{ | ||
/** | ||
* @param string[]|string $args | ||
* | ||
* @return void | ||
*/ | ||
public function run( $args ) { | ||
if ( is_array( $args ) ) { | ||
foreach ( $args as $data ) { | ||
echo $data; | ||
} | ||
} else { | ||
echo $args; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\IndentationCrash; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class TabIndentationCrashTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureTab'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/tab_configured_rule.php'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/Issues/IndentationCrash/config/tab_configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->indent("\t", 1); | ||
$rectorConfig->rule(SimplifyIfElseWithSameContentRector::class); | ||
}; |