Updated Rector to commit 97d095f5bd3fe561dafd06f56f898f0aec535ba0

97d095f5bd [TypeDeclaration] Skip default numeric string on param int on ParamTypeByMethodCallTypeRector (#5210)
This commit is contained in:
Tomas Votruba 2023-10-28 16:36:35 +00:00
parent b60b85beb4
commit 5869e2ab60
2 changed files with 34 additions and 4 deletions

View File

@ -3,8 +3,10 @@
declare (strict_types=1);
namespace Rector\TypeDeclaration\NodeAnalyzer;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\ComplexType;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
@ -19,6 +21,8 @@ use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\PhpParser\AstResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
use Rector\StaticTypeMapper\StaticTypeMapper;
final class CallerParamMatcher
{
/**
@ -31,10 +35,22 @@ final class CallerParamMatcher
* @var \Rector\Core\PhpParser\AstResolver
*/
private $astResolver;
public function __construct(NodeNameResolver $nodeNameResolver, AstResolver $astResolver)
/**
* @readonly
* @var \Rector\StaticTypeMapper\StaticTypeMapper
*/
private $staticTypeMapper;
/**
* @readonly
* @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator
*/
private $typeComparator;
public function __construct(NodeNameResolver $nodeNameResolver, AstResolver $astResolver, StaticTypeMapper $staticTypeMapper, TypeComparator $typeComparator)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->astResolver = $astResolver;
$this->staticTypeMapper = $staticTypeMapper;
$this->typeComparator = $typeComparator;
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\FuncCall $call
@ -46,7 +62,21 @@ final class CallerParamMatcher
if (!$callParam instanceof Param) {
return null;
}
return $callParam->type;
if (!$param->default instanceof Expr) {
return $callParam->type;
}
if (!$callParam->type instanceof Node) {
return null;
}
$callParamType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($callParam->type);
$defaultType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->default);
if ($this->typeComparator->areTypesEqual($callParamType, $defaultType)) {
return $callParam->type;
}
if ($this->typeComparator->isSubtype($defaultType, $callParamType)) {
return $callParam->type;
}
return null;
}
public function matchParentParam(StaticCall $parentStaticCall, Param $param, Scope $scope) : ?Param
{

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6f330105bef70bec222f1cc6f86c09b137dff44f';
public const PACKAGE_VERSION = '97d095f5bd3fe561dafd06f56f898f0aec535ba0';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-10-28 19:40:43';
public const RELEASE_DATE = '2023-10-28 23:32:49';
/**
* @var int
*/