mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-16 08:02:23 +00:00
[Php71] Skip interface type on RemoveExtraParametersRector (#237)
This commit is contained in:
parent
246a5863ed
commit
1fb8e54d95
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Fixture;
|
||||
|
||||
use Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Source\CollectionInterface;
|
||||
use Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Source\CollectionImpl;
|
||||
|
||||
final class SkipInterfaceType
|
||||
{
|
||||
/** @var CollectionInterface*/
|
||||
private $collection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->collection = new CollectionImpl();
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->collection->getData('value');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Source;
|
||||
|
||||
class CollectionImpl implements CollectionInterface
|
||||
{
|
||||
public function getData(string $var = null)
|
||||
{
|
||||
echo $var ?? 'fallback';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Source;
|
||||
|
||||
interface CollectionInterface
|
||||
{
|
||||
public function getData();
|
||||
}
|
|
@ -12,6 +12,7 @@ use PhpParser\Node\Name;
|
|||
use PHPStan\Reflection\FunctionReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Reflection\ParametersAcceptor;
|
||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
||||
use PHPStan\Reflection\Type\UnionTypeMethodReflection;
|
||||
use Rector\Core\PHPStan\Reflection\CallReflectionResolver;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
@ -65,6 +66,13 @@ final class RemoveExtraParametersRector extends AbstractRector
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($functionLikeReflection instanceof PhpMethodReflection) {
|
||||
$classReflection = $functionLikeReflection->getDeclaringClass();
|
||||
if ($classReflection->isInterface()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$maximumAllowedParameterCount = $this->resolveMaximumAllowedParameterCount($functionLikeReflection);
|
||||
|
||||
$numberOfArguments = count($node->args);
|
||||
|
|
Loading…
Reference in New Issue
Block a user