Skip to content

Commit 461c9c4

Browse files
authored
[DeadCode] Skip different default param not typed on RemoveParentDelegatingConstructorRector (#7905)
* [DeadCode] Skip different default param not typed on RemoveParentDelegatingConstructorRector * Fix
1 parent 1424f50 commit 461c9c4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
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 Exception;
6+
7+
class SkipDifferentDefaultParamNoTyped extends Exception
8+
{
9+
public function __construct($message = 'Email not sent.', ...$args)
10+
{
11+
parent::__construct($message, ...$args);
12+
}
13+
}

rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ private function areConstructorAndParentParameterTypesMatching(
232232

233233
// no type override
234234
if ($parameterType === null) {
235+
if ($param->default instanceof Expr && $this->isDifferentDefaultValue($param->default, $extendedMethodReflection, $position)) {
236+
return false;
237+
}
238+
235239
continue;
236240
}
237241

0 commit comments

Comments
 (0)