Skip to content

Commit

Permalink
[DeadCode] Merge RemoveDeadConstructorRector, to RemoveEmptyClassMeth…
Browse files Browse the repository at this point in the history
…odRector with same behavior (#2829)
  • Loading branch information
TomasVotruba committed Aug 24, 2022
1 parent 9018492 commit 6c8c40b
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 208 deletions.
21 changes: 2 additions & 19 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 410 Rules Overview
# 409 Rules Overview

<br>

Expand All @@ -14,7 +14,7 @@

- [Composer](#composer) (6)

- [DeadCode](#deadcode) (49)
- [DeadCode](#deadcode) (48)

- [DependencyInjection](#dependencyinjection) (2)

Expand Down Expand Up @@ -2857,23 +2857,6 @@ Remove dead condition above return

<br>

### RemoveDeadConstructorRector

Remove empty constructor

- class: [`Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector`](../rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php)

```diff
class SomeClass
{
- public function __construct()
- {
- }
}
```

<br>

### RemoveDeadContinueRector

Remove useless continue at the end of loops
Expand Down
2 changes: 0 additions & 2 deletions config/set/dead-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector;
Expand Down Expand Up @@ -66,7 +65,6 @@
RemoveUnusedPrivatePropertyRector::class,
RemoveUnusedPrivateClassConstantRector::class,
RemoveUnusedPrivateMethodRector::class,
RemoveDeadConstructorRector::class,
RemoveDeadReturnRector::class,
RemoveDeadContinueRector::class,
RemoveDeadIfForeachForRector::class,
Expand Down
2 changes: 1 addition & 1 deletion e2e/applied-rule-removed-node/expected-output.diff
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
----------- end diff -----------

Applied rules:
* RemoveDeadConstructorRector
* RemoveEmptyClassMethodRector


2) src/AlwaysTrue.php:3
Expand Down
4 changes: 2 additions & 2 deletions e2e/applied-rule-removed-node/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);

$rectorConfig->rule(RemoveDeadConstructorRector::class);
$rectorConfig->rule(RemoveEmptyClassMethodRector::class);
$rectorConfig->rule(RemoveAlwaysTrueIfConditionRector::class);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

final class FirstFixture
{
public function __construct()
{
}
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

final class FirstFixture
{
}

?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

class Skip extends AnotherClass
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

class MyPdoStub extends MyPdo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

class SkipPrivate
{
private function __construct()
{
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

class SkipPropertyPromotion
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

abstract class SkipProtectedOnAbstractClass
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\Fixture;

class SkipProtectedOnNonFinalClass
{
Expand Down
102 changes: 0 additions & 102 deletions rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(RemoveAlwaysTrueIfConditionRector::class);
$rectorConfig->rule(RemoveDeadConstructorRector::class);
$rectorConfig->rule(RemoveEmptyClassMethodRector::class);
};

0 comments on commit 6c8c40b

Please sign in to comment.