Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class OverriddenInBetweenParam extends TestCase
{
public function run()
{
return $this->create(1, 2, 3);
}

private function create($first, $second, $third)
{
$second = 100;

return [$first, $second, $third];
}
}

?>
-----
<?php

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

use PHPUnit\Framework\TestCase;

final class OverriddenInBetweenParam extends TestCase
{
public function run()
{
return $this->create(1, 3);
}

private function create($first, $third)
{
$second = 100;

return [$first, $second, $third];
}
}

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

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

use PHPUnit\Framework\TestCase;

final class OverriddenParam extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
$value = 500;

return $value;
}
}

?>
-----
<?php

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

use PHPUnit\Framework\TestCase;

final class OverriddenParam extends TestCase
{
public function run()
{
return $this->create();
}

private function create()
{
$value = 500;
return $value;
}
}

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

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

use PHPUnit\Framework\TestCase;

final class OverriddenParamWithPhpDoc extends TestCase
{
public function run()
{
$this->prepare(new \stdClass());
}

/**
* @param \stdClass $user
*/
private function prepare(\stdClass $user): void
{
$user = new \stdClass();

echo $user->name;
}
}

?>
-----
<?php

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

use PHPUnit\Framework\TestCase;

final class OverriddenParamWithPhpDoc extends TestCase
{
public function run()
{
$this->prepare();
}

private function prepare(): void
{
$user = new \stdClass();
echo $user->name;
}
}

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

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

use PHPUnit\Framework\TestCase;

final class SkipByRefOverride extends TestCase
{
public function run()
{
$value = 1000;
$this->create($value);

return $value;
}

private function create(&$value)
{
$value = 500;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipClosureUseBeforeOverride extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
$closure = function () use ($value) {
return $value;
};

$value = 500;

return [$closure, $value];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipCompactOverride extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
$data = compact('value');

$value = 500;

return [$data, $value];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipConditionalOverride extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
if (rand(0, 1)) {
$value = 500;
}

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipConstructorOverride extends TestCase
{
private $value;

private function __construct($value)
{
$value = 500;

$this->value = $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipFirstClassCallableCaller extends TestCase
{
public function run()
{
return $this->create(...);
}

private function create($value)
{
$value = 500;

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

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

final class SkipNonTestClass
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
$value = 500;

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipPublicMethodOverride extends TestCase
{
public function create($value)
{
$value = 500;

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipSelfReferenceOverride extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
$value = $value ?: 500;

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

use PHPUnit\Framework\TestCase;

final class SkipUsedBeforeOverride extends TestCase
{
public function run()
{
return $this->create(1000);
}

private function create($value)
{
echo $value;

$value = 500;

return $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveTestsOverriddenPrivateMethodParameterRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class RemoveTestsOverriddenPrivateMethodParameterRectorTest 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';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveTestsOverriddenPrivateMethodParameterRector;

return RectorConfig::configure()
->withRules([RemoveTestsOverriddenPrivateMethodParameterRector::class]);
Loading
Loading