Updated Rector to commit f2afe8ed6e

f2afe8ed6e [DX] Move from deprecated getStaticType() to getType() (#974)
This commit is contained in:
Tomas Votruba 2021-10-07 18:52:22 +00:00
parent 61389a9b2c
commit 6154cc59ea
40 changed files with 160 additions and 83 deletions

View File

@ -171,6 +171,10 @@ final class NodeTypeResolver
if ($type !== null) {
$type = $this->accessoryNonEmptyStringTypeCorrector->correct($type);
$type = $this->genericClassStringTypeCorrector->correct($type);
if ($type instanceof \PHPStan\Type\ObjectType) {
// we want to keep aliased object types
$type = $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $type);
}
return $this->hasOffsetTypeCorrector->correct($type);
}
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
@ -222,6 +226,10 @@ final class NodeTypeResolver
}
return $scope->getNativeType($expr);
}
/**
* @deprecated
* @see Use NodeTypeResolver::getType() instead
*/
public function getStaticType(\PhpParser\Node $node) : \PHPStan\Type\Type
{
if ($node instanceof \PhpParser\Node\Param || $node instanceof \PhpParser\Node\Expr\New_ || $node instanceof \PhpParser\Node\Stmt\Return_) {

View File

@ -19,7 +19,7 @@ final class StringTypeAnalyzer
}
public function isStringOrUnionStringOnlyType(\PhpParser\Node $node) : bool
{
$nodeType = $this->nodeTypeResolver->getStaticType($node);
$nodeType = $this->nodeTypeResolver->getType($node);
if ($nodeType instanceof \PHPStan\Type\StringType) {
return \true;
}

View File

@ -40,6 +40,9 @@ final class NullTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY())) {
return null;
}
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM())) {
return null;
}
// return type cannot be only null
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN())) {
return null;

View File

@ -0,0 +1,9 @@
<?php
declare (strict_types=1);
namespace Rector\StaticTypeMapper\ValueObject\Type;
use PHPStan\Type\ObjectType;
final class NonExistingObjectType extends \PHPStan\Type\ObjectType
{
}

View File

@ -0,0 +1,42 @@
<?php
declare (strict_types=1);
namespace Rector\StaticTypeMapper\ValueObject\Type;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\Type;
final class ShortenedGenericObjectType extends \PHPStan\Type\Generic\GenericObjectType
{
/**
* @var class-string
*/
private $fullyQualifiedName;
/**
* @param class-string $fullyQualifiedName
*/
public function __construct(string $shortName, array $types, string $fullyQualifiedName)
{
$this->fullyQualifiedName = $fullyQualifiedName;
parent::__construct($shortName, $types);
}
/**
* @param \PHPStan\Type\Type $type
*/
public function isSuperTypeOf($type) : \PHPStan\TrinaryLogic
{
$genericObjectType = new \PHPStan\Type\Generic\GenericObjectType($this->fullyQualifiedName, $this->getTypes());
return $genericObjectType->isSuperTypeOf($type);
}
public function getShortName() : string
{
return $this->getClassName();
}
/**
* @return class-string
*/
public function getFullyQualifiedName() : string
{
return $this->fullyQualifiedName;
}
}

View File

@ -131,7 +131,7 @@ final class LocalPropertyAnalyzer
$parentNode = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
// possible get type
if ($parentNode instanceof \PhpParser\Node\Expr\Assign) {
return $this->nodeTypeResolver->getStaticType($parentNode->expr);
return $this->nodeTypeResolver->getType($parentNode->expr);
}
if ($parentNode instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
return $this->arrayDimFetchTypeResolver->resolve($parentNode);

View File

@ -47,7 +47,7 @@ final class ExprBoolCaster
}
return new \PhpParser\Node\Expr\Cast\Bool_($expr);
}
$exprStaticType = $this->nodeTypeResolver->getStaticType($expr);
$exprStaticType = $this->nodeTypeResolver->getType($expr);
// if we remove null type, still has to be trueable
if ($exprStaticType instanceof \PHPStan\Type\UnionType) {
$unionTypeWithoutNullType = $this->typeUnwrapper->removeNullTypeFromUnionType($exprStaticType);

View File

@ -29,7 +29,7 @@ final class ArrayDimFetchTypeResolver
private function resolveDimType(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PHPStan\Type\Type
{
if ($arrayDimFetch->dim !== null) {
return $this->nodeTypeResolver->getStaticType($arrayDimFetch->dim);
return $this->nodeTypeResolver->getType($arrayDimFetch->dim);
}
return new \PHPStan\Type\MixedType();
}
@ -37,7 +37,7 @@ final class ArrayDimFetchTypeResolver
{
$parentParent = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if ($parentParent instanceof \PhpParser\Node\Expr\Assign) {
return $this->nodeTypeResolver->getStaticType($parentParent->expr);
return $this->nodeTypeResolver->getType($parentParent->expr);
}
return new \PHPStan\Type\MixedType();
}

View File

@ -25,7 +25,7 @@ final class ExprStringTypeResolver
}
public function resolve(\PhpParser\Node\Expr $expr) : ?string
{
$exprStaticType = $this->nodeTypeResolver->getStaticType($expr);
$exprStaticType = $this->nodeTypeResolver->getType($expr);
$exprStaticType = $this->typeUnwrapper->unwrapNullableType($exprStaticType);
if (!$exprStaticType instanceof \PHPStan\Type\TypeWithClassName) {
// nothing we can do, unless

View File

@ -91,12 +91,12 @@ final class FluentChainMethodCallNodeAnalyzer
if ($this->callAnalyzer->isObjectCall($methodCall->var)) {
return \false;
}
$calleeStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
$calleeStaticType = $this->nodeTypeResolver->getType($methodCall->var);
// we're not sure
if ($calleeStaticType instanceof \PHPStan\Type\MixedType) {
return \false;
}
$methodReturnStaticType = $this->nodeTypeResolver->getStaticType($methodCall);
$methodReturnStaticType = $this->nodeTypeResolver->getType($methodCall);
// is fluent type
if (!$calleeStaticType->equals($methodReturnStaticType)) {
return \false;

View File

@ -109,7 +109,7 @@ final class FluentChainMethodCallRootExtractor
{
$isFirstCallFactory = $this->isFirstMethodCallFactory($methodCall);
// the method call, does not belong to the
$staticType = $this->nodeTypeResolver->getStaticType($methodCall);
$staticType = $this->nodeTypeResolver->getType($methodCall);
$parentNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
// no assign
if ($parentNode instanceof \PhpParser\Node\Stmt\Expression) {

View File

@ -20,8 +20,8 @@ final class GetterMethodCallAnalyzer
if ($methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) {
return \false;
}
$methodCallStaticType = $this->nodeTypeResolver->getStaticType($methodCall);
$methodCallVarStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
$methodCallStaticType = $this->nodeTypeResolver->getType($methodCall);
$methodCallVarStaticType = $this->nodeTypeResolver->getType($methodCall->var);
// getter short call type
return !$methodCallStaticType->equals($methodCallVarStaticType);
}

View File

@ -20,8 +20,8 @@ final class NewFluentChainMethodCallNodeAnalyzer
}
public function isNewMethodCallReturningSelf(\PhpParser\Node\Expr\MethodCall $methodCall) : bool
{
$newStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
$methodCallStaticType = $this->nodeTypeResolver->getStaticType($methodCall);
$newStaticType = $this->nodeTypeResolver->getType($methodCall->var);
$methodCallStaticType = $this->nodeTypeResolver->getType($methodCall);
return $methodCallStaticType->equals($newStaticType);
}
/**

View File

@ -44,7 +44,7 @@ final class ReturnFluentMethodCallFactory
} else {
// we need a variable to assign the stuff into
// the method call, does not belong to the
$staticType = $this->nodeTypeResolver->getStaticType($rootMethodCall);
$staticType = $this->nodeTypeResolver->getType($rootMethodCall);
if (!$staticType instanceof \PHPStan\Type\ObjectType) {
return null;
}

View File

@ -113,7 +113,7 @@ final class ExpectedNameResolver
if ($name === null) {
return null;
}
$returnedType = $this->nodeTypeResolver->getStaticType($expr);
$returnedType = $this->nodeTypeResolver->getType($expr);
if ($returnedType instanceof \PHPStan\Type\ArrayType) {
return null;
}
@ -146,7 +146,7 @@ final class ExpectedNameResolver
if ($name === null) {
return null;
}
$returnedType = $this->nodeTypeResolver->getStaticType($expr);
$returnedType = $this->nodeTypeResolver->getType($expr);
if ($returnedType->isIterable()->no()) {
return null;
}

View File

@ -98,7 +98,7 @@ final class VariableNaming
}
public function resolveFromNode(\PhpParser\Node $node) : ?string
{
$nodeType = $this->nodeTypeResolver->getStaticType($node);
$nodeType = $this->nodeTypeResolver->getType($node);
return $this->resolveFromNodeAndType($node, $nodeType);
}
private function resolveBareFromNode(\PhpParser\Node $node) : ?string

View File

@ -3,29 +3,14 @@
declare (strict_types=1);
namespace Rector\Php73\NodeTypeAnalyzer;
use PhpParser\Node\Expr;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\NodeTypeResolver\NodeTypeResolver;
final class NodeTypeAnalyzer
{
/**
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver)
{
$this->nodeTypeResolver = $nodeTypeResolver;
}
public function isStringTypeExpr(\PhpParser\Node\Expr $expr) : bool
{
$staticType = $this->nodeTypeResolver->getStaticType($expr);
return $this->isStringType($staticType);
}
private function isStringType(\PHPStan\Type\Type $type) : bool
public function isStringyType(\PHPStan\Type\Type $type) : bool
{
if ($type instanceof \PHPStan\Type\StringType) {
return \true;
@ -35,7 +20,7 @@ final class NodeTypeAnalyzer
}
if ($type instanceof \PHPStan\Type\IntersectionType || $type instanceof \PHPStan\Type\UnionType) {
foreach ($type->getTypes() as $innerType) {
if (!$this->isStringType($innerType)) {
if (!$this->isStringyType($innerType)) {
return \false;
}
}

View File

@ -7,6 +7,7 @@ use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Cast\String_;
use PhpParser\Node\Expr\FuncCall;
use PHPStan\Type\StringType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer;
@ -69,11 +70,15 @@ CODE_SAMPLE
return null;
}
// is argument string?
$needleArgNode = $node->args[1]->value;
if ($this->nodeTypeAnalyzer->isStringTypeExpr($needleArgNode)) {
$needleArgValue = $node->args[1]->value;
$needleType = $this->getType($needleArgValue);
if ($needleType instanceof \PHPStan\Type\StringType) {
return null;
}
if ($needleArgNode instanceof \PhpParser\Node\Expr\Cast\String_) {
if ($this->nodeTypeAnalyzer->isStringyType($needleType)) {
return null;
}
if ($needleArgValue instanceof \PhpParser\Node\Expr\Cast\String_) {
return null;
}
$node->args[1]->value = new \PhpParser\Node\Expr\Cast\String_($node->args[1]->value);

View File

@ -40,7 +40,7 @@ CODE_SAMPLE
/**
* @param Assign $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\AssignOp\Coalesce
{
if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) {
return null;

View File

@ -24,6 +24,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
use Rector\VendorLocker\VendorLockResolver;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -142,6 +143,10 @@ CODE_SAMPLE
return $node;
}
}
// we are not sure what object type this is
if ($varType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) {
return null;
}
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
if ($this->isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($propertyTypeNode, $node, $varType)) {
return null;

View File

@ -170,7 +170,7 @@ final class PromotedPropertyCandidateResolver
}
$matchedParamType = $this->nodeTypeResolver->resolve($param);
if ($param->default !== null) {
$defaultValueType = $this->nodeTypeResolver->getStaticType($param->default);
$defaultValueType = $this->nodeTypeResolver->getType($param->default);
$matchedParamType = $this->typeFactory->createMixedPassedOrUnionType([$matchedParamType, $defaultValueType]);
}
if (!$propertyType instanceof \PHPStan\Type\UnionType) {

View File

@ -85,7 +85,7 @@ final class TokenManipulator
if (!$this->isArrayDimFetchWithDimIntegerValue($node, 1)) {
return null;
}
$tokenStaticType = $this->nodeTypeResolver->getStaticType($node->var);
$tokenStaticType = $this->nodeTypeResolver->getType($node->var);
if (!$tokenStaticType instanceof \PHPStan\Type\ArrayType) {
return null;
}
@ -105,7 +105,7 @@ final class TokenManipulator
if (!$this->nodeComparator->areNodesEqual($node->expr, $singleTokenExpr)) {
return null;
}
$tokenStaticType = $this->nodeTypeResolver->getStaticType($node->expr);
$tokenStaticType = $this->nodeTypeResolver->getType($node->expr);
if ($tokenStaticType instanceof \PHPStan\Type\ArrayType) {
return null;
}
@ -116,7 +116,7 @@ final class TokenManipulator
if (!$node instanceof \PhpParser\Node\Expr\Assign) {
return null;
}
$tokenStaticType = $this->nodeTypeResolver->getStaticType($node->expr);
$tokenStaticType = $this->nodeTypeResolver->getType($node->expr);
if ($tokenStaticType instanceof \PHPStan\Type\ArrayType) {
return null;
}
@ -215,7 +215,7 @@ final class TokenManipulator
if (!$possibleTokenArray instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
return null;
}
$tokenStaticType = $this->nodeTypeResolver->getStaticType($possibleTokenArray->var);
$tokenStaticType = $this->nodeTypeResolver->getType($possibleTokenArray->var);
if (!$tokenStaticType instanceof \PHPStan\Type\ArrayType) {
return null;
}

View File

@ -59,7 +59,7 @@ final class NullTypeAssignDetector
return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
// not in doctrine property
$staticType = $this->nodeTypeResolver->getStaticType($expr);
$staticType = $this->nodeTypeResolver->getType($expr);
if ($this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($staticType)) {
$needsNullType = \false;
return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;

View File

@ -11,12 +11,14 @@ use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType;
final class ObjectTypeSpecifier
{
@ -55,7 +57,7 @@ final class ObjectTypeSpecifier
return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className);
}
// invalid type
return new \PHPStan\Type\MixedType();
return new \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType($className);
}
private function matchAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : ?\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType
{
@ -98,7 +100,10 @@ final class ObjectTypeSpecifier
}
return null;
}
private function matchShortenedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : ?\Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType
/**
* @return \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType|null
*/
private function matchShortenedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType)
{
/** @var Use_[]|null $uses */
$uses = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES);
@ -116,6 +121,10 @@ final class ObjectTypeSpecifier
}
$partialNamespaceObjectType = $this->matchClassWithLastUseImportPart($objectType, $useUse);
if ($partialNamespaceObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) {
// keep Generic items
if ($objectType instanceof \PHPStan\Type\Generic\GenericObjectType) {
return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType($objectType->getClassName(), $objectType->getTypes(), $partialNamespaceObjectType->getClassName());
}
return $partialNamespaceObjectType->getShortNameType();
}
if ($partialNamespaceObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) {

View File

@ -9,13 +9,13 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
use Rector\Defluent\ConflictGuard\ParentClassMethodTypeOverrideGuard;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
use Rector\TypeDeclaration\NodeTypeAnalyzer\TraitTypeAnalyzer;
use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer;
use Rector\TypeDeclaration\ValueObject\NewType;
@ -163,7 +163,7 @@ CODE_SAMPLE
if ($inferedType instanceof \PHPStan\Type\MixedType) {
return;
}
if ($inferedType instanceof \PHPStan\Type\NullType) {
if ($inferedType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) {
return;
}
if ($this->traitTypeAnalyzer->isTraitType($inferedType)) {

View File

@ -7,6 +7,7 @@ use PhpParser\Node;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\Core\Rector\AbstractRector;
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
@ -78,12 +79,8 @@ CODE_SAMPLE
return null;
}
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
// is already set
foreach (['@var', '@phpstan-var', '@psalm-var'] as $tagName) {
$varType = $phpDocInfo->getVarType($tagName);
if (!$varType instanceof \PHPStan\Type\MixedType) {
return null;
}
if ($this->isVarDocAlreadySet($phpDocInfo)) {
return null;
}
$type = $this->propertyTypeInferer->inferProperty($node);
if ($type instanceof \PHPStan\Type\MixedType) {
@ -95,4 +92,14 @@ CODE_SAMPLE
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $type);
return $node;
}
private function isVarDocAlreadySet(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool
{
foreach (['@var', '@phpstan-var', '@psalm-var'] as $tagName) {
$varType = $phpDocInfo->getVarType($tagName);
if (!$varType instanceof \PHPStan\Type\MixedType) {
return \true;
}
}
return \false;
}
}

View File

@ -84,7 +84,7 @@ final class AssignToPropertyTypeInferer
}
private function resolveExprStaticTypeIncludingDimFetch(\PhpParser\Node\Expr\Assign $assign) : \PHPStan\Type\Type
{
$exprStaticType = $this->nodeTypeResolver->getStaticType($assign->expr);
$exprStaticType = $this->nodeTypeResolver->getType($assign->expr);
if ($assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), $exprStaticType);
}

View File

@ -67,7 +67,7 @@ final class PropertyNodeParamTypeInferer implements \Rector\TypeDeclaration\Cont
if (!$this->propertyFetchAnalyzer->isVariableAssignToThisPropertyFetch($node, $paramName)) {
return null;
}
$staticType = $this->nodeTypeResolver->getStaticType($node->var);
$staticType = $this->nodeTypeResolver->getType($node->var);
if ($staticType !== null) {
$propertyStaticTypes[] = $staticType;
}

View File

@ -159,7 +159,7 @@ final class ConstructorPropertyTypeInferer implements \Rector\TypeDeclaration\Co
if (!$this->nodeNameResolver->isName($node, $propertyName)) {
return null;
}
$paramStaticType = $this->nodeTypeResolver->getStaticType($node);
$paramStaticType = $this->nodeTypeResolver->getType($node);
return \PhpParser\NodeTraverser::STOP_TRAVERSAL;
});
return $paramStaticType;
@ -170,7 +170,7 @@ final class ConstructorPropertyTypeInferer implements \Rector\TypeDeclaration\Co
return \true;
}
if ($param->default !== null) {
$defaultValueStaticType = $this->nodeTypeResolver->getStaticType($param->default);
$defaultValueStaticType = $this->nodeTypeResolver->getType($param->default);
if ($defaultValueStaticType instanceof \PHPStan\Type\NullType) {
return \true;
}

View File

@ -26,7 +26,7 @@ final class DefaultValuePropertyTypeInferer
if ($propertyProperty->default === null) {
return new \PHPStan\Type\MixedType();
}
return $this->nodeTypeResolver->getStaticType($propertyProperty->default);
return $this->nodeTypeResolver->getType($propertyProperty->default);
}
public function getPriority() : int
{

View File

@ -61,7 +61,7 @@ final class SingleMethodAssignedNodePropertyTypeInferer implements \Rector\TypeD
if (!$assignedNode instanceof \PhpParser\Node\Expr) {
return null;
}
return $this->nodeTypeResolver->getStaticType($assignedNode);
return $this->nodeTypeResolver->getType($assignedNode);
}
public function getPriority() : int
{

View File

@ -94,7 +94,7 @@ final class ReturnedNodesReturnTypeInferer implements \Rector\TypeDeclaration\Co
return $this->resolveNoLocalReturnNodes($classLike, $functionLike);
}
foreach ($localReturnNodes as $localReturnNode) {
$returnedExprType = $this->nodeTypeResolver->getStaticType($localReturnNode);
$returnedExprType = $this->nodeTypeResolver->getType($localReturnNode);
$returnedExprType = $this->correctWithNestedType($returnedExprType, $localReturnNode, $functionLike);
$types[] = $this->splArrayFixedTypeNarrower->narrow($returnedExprType);
}

