Skip to content

Commit fc381ce

Browse files
committed
skip fcc
1 parent 286ca84 commit fc381ce

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_differnt_args.php.inc renamed to rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_different_args.php.inc

File renamed without changes.

rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_differnt_count.php.inc renamed to rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_different_count.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstru
44

55
use PhpParser\Node\Scalar\String_;
66

7-
final class SkipDifferntCount extends String_
7+
final class SkipDifferentCount extends String_
88
{
99
public function __construct($value)
1010
{

rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_different_type.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstru
77
use PhpParser\NodeTraverser;
88
use Rector\Comments\NodeVisitor\CommentRemovingNodeVisitor;
99

10-
final class SkipDifferntType extends NodeTraverser
10+
final class SkipDifferentType extends NodeTraverser
1111
{
1212
public function __construct(CommentRemovingNodeVisitor $commentRemovingNodeVisitor)
1313
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector\Fixture;
4+
5+
use PhpParser\Node\Scalar\String_;
6+
7+
final class SkipFirstClassCallable extends String_
8+
{
9+
public function __construct($value, $attributes)
10+
{
11+
parent::__construct(...);
12+
}
13+
}

rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ private function matchParentConstructorCallArgs(Stmt $stmt): ?array
155155
}
156156

157157
$staticCall = $stmt->expr;
158+
if ($staticCall->isFirstClassCallable()) {
159+
return null;
160+
}
161+
158162
if (! $this->isName($staticCall->class, ObjectReference::PARENT)) {
159163
return null;
160164
}
@@ -201,7 +205,7 @@ private function isParameterAndArgCountAndOrderIdentical(ClassMethod $classMetho
201205

202206
private function areConstructorAndParentParameterTypesMatching(
203207
ClassMethod $classMethod,
204-
ExtendedMethodReflection $parentMethodReflection
208+
ExtendedMethodReflection $extendedMethodReflection
205209
): bool {
206210
foreach ($classMethod->getParams() as $position => $param) {
207211
$parameterType = $param->type;
@@ -211,7 +215,7 @@ private function areConstructorAndParentParameterTypesMatching(
211215
continue;
212216
}
213217

214-
$parametersSelector = $parentMethodReflection->getOnlyVariant();
218+
$parametersSelector = $extendedMethodReflection->getOnlyVariant();
215219

216220
foreach ($parametersSelector->getParameters() as $index => $parameterReflection) {
217221
if ($index !== $position) {

src/Comments/NodeTraverser/CommentRemovingNodeTraverser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
namespace Rector\Comments\NodeTraverser;
66

77
use PhpParser\NodeTraverser;
8+
use Rector\Comments\NodeVisitor\CommentRemovingNodeVisitor;
89

910
final class CommentRemovingNodeTraverser extends NodeTraverser
1011
{
12+
public function __construct(CommentRemovingNodeVisitor $commentRemovingNodeVisitor)
13+
{
14+
parent::__construct($commentRemovingNodeVisitor);
15+
}
1116
}

0 commit comments

Comments
 (0)