-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Handle RemoveUnusedConstructorParamRector + RemoveUnusedPr…
…ivatePropertyRector (#1714) Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
88a3207
commit 081958a
Showing
5 changed files
with
153 additions
and
32 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
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
53 changes: 53 additions & 0 deletions
53
tests/Issues/RemoveUnusedParamInMiddle/Fixture/do_not_remove_parameter_in_middle.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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\RemoveUnusedParamInMiddle\Fixture; | ||
|
||
final class DoNotRemoveParameterInMiddle | ||
{ | ||
private $propertyA; | ||
private $propertyB; | ||
private $propertyC; | ||
|
||
public function __construct($propertyA, $propertyB, $propertyC) | ||
{ | ||
$this->propertyA = $propertyA; | ||
$this->propertyB = $propertyB; | ||
$this->propertyC = $propertyC; | ||
} | ||
|
||
public function run() | ||
{ | ||
echo $this->propertyA; | ||
echo $this->propertyC; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\RemoveUnusedParamInMiddle\Fixture; | ||
|
||
final class DoNotRemoveParameterInMiddle | ||
{ | ||
private $propertyA; | ||
private $propertyC; | ||
|
||
public function __construct($propertyA, $propertyB, $propertyC) | ||
{ | ||
$this->propertyA = $propertyA; | ||
$this->propertyC = $propertyC; | ||
} | ||
|
||
public function run() | ||
{ | ||
echo $this->propertyA; | ||
echo $this->propertyC; | ||
} | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
tests/Issues/RemoveUnusedParamInMiddle/RemoveUnusedParamInMiddleTest.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\RemoveUnusedParamInMiddle; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class RemoveUnusedParamInMiddleTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Issues/RemoveUnusedParamInMiddle/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\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; | ||
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
$services->set(RemoveUnusedConstructorParamRector::class); | ||
$services->set(RemoveUnusedPrivatePropertyRector::class); | ||
}; |