mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-29 06:03:30 +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/VendorLock/VendorLockResolver.php'
|
||||||
- 'packages/TypeDeclaration/src/PhpParserTypeAnalyzer.php'
|
- 'packages/TypeDeclaration/src/PhpParserTypeAnalyzer.php'
|
||||||
- 'src/PhpParser/Node/Manipulator/IfManipulator.php'
|
- 'src/PhpParser/Node/Manipulator/IfManipulator.php'
|
||||||
|
- 'packages/DeadCode/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php'
|
||||||
# aliases
|
# aliases
|
||||||
- 'packages/CodingStyle/src/Rector/Namespace_/ImportFullyQualifiedNamesRector.php'
|
- 'packages/CodingStyle/src/Rector/Namespace_/ImportFullyQualifiedNamesRector.php'
|
||||||
|
|
||||||
|
|
|
@ -234,8 +234,12 @@ PHP
|
||||||
if ($parentClassMethod->isProtected() && $classMethod->isPublic()) {
|
if ($parentClassMethod->isProtected() && $classMethod->isPublic()) {
|
||||||
return true;
|
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
|
ReflectionMethod $reflectionMethod
|
||||||
): bool {
|
): bool {
|
||||||
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
|
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
|
||||||
|
if (! isset($classMethod->params[$key])) {
|
||||||
|
if ($parameter->isDefaultValueAvailable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$methodParam = $classMethod->params[$key];
|
$methodParam = $classMethod->params[$key];
|
||||||
|
|
||||||
if ($parameter->isDefaultValueAvailable() !== isset($methodParam->default)) {
|
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