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,13 @@
<?php

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

use PhpParser\Node\Scalar\String_;

final class SkipFinalConstruct extends String_
{
final public function __construct($value, $attributes)
{
parent::__construct($value, $attributes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

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

use PhpParser\Node\Scalar\String_;

final class SkipPrivateConstruct extends String_
{
private function __construct($value, $attributes)
{
parent::__construct($value, $attributes);
}

public static function create($value, $attributes)
{
return new self($value, $attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public function refactor(Node $node): ?int
return null;
}

if ($node->isFinal()) {
return null;
}

if (! $node->isPublic()) {
return null;
}

$parentMethodReflection = $this->matchParentConstructorReflection($node);
if (! $parentMethodReflection instanceof ExtendedMethodReflection) {
return null;
Expand Down