-
-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cd6376
commit 5b990b9
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
tests/Issues/KeepDoubleAssignParam/Fixture/fixture.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,49 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\KeepDoubleAssignParam\Fixture; | ||
|
||
final class Fixture | ||
{ | ||
private $items; | ||
|
||
public function __construct($input) | ||
{ | ||
if (! \is_array($input)) { | ||
$this->items = [$input]; | ||
} else { | ||
$this->items = $input; | ||
} | ||
|
||
$this->items = $this->getItems(); | ||
} | ||
|
||
public function getItems() | ||
{ | ||
return sort($this->items); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\KeepDoubleAssignParam\Fixture; | ||
|
||
final class Fixture | ||
{ | ||
private $items; | ||
|
||
public function __construct($input) | ||
{ | ||
$this->items = !\is_array($input) ? [$input] : $input; | ||
|
||
$this->items = $this->getItems(); | ||
} | ||
|
||
public function getItems() | ||
{ | ||
return sort($this->items); | ||
} | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/KeepDoubleAssignParam/KeepDoubleAssignParamTest.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\KeepDoubleAssignParam; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class KeepDoubleAssignParamTest 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'; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/Issues/KeepDoubleAssignParam/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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
|
||
return RectorConfig::configure() | ||
->withRules([ | ||
\Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class, | ||
\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class, | ||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class, | ||
]); |