mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 12:52:36 +00:00
Merge pull request #2672 from jeroensmit/RemoveDelegatingParentCallDefault
Remove delegating parent call
This commit is contained in:
commit
80df8d0030
1
ecs.yaml
1
ecs.yaml
|
@ -119,6 +119,7 @@ parameters:
|
|||
- 'packages/TypeDeclaration/src/VendorLock/VendorLockResolver.php'
|
||||
- 'packages/TypeDeclaration/src/PhpParserTypeAnalyzer.php'
|
||||
- 'src/PhpParser/Node/Manipulator/IfManipulator.php'
|
||||
- 'packages/DeadCode/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php'
|
||||
# aliases
|
||||
- 'packages/CodingStyle/src/Rector/Namespace_/ImportFullyQualifiedNamesRector.php'
|
||||
|
||||
|
|
|
@ -234,8 +234,12 @@ PHP
|
|||
if ($parentClassMethod->isProtected() && $classMethod->isPublic()) {
|
||||
return true;
|
||||
}
|
||||
if (! $this->areNodesEqual($parentClassMethod->params, $classMethod->params)) {
|
||||
return true;
|
||||
|
||||
foreach ($parentClassMethod->params as $key => $parentParam) {
|
||||
if (! isset($classMethod->params[$key]) && $parentParam->default !== null) {
|
||||
continue;
|
||||
}
|
||||
$this->areNodesEqual($parentParam, $classMethod->params[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,6 +263,12 @@ PHP
|
|||
ReflectionMethod $reflectionMethod
|
||||
): bool {
|
||||
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
|
||||
if (! isset($classMethod->params[$key])) {
|
||||
if ($parameter->isDefaultValueAvailable()) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
$methodParam = $classMethod->params[$key];
|
||||
|
||||
if ($parameter->isDefaultValueAvailable() !== isset($methodParam->default)) {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveDelegatingParentCallRector\DefaultParam;
|
||||
Class Base
|
||||
{
|
||||
public function __construct($a, $b = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Override extends Base
|
||||
{
|
||||
public function __construct($a)
|
||||
{
|
||||
parent::__construct($a);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveDelegatingParentCallRector\DefaultParam;
|
||||
Class Base
|
||||
{
|
||||
public function __construct($a, $b = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Override extends Base
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user