View File

@ -55,7 +55,7 @@ final class YieldNodesReturnTypeInferer implements \Rector\TypeDeclaration\Contr
if (!$value instanceof \PhpParser\Node\Expr) {
continue;
}
$resolvedType = $this->nodeTypeResolver->getStaticType($value);
$resolvedType = $this->nodeTypeResolver->getType($value);
if ($resolvedType instanceof \PHPStan\Type\MixedType) {
continue;
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'f6f7431ce7aa36124efcda10e1b9ed16a5ccc343';
public const PACKAGE_VERSION = 'f2afe8ed6edb2e91082158c3a7b317b72a46fde8';
/**
* @var string
*/
public const RELEASE_DATE = '2021-10-07 19:34:41';
public const RELEASE_DATE = '2021-10-07 18:38:20';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211007\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -94,7 +94,7 @@ final class ValueResolver
if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) {
return $this->nodeNameResolver->getName($expr);
}
$nodeStaticType = $this->nodeTypeResolver->getStaticType($expr);
$nodeStaticType = $this->nodeTypeResolver->getType($expr);
if ($nodeStaticType instanceof \PHPStan\Type\Constant\ConstantArrayType) {
return $this->extractConstantArrayTypeValue($nodeStaticType);
}

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78::getLoader();
return ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83::getLoader();

