mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-30 14:43:31 +00:00
[TypeDeclaration] Skip ParamTypeDeclarationRector on interface with extends (#5292)
* Add failing test fixture for ParamTypeDeclarationRector # Failing Test for ParamTypeDeclarationRector Based on https://getrector.org/demo/56b352cf-6ba5-4fd5-8186-dd071d1e4010 * Fix namespace position * Update rules/type-declaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/Fixture/vat_rate.php.inc Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * Update rules/type-declaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/Fixture/vat_rate.php.inc Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * Update interfaces' names * Rename vat_rate.php.inc to skip_different_with_interface.php.inc * Close #5274 Fixes #5270 * cs fix Co-authored-by: Adamo Crespi <hello@aerendir.me>
This commit is contained in:
parent
d08f63fb1b
commit
8cd6dbea3b
|
@ -9,11 +9,13 @@ use PhpParser\Node\FunctionLike;
|
|||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\TypeDeclaration\ChildPopulator\ChildParamPopulator;
|
||||
|
@ -176,6 +178,11 @@ CODE_SAMPLE
|
|||
return;
|
||||
}
|
||||
|
||||
$parentNode = $functionLike->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof Interface_ && $parentNode->extends !== []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$param->type = $paramTypeNode;
|
||||
$this->childParamPopulator->populateChildClassMethod($functionLike, $position, $inferedType);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\FunctionLike\ParamTypeDeclarationRector\Fixture;
|
||||
|
||||
interface ParentInterface
|
||||
{
|
||||
/**
|
||||
* @param float|int|string $value
|
||||
*/
|
||||
public function __construct($value);
|
||||
}
|
||||
|
||||
interface IntermediateInterface extends ParentInterface
|
||||
{
|
||||
/**
|
||||
* @param string $countryCode
|
||||
*/
|
||||
public function __construct($countryCode);
|
||||
}
|
||||
|
||||
final class SkipInterfaceExtends implements IntermediateInterface
|
||||
{
|
||||
/**
|
||||
* @param string $countryCode
|
||||
*/
|
||||
public function __construct($countryCode)
|
||||
{
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user