Updated Rector to commit 14f11280c85a2776b211dac001f0accd4295c587

14f11280c8 [Naming] Skip DateTimeImmutable on RenamePropertyToMatchTypeRector (#5340)
This commit is contained in:
Tomas Votruba 2023-12-08 14:41:39 +00:00
parent 548d5109ed
commit e5e3c815d5
2 changed files with 12 additions and 12 deletions

View File

@ -8,6 +8,7 @@ use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\Naming\Naming\PropertyNaming;
use Rector\Naming\ValueObject\ExpectedName;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\StaticTypeMapper\StaticTypeMapper;
final class MatchParamTypeExpectedNameResolver
{
@ -21,10 +22,16 @@ final class MatchParamTypeExpectedNameResolver
* @var \Rector\Naming\Naming\PropertyNaming
*/
private $propertyNaming;
public function __construct(StaticTypeMapper $staticTypeMapper, PropertyNaming $propertyNaming)
/**
* @readonly
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
public function __construct(StaticTypeMapper $staticTypeMapper, PropertyNaming $propertyNaming, NodeTypeResolver $nodeTypeResolver)
{
$this->staticTypeMapper = $staticTypeMapper;
$this->propertyNaming = $propertyNaming;
$this->nodeTypeResolver = $nodeTypeResolver;
}
public function resolve(Param $param) : ?string
{
@ -33,9 +40,9 @@ final class MatchParamTypeExpectedNameResolver
return null;
}
$staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
// include nullable too
// include nullabgitle too
// skip date time + date time interface, as should be kept
if ($this->isDateTimeType($staticType)) {
if ($this->nodeTypeResolver->isObjectType($param->type, new ObjectType('DateTimeInterface'))) {
return null;
}
$expectedName = $this->propertyNaming->getExpectedNameFromType($staticType);
@ -44,11 +51,4 @@ final class MatchParamTypeExpectedNameResolver
}
return $expectedName->getName();
}
private function isDateTimeType(Type $type) : bool
{
if ($type->isSuperTypeOf(new ObjectType('DateTimeInterface'))->yes()) {
return \true;
}
return $type->isSuperTypeOf(new ObjectType('DateTime'))->yes();
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '0a2dc3d52b679bad1b07849d951748a8faad7f9a';
public const PACKAGE_VERSION = '14f11280c85a2776b211dac001f0accd4295c587';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-12-08 13:56:59';
public const RELEASE_DATE = '2023-12-08 21:39:23';
/**
* @var int
*/