Skip to content

Commit 33db411

Browse files
committed
[internal] Fix inline replace block removal not removed on deep block for InlineIfToExplicitIfRector + ReplaceBlockToItsStmtsRector
1 parent 17f8d5c commit 33db411

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\InlineIfReplaceBlock\Fixture;
4+
5+
{
6+
is_null($userId) && $userId = 5;
7+
8+
{}
9+
}
10+
11+
{
12+
is_null($userId) && $userId = 5;
13+
14+
{}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\Tests\Issues\InlineIfReplaceBlock\Fixture;
22+
23+
if (is_null($userId)) {
24+
$userId = 5;
25+
}
26+
27+
if (is_null($userId)) {
28+
$userId = 5;
29+
}
30+
31+
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\Issues\InlineIfReplaceBlock;
6+
7+
use Iterator;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
10+
11+
final class InlineIfReplaceBlockTest extends AbstractRectorTestCase
12+
{
13+
#[DataProvider('provideData')]
14+
public function test(string $filePath): void
15+
{
16+
$this->doTestFile($filePath);
17+
}
18+
19+
public static function provideData(): Iterator
20+
{
21+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
22+
}
23+
24+
public function provideConfigFilePath(): string
25+
{
26+
return __DIR__ . '/config/configured_rule.php';
27+
}
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\DeadCode\Rector\Block\ReplaceBlockToItsStmtsRector;
8+
9+
return RectorConfig::configure()
10+
->withRules([InlineIfToExplicitIfRector::class, ReplaceBlockToItsStmtsRector::class]);

0 commit comments

Comments
 (0)