Skip to content

Commit 5c398e3

Browse files
committed
fix
1 parent ae7ccd4 commit 5c398e3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpParser\Node\Stmt\ClassMethod;
1414
use PhpParser\Node\Stmt\Expression;
1515
use PhpParser\NodeVisitor;
16+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter;
1617
use PHPStan\Reflection\ClassReflection;
1718
use PHPStan\Reflection\ExtendedMethodReflection;
1819
use Rector\Enum\ObjectReference;
1920
use Rector\PhpParser\Node\Value\ValueResolver;
2021
use Rector\PHPStan\ScopeFetcher;
2122
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
2223
use Rector\Rector\AbstractRector;
23-
use Rector\Reflection\ReflectionResolver;
2424
use Rector\StaticTypeMapper\StaticTypeMapper;
2525
use Rector\ValueObject\MethodName;
2626
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@@ -236,10 +236,20 @@ private function areConstructorAndParentParameterTypesMatching(
236236
return false;
237237
}
238238

239+
if (! $param->default instanceof Expr) {
240+
continue;
241+
}
242+
239243
if ($extendedMethodReflection->getDeclaringClass()->getNativeReflection()->hasMethod($methodName)) {
240-
$parentMethod = $extendedMethodReflection->getDeclaringClass()->getNativeReflection()->getMethod($methodName);
244+
$parentMethod = $extendedMethodReflection->getDeclaringClass()
245+
->getNativeReflection()
246+
->getMethod($methodName);
241247
$nativeParentParameterReflection = $parentMethod->getParameters()[$index] ?? null;
242248

249+
if (! $nativeParentParameterReflection instanceof ReflectionParameter) {
250+
continue;
251+
}
252+
243253
$parentDefault = $nativeParentParameterReflection->getDefaultValue();
244254
$currentDefault = $this->valueResolver->getValue($param->default);
245255

0 commit comments

Comments
 (0)