View File

@ -2955,8 +2955,10 @@ return array(
'Rector\\StaticTypeMapper\\ValueObject\\Type\\AliasedObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedGenericObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\NonExistingObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ParentStaticType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\SelfObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ShortenedGenericObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ShortenedObjectType' => $baseDir . '/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php',
'Rector\\Strict\\NodeFactory\\ExactCompareFactory' => $baseDir . '/rules/Strict/NodeFactory/ExactCompareFactory.php',
'Rector\\Strict\\Rector\\AbstractFalsyScalarRuleFixerRector' => $baseDir . '/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78
class ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb370113e68d2f689ade55d3318a17c83::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitb370113e68d2f689ade55d3318a17c83::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire3dce88f69e2175ec99fe8e0ec6003c78($fileIdentifier, $file);
composerRequireb370113e68d2f689ade55d3318a17c83($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire3dce88f69e2175ec99fe8e0ec6003c78($fileIdentifier, $file)
function composerRequireb370113e68d2f689ade55d3318a17c83($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78
class ComposerStaticInitb370113e68d2f689ade55d3318a17c83
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3315,8 +3315,10 @@ class ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78
'Rector\\StaticTypeMapper\\ValueObject\\Type\\AliasedObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedGenericObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\NonExistingObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ParentStaticType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\SelfObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ShortenedGenericObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php',
'Rector\\StaticTypeMapper\\ValueObject\\Type\\ShortenedObjectType' => __DIR__ . '/../..' . '/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php',
'Rector\\Strict\\NodeFactory\\ExactCompareFactory' => __DIR__ . '/../..' . '/rules/Strict/NodeFactory/ExactCompareFactory.php',
'Rector\\Strict\\Rector\\AbstractFalsyScalarRuleFixerRector' => __DIR__ . '/../..' . '/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php',
@ -3891,9 +3893,9 @@ class ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3dce88f69e2175ec99fe8e0ec6003c78::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitb370113e68d2f689ade55d3318a17c83::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb370113e68d2f689ade55d3318a17c83::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb370113e68d2f689ade55d3318a17c83::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211007\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78', false) && !interface_exists('ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78', false) && !trait_exists('ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78', false)) {
spl_autoload_call('RectorPrefix20211007\ComposerAutoloaderInit3dce88f69e2175ec99fe8e0ec6003c78');
if (!class_exists('ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83', false) && !interface_exists('ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83', false) && !trait_exists('ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83', false)) {
spl_autoload_call('RectorPrefix20211007\ComposerAutoloaderInitb370113e68d2f689ade55d3318a17c83');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211007\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3306,9 +3306,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211007\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire3dce88f69e2175ec99fe8e0ec6003c78')) {
function composerRequire3dce88f69e2175ec99fe8e0ec6003c78() {
return \RectorPrefix20211007\composerRequire3dce88f69e2175ec99fe8e0ec6003c78(...func_get_args());
if (!function_exists('composerRequireb370113e68d2f689ade55d3318a17c83')) {
function composerRequireb370113e68d2f689ade55d3318a17c83() {
return \RectorPrefix20211007\composerRequireb370113e68d2f689ade55d3318a17c83(...func_get_args());
}
}
if (!function_exists('parseArgs')) {