-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php54] No need reprint when array is just created on LongArrayToShor…
…tArrayRector (#6206) * [Php54] No need reprint when array is just created on LongArrayToShortArrayRector * [Php54] No need reprint when array is just created on LongArrayToShortArrayRector
- Loading branch information
1 parent
ad36316
commit 1331f97
Showing
4 changed files
with
80 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
tests/Issues/CountArrayLongToShort/CountArrayLongToShortTest.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Issues\CountArrayLongToShort; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class CountArrayLongToShortTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/Issues/CountArrayLongToShort/Fixture/count_to_empty_array_compare.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,33 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\CountArrayLongToShort\Fixture; | ||
|
||
final class CountToEmptyArrayCompare | ||
{ | ||
public function run() | ||
{ | ||
$data = []; | ||
|
||
if (count($data) === 0) { | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\CountArrayLongToShort\Fixture; | ||
|
||
final class CountToEmptyArrayCompare | ||
{ | ||
public function run() | ||
{ | ||
$data = []; | ||
|
||
if ($data === []) { | ||
} | ||
} | ||
} | ||
|
||
?> |
13 changes: 13 additions & 0 deletions
13
tests/Issues/CountArrayLongToShort/config/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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector; | ||
|
||
return RectorConfig::configure() | ||
->withRules([ | ||
CountArrayToEmptyArrayComparisonRector::class, | ||
LongArrayToShortArrayRector::class, | ||
]); |