mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 12:29:43 +01:00
[DeadCode] Rector RemoveDeadConstructorRector
should skip private
method
This commit is contained in:
parent
361c9eb832
commit
d2923570d2
@ -53,6 +53,11 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skip private as they lock creating new instances via `new ClassName()`
|
||||
if ($node->isPrivate()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->removeNode($node);
|
||||
|
||||
return null;
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveDeadConstructorRector\Fixture;
|
||||
|
||||
class SkipPrivate
|
||||
{
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
@ -9,7 +9,13 @@ final class RemoveDeadConstructorRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc', __DIR__ . '/Fixture/skip.php.inc']);
|
||||
$this->doTestFiles(
|
||||
[
|
||||
__DIR__ . '/Fixture/fixture.php.inc',
|
||||
__DIR__ . '/Fixture/skip.php.inc',
|
||||
__DIR__ . '/Fixture/skip_private.php.inc',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
|
Loading…
x
Reference in New Issue
Block a user