Skip to content

Commit e46bfd9

Browse files
authored
[DeadCode] Add RemoveParentDelegatingClassMethodRector (#8204)
1 parent 919fc0e commit e46bfd9

24 files changed

Lines changed: 632 additions & 0 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentWithDocblockTypes;
6+
7+
final class SkipAddedNativeTypes extends SomeParentWithDocblockTypes
8+
{
9+
public function compute(int $value): int
10+
{
11+
return parent::compute($value);
12+
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipAttributedMethod extends SomeParentCommand
8+
{
9+
#[\Deprecated]
10+
protected function configure(): void
11+
{
12+
parent::configure();
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentWithConstructor;
6+
7+
final class SkipConstruct extends SomeParentWithConstructor
8+
{
9+
public function __construct(int $value)
10+
{
11+
parent::__construct($value);
12+
}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipDeprecatedDocblock extends SomeParentCommand
8+
{
9+
/**
10+
* @deprecated
11+
*/
12+
protected function configure(): void
13+
{
14+
parent::configure();
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipDifferentParentMethod extends SomeParentCommand
8+
{
9+
protected function configure(): void
10+
{
11+
parent::anotherMethod();
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipExtraStmt extends SomeParentCommand
8+
{
9+
protected function configure(): void
10+
{
11+
parent::configure();
12+
13+
echo 'more';
14+
}
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
class SkipFinalMethod extends SomeParentCommand
8+
{
9+
final protected function configure(): void
10+
{
11+
parent::configure();
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipNarrowedParamType extends SomeParentCommand
8+
{
9+
public function process(int|float $value): int
10+
{
11+
return parent::process($value);
12+
}
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
final class SkipNoParentClass
6+
{
7+
protected function configure(): void
8+
{
9+
}
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Fixture;
4+
5+
use Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector\Source\SomeParentCommand;
6+
7+
final class SkipParamDocblock extends SomeParentCommand
8+
{
9+
/**
10+
* @param positive-int $value
11+
*/
12+
public function process(int $value): int
13+
{
14+
return parent::process($value);
15+
}
16+
}

0 commit comments

Comments
 (0)