|
13 | 13 | use PhpParser\Node\Stmt\ClassMethod; |
14 | 14 | use PhpParser\Node\Stmt\Expression; |
15 | 15 | use PhpParser\NodeVisitor; |
| 16 | +use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter; |
16 | 17 | use PHPStan\Reflection\ClassReflection; |
17 | 18 | use PHPStan\Reflection\ExtendedMethodReflection; |
18 | 19 | use Rector\Enum\ObjectReference; |
19 | 20 | use Rector\PhpParser\Node\Value\ValueResolver; |
20 | 21 | use Rector\PHPStan\ScopeFetcher; |
21 | 22 | use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; |
22 | 23 | use Rector\Rector\AbstractRector; |
23 | | -use Rector\Reflection\ReflectionResolver; |
24 | 24 | use Rector\StaticTypeMapper\StaticTypeMapper; |
25 | 25 | use Rector\ValueObject\MethodName; |
26 | 26 | use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
@@ -236,10 +236,20 @@ private function areConstructorAndParentParameterTypesMatching( |
236 | 236 | return false; |
237 | 237 | } |
238 | 238 |
|
| 239 | + if (! $param->default instanceof Expr) { |
| 240 | + continue; |
| 241 | + } |
| 242 | + |
239 | 243 | if ($extendedMethodReflection->getDeclaringClass()->getNativeReflection()->hasMethod($methodName)) { |
240 | | - $parentMethod = $extendedMethodReflection->getDeclaringClass()->getNativeReflection()->getMethod($methodName); |
| 244 | + $parentMethod = $extendedMethodReflection->getDeclaringClass() |
| 245 | + ->getNativeReflection() |
| 246 | + ->getMethod($methodName); |
241 | 247 | $nativeParentParameterReflection = $parentMethod->getParameters()[$index] ?? null; |
242 | 248 |
|
| 249 | + if (! $nativeParentParameterReflection instanceof ReflectionParameter) { |
| 250 | + continue; |
| 251 | + } |
| 252 | + |
243 | 253 | $parentDefault = $nativeParentParameterReflection->getDefaultValue(); |
244 | 254 | $currentDefault = $this->valueResolver->getValue($param->default); |
245 | 255 |
|
|
0 commit comments