mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit f6c3e95d7bc61d0baeef95fa98721000871db0df
f6c3e95d7b
[TypeDeclaration] Improve PropertyTypeDeclarationRector to work with strict types (#1494)
This commit is contained in:
parent
a440c65f29
commit
79317e0a0f
@ -7760,7 +7760,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
|
||||
$services->set(TypedPropertyRector::class)
|
||||
->configure([
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false,
|
||||
TypedPropertyRector::PRIVATE_PROPERTY_ONLY => false,
|
||||
]);
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\TypeComparator;
|
||||
|
||||
use PHPStan\Type\BooleanType;
|
||||
use PHPStan\Type\ClassStringType;
|
||||
use PHPStan\Type\FloatType;
|
||||
use PHPStan\Type\IntegerType;
|
||||
use PHPStan\Type\StringType;
|
||||
@ -32,4 +33,40 @@ final class ScalarTypeComparator
|
||||
}
|
||||
return $secondType instanceof \PHPStan\Type\BooleanType;
|
||||
}
|
||||
/**
|
||||
* E.g. first is string, second is bool
|
||||
*/
|
||||
public function areDifferentScalarTypes(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
|
||||
{
|
||||
if (!$this->isScalarType($firstType)) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->isScalarType($secondType)) {
|
||||
return \false;
|
||||
}
|
||||
// treat class-string and string the same
|
||||
if ($firstType instanceof \PHPStan\Type\ClassStringType && $secondType instanceof \PHPStan\Type\StringType) {
|
||||
return \false;
|
||||
}
|
||||
if (!$firstType instanceof \PHPStan\Type\StringType) {
|
||||
return \get_class($firstType) !== \get_class($secondType);
|
||||
}
|
||||
if (!$secondType instanceof \PHPStan\Type\ClassStringType) {
|
||||
return \get_class($firstType) !== \get_class($secondType);
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function isScalarType(\PHPStan\Type\Type $type) : bool
|
||||
{
|
||||
if ($type instanceof \PHPStan\Type\StringType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof \PHPStan\Type\FloatType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof \PHPStan\Type\IntegerType) {
|
||||
return \true;
|
||||
}
|
||||
return $type instanceof \PHPStan\Type\BooleanType;
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,9 @@ final class TypeComparator
|
||||
// normalize bool union types
|
||||
$phpParserNodeType = $this->normalizeConstantBooleanType($phpParserNodeType);
|
||||
$phpStanDocType = $this->normalizeConstantBooleanType($phpStanDocType);
|
||||
if (!$this->areTypesEqual($phpParserNodeType, $phpStanDocType)) {
|
||||
// is scalar replace by another - remove it?
|
||||
$areDifferentScalarTypes = $this->scalarTypeComparator->areDifferentScalarTypes($phpParserNodeType, $phpStanDocType);
|
||||
if (!$areDifferentScalarTypes && !$this->areTypesEqual($phpParserNodeType, $phpStanDocType)) {
|
||||
return \false;
|
||||
}
|
||||
// special case for non-final $this/self compare; in case of interface/abstract class, it can be another $this
|
||||
|
@ -11,6 +11,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\Generic\TemplateObjectWithoutClassType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
@ -66,6 +67,9 @@ final class VarTagRemover
|
||||
*/
|
||||
public function removeVarPhpTagValueNodeIfNotComment($node, \PHPStan\Type\Type $type) : void
|
||||
{
|
||||
if ($type instanceof \PHPStan\Type\Generic\TemplateObjectWithoutClassType) {
|
||||
return;
|
||||
}
|
||||
// keep doctrine collection narrow type
|
||||
if ($this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($type)) {
|
||||
return;
|
||||
|
@ -6,12 +6,10 @@ namespace Rector\Php74\Rector\Property;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\Generic\TemplateType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\NullType;
|
||||
@ -27,10 +25,8 @@ use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer;
|
||||
use Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
|
||||
use Rector\VendorLocker\VendorLockResolver;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
@ -43,23 +39,13 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
* @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\ClassLikeTypesOnlyTest
|
||||
* @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\DoctrineTypedPropertyRectorTest
|
||||
* @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\ImportedTest
|
||||
* @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\UnionTypedPropertyRectorTest
|
||||
*/
|
||||
final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CLASS_LIKE_TYPE_ONLY = 'class_like_type_only';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PRIVATE_PROPERTY_ONLY = 'PRIVATE_PROPERTY_ONLY';
|
||||
/**
|
||||
* Useful for refactoring of huge applications. Taking types first narrows scope
|
||||
* @var bool
|
||||
*/
|
||||
private $classLikeTypeOnly = \false;
|
||||
/**
|
||||
* If want to keep BC, it can be set to true
|
||||
* @see https://3v4l.org/spl4P
|
||||
@ -86,11 +72,6 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector imple
|
||||
* @var \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover
|
||||
*/
|
||||
private $varTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \PHPStan\Reflection\ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer
|
||||
@ -106,11 +87,6 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector imple
|
||||
* @var \Rector\Core\NodeAnalyzer\PropertyAnalyzer
|
||||
*/
|
||||
private $propertyAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver
|
||||
*/
|
||||
private $propertyUnionTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\AstResolver
|
||||
@ -121,17 +97,15 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector imple
|
||||
* @var \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer
|
||||
*/
|
||||
private $objectTypeAnalyzer;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver $propertyUnionTypeResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer $objectTypeAnalyzer)
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer $objectTypeAnalyzer)
|
||||
{
|
||||
$this->propertyTypeInferer = $propertyTypeInferer;
|
||||
$this->vendorLockResolver = $vendorLockResolver;
|
||||
$this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer;
|
||||
$this->varTagRemover = $varTagRemover;
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->familyRelationsAnalyzer = $familyRelationsAnalyzer;
|
||||
$this->propertyAnalyzer = $propertyAnalyzer;
|
||||
$this->propertyUnionTypeResolver = $propertyUnionTypeResolver;
|
||||
$this->astResolver = $astResolver;
|
||||
$this->objectTypeAnalyzer = $objectTypeAnalyzer;
|
||||
}
|
||||
@ -152,7 +126,7 @@ final class SomeClass
|
||||
private int $count;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [self::CLASS_LIKE_TYPE_ONLY => \false, self::PRIVATE_PROPERTY_ONLY => \false])]);
|
||||
, [self::PRIVATE_PROPERTY_ONLY => \false])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
@ -185,7 +159,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($this->isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($propertyTypeNode, $node, $varType)) {
|
||||
if ($this->isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($propertyTypeNode, $node)) {
|
||||
return null;
|
||||
}
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
@ -203,7 +177,6 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->classLikeTypeOnly = $configuration[self::CLASS_LIKE_TYPE_ONLY] ?? \false;
|
||||
$this->privatePropertyOnly = $configuration[self::PRIVATE_PROPERTY_ONLY] ?? \false;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
@ -213,16 +186,11 @@ CODE_SAMPLE
|
||||
/**
|
||||
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Name|null $node
|
||||
*/
|
||||
private function isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($node, \PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $type) : bool
|
||||
private function isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($node, \PhpParser\Node\Stmt\Property $property) : bool
|
||||
{
|
||||
if (!$node instanceof \PhpParser\Node) {
|
||||
return \true;
|
||||
}
|
||||
$type = $this->propertyUnionTypeResolver->resolve($node, $type);
|
||||
// is not class-type and should be skipped
|
||||
if ($this->shouldSkipNonClassLikeType($node, $type)) {
|
||||
return \true;
|
||||
}
|
||||
// false positive
|
||||
if (!$node instanceof \PhpParser\Node\Name) {
|
||||
return $this->vendorLockResolver->isPropertyTypeChangeVendorLockedIn($property);
|
||||
@ -232,27 +200,6 @@ CODE_SAMPLE
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Name $node
|
||||
*/
|
||||
private function shouldSkipNonClassLikeType($node, \PHPStan\Type\Type $type) : bool
|
||||
{
|
||||
// unwrap nullable type
|
||||
if ($node instanceof \PhpParser\Node\NullableType) {
|
||||
$node = $node->type;
|
||||
}
|
||||
$typeName = $this->getName($node);
|
||||
if ($typeName === null) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->classLikeTypeOnly) {
|
||||
return \false;
|
||||
}
|
||||
if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) {
|
||||
$typeName = $type->getFullyQualifiedName();
|
||||
}
|
||||
return !$this->reflectionProvider->hasClass($typeName);
|
||||
}
|
||||
private function removeDefaultValueForDoctrineCollection(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void
|
||||
{
|
||||
if (!$this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($propertyType)) {
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php74\TypeAnalyzer;
|
||||
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\UnionType;
|
||||
final class PropertyUnionTypeResolver
|
||||
{
|
||||
/**
|
||||
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Name $phpUnionType
|
||||
*/
|
||||
public function resolve($phpUnionType, \PHPStan\Type\Type $possibleUnionType) : \PHPStan\Type\Type
|
||||
{
|
||||
if (!$phpUnionType instanceof \PhpParser\Node\NullableType) {
|
||||
return $possibleUnionType;
|
||||
}
|
||||
if (!$possibleUnionType instanceof \PHPStan\Type\UnionType) {
|
||||
return $possibleUnionType;
|
||||
}
|
||||
$types = $possibleUnionType->getTypes();
|
||||
foreach ($types as $type) {
|
||||
if (!$type instanceof \PHPStan\Type\NullType) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
return $possibleUnionType;
|
||||
}
|
||||
}
|
@ -5,15 +5,20 @@ namespace Rector\TypeDeclaration\Rector\Property;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\UnionType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @deprecated Split to smaller specific rules.
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\PropertyTypeDeclarationRectorTest
|
||||
*/
|
||||
final class PropertyTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector
|
||||
@ -91,6 +96,9 @@ CODE_SAMPLE
|
||||
if (!$node->isPrivate() && $type instanceof \PHPStan\Type\NullType) {
|
||||
return null;
|
||||
}
|
||||
if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
return $this->completeTypedProperty($type, $node, $phpDocInfo);
|
||||
}
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $type);
|
||||
return $node;
|
||||
}
|
||||
@ -104,4 +112,18 @@ CODE_SAMPLE
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function completeTypedProperty(\PHPStan\Type\Type $type, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : \PhpParser\Node\Stmt\Property
|
||||
{
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($propertyTypeNode instanceof \PhpParser\Node\UnionType) {
|
||||
if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) {
|
||||
$property->type = $propertyTypeNode;
|
||||
return $property;
|
||||
}
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $type);
|
||||
return $property;
|
||||
}
|
||||
$property->type = $propertyTypeNode;
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
@ -7,18 +7,18 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector\TypedPropertyFromStrictConstructorRectorTest
|
||||
*/
|
||||
final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface
|
||||
final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
@ -30,10 +30,16 @@ final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector
|
||||
* @var \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover
|
||||
*/
|
||||
private $varTagRemover;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer $constructorPropertyTypeInferer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer $constructorPropertyTypeInferer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger)
|
||||
{
|
||||
$this->constructorPropertyTypeInferer = $constructorPropertyTypeInferer;
|
||||
$this->varTagRemover = $varTagRemover;
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -83,13 +89,17 @@ CODE_SAMPLE
|
||||
if ($varType instanceof \PHPStan\Type\MixedType) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $varType);
|
||||
return $node;
|
||||
}
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if (!$propertyTypeNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
$node->type = $propertyTypeNode;
|
||||
$node->props[0]->default = null;
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$this->varTagRemover->removeVarTagIfUseless($phpDocInfo, $node);
|
||||
return $node;
|
||||
}
|
||||
|
@ -10,28 +10,40 @@ use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector\TypedPropertyFromStrictGetterMethodReturnTypeRectorTest
|
||||
* @todo make generic
|
||||
*/
|
||||
final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface
|
||||
final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer
|
||||
*/
|
||||
private $getterTypeDeclarationPropertyTypeInferer;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer $getterTypeDeclarationPropertyTypeInferer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover
|
||||
*/
|
||||
private $varTagRemover;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer $getterTypeDeclarationPropertyTypeInferer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover)
|
||||
{
|
||||
$this->getterTypeDeclarationPropertyTypeInferer = $getterTypeDeclarationPropertyTypeInferer;
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
$this->varTagRemover = $varTagRemover;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -81,6 +93,11 @@ CODE_SAMPLE
|
||||
if (!$getterReturnType instanceof \PHPStan\Type\Type) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $getterReturnType);
|
||||
return $node;
|
||||
}
|
||||
// if property is public, it should be nullable
|
||||
if ($node->isPublic() && !\PHPStan\Type\TypeCombinator::containsNull($getterReturnType)) {
|
||||
$getterReturnType = \PHPStan\Type\TypeCombinator::addNull($getterReturnType);
|
||||
@ -91,6 +108,8 @@ CODE_SAMPLE
|
||||
}
|
||||
$node->type = $propertyType;
|
||||
$this->decorateDefaultNull($getterReturnType, $node);
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$this->varTagRemover->removeVarTagIfUseless($phpDocInfo, $node);
|
||||
return $node;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
|
@ -29,9 +29,8 @@ use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface;
|
||||
use RectorPrefix20211214\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class ConstructorPropertyTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface
|
||||
final class ConstructorPropertyTypeInferer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
@ -111,10 +110,6 @@ final class ConstructorPropertyTypeInferer implements \Rector\TypeDeclaration\Co
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
return 800;
|
||||
}
|
||||
private function resolveFromParamType(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : \PHPStan\Type\Type
|
||||
{
|
||||
$type = $this->resolveParamTypeToPHPStanType($param);
|
||||
|
@ -17,6 +17,9 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface;
|
||||
/**
|
||||
* @deprecated Move to rector-doctrine, under code quality
|
||||
*/
|
||||
final class DoctrineColumnPropertyTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface
|
||||
{
|
||||
/**
|
||||
|
@ -17,6 +17,9 @@ use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface;
|
||||
use Rector\TypeDeclaration\PhpDoc\ShortClassExpander;
|
||||
/**
|
||||
* @deprecated Move to rector-doctrine, under code quality
|
||||
*/
|
||||
final class DoctrineRelationPropertyTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface
|
||||
{
|
||||
/**
|
||||
|
@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
|
||||
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface;
|
||||
use Rector\TypeDeclaration\FunctionLikeReturnTypeResolver;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnedNodesReturnTypeInferer;
|
||||
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTagReturnTypeInferer;
|
||||
final class GetterPropertyTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTagReturnTypeInferer
|
||||
*/
|
||||
private $returnTagReturnTypeInferer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnedNodesReturnTypeInferer
|
||||
*/
|
||||
private $returnedNodesReturnTypeInferer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\FunctionLikeReturnTypeResolver
|
||||
*/
|
||||
private $functionLikeReturnTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer
|
||||
*/
|
||||
private $classMethodAndPropertyAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\AstResolver
|
||||
*/
|
||||
private $astResolver;
|
||||
public function __construct(\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTagReturnTypeInferer $returnTagReturnTypeInferer, \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnedNodesReturnTypeInferer $returnedNodesReturnTypeInferer, \Rector\TypeDeclaration\FunctionLikeReturnTypeResolver $functionLikeReturnTypeResolver, \Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer $classMethodAndPropertyAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\AstResolver $astResolver)
|
||||
{
|
||||
$this->returnTagReturnTypeInferer = $returnTagReturnTypeInferer;
|
||||
$this->returnedNodesReturnTypeInferer = $returnedNodesReturnTypeInferer;
|
||||
$this->functionLikeReturnTypeResolver = $functionLikeReturnTypeResolver;
|
||||
$this->classMethodAndPropertyAnalyzer = $classMethodAndPropertyAnalyzer;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->astResolver = $astResolver;
|
||||
}
|
||||
public function inferProperty(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type
|
||||
{
|
||||
$class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class);
|
||||
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return null;
|
||||
}
|
||||
/** @var string $propertyName */
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
$returnTypes = [];
|
||||
$classAndTraitMethods = $this->resolveClassAndTraitMethods($class);
|
||||
foreach ($classAndTraitMethods as $classAndTraitMethod) {
|
||||
if (!$this->classMethodAndPropertyAnalyzer->hasClassMethodOnlyStatementReturnOfPropertyFetch($classAndTraitMethod, $propertyName)) {
|
||||
continue;
|
||||
}
|
||||
$returnType = $this->inferClassMethodReturnType($classAndTraitMethod);
|
||||
if ($returnType instanceof \PHPStan\Type\MixedType) {
|
||||
continue;
|
||||
}
|
||||
$returnTypes[] = $returnType;
|
||||
}
|
||||
if ($returnTypes === []) {
|
||||
return null;
|
||||
}
|
||||
if (\count($returnTypes) === 1) {
|
||||
return $returnTypes[0];
|
||||
}
|
||||
return new \PHPStan\Type\UnionType($returnTypes);
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
return 1700;
|
||||
}
|
||||
private function inferClassMethodReturnType(\PhpParser\Node\Stmt\ClassMethod $classMethod) : \PHPStan\Type\Type
|
||||
{
|
||||
$returnTypeDeclarationType = $this->functionLikeReturnTypeResolver->resolveFunctionLikeReturnTypeToPHPStanType($classMethod);
|
||||
if (!$returnTypeDeclarationType instanceof \PHPStan\Type\MixedType) {
|
||||
return $returnTypeDeclarationType;
|
||||
}
|
||||
$inferedType = $this->returnedNodesReturnTypeInferer->inferFunctionLike($classMethod);
|
||||
if (!$inferedType instanceof \PHPStan\Type\MixedType) {
|
||||
return $inferedType;
|
||||
}
|
||||
return $this->returnTagReturnTypeInferer->inferFunctionLike($classMethod);
|
||||
}
|
||||
/**
|
||||
* @return ClassMethod[]
|
||||
*/
|
||||
private function resolveClassAndTraitMethods(\PhpParser\Node\Stmt\Class_ $class) : array
|
||||
{
|
||||
$classAndTraitMethods = $class->getMethods();
|
||||
foreach ($class->getTraitUses() as $traitUse) {
|
||||
foreach ($traitUse->traits as $traitName) {
|
||||
$trait = $this->astResolver->resolveClassFromName($traitName->toString());
|
||||
if (!$trait instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
continue;
|
||||
}
|
||||
$classAndTraitMethods = \array_merge($classAndTraitMethods, $trait->getMethods());
|
||||
}
|
||||
}
|
||||
return $classAndTraitMethods;
|
||||
}
|
||||
}
|
@ -11,10 +11,9 @@ use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface;
|
||||
use Rector\TypeDeclaration\FunctionLikeReturnTypeResolver;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer;
|
||||
final class GetterTypeDeclarationPropertyTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\PropertyTypeInfererInterface
|
||||
final class GetterTypeDeclarationPropertyTypeInferer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
@ -67,8 +66,4 @@ final class GetterTypeDeclarationPropertyTypeInferer implements \Rector\TypeDecl
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
return 630;
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7cdd03ed7733e2d8d12d68e5750a89b7f0dda829';
|
||||
public const PACKAGE_VERSION = 'f6c3e95d7bc61d0baeef95fa98721000871db0df';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-12-14 14:22:38';
|
||||
public const RELEASE_DATE = '2021-12-14 15:15:08';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211214\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1::getLoader();
|
||||
return ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36::getLoader();
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -2598,7 +2598,6 @@ return array(
|
||||
'Rector\\Php74\\Rector\\StaticCall\\ExportToReflectionFunctionRector' => $baseDir . '/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php',
|
||||
'Rector\\Php74\\Tokenizer\\FollowedByCurlyBracketAnalyzer' => $baseDir . '/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php',
|
||||
'Rector\\Php74\\TypeAnalyzer\\ObjectTypeAnalyzer' => $baseDir . '/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php',
|
||||
'Rector\\Php74\\TypeAnalyzer\\PropertyUnionTypeResolver' => $baseDir . '/rules/Php74/TypeAnalyzer/PropertyUnionTypeResolver.php',
|
||||
'Rector\\Php80\\Contract\\StrStartWithMatchAndRefactorInterface' => $baseDir . '/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php',
|
||||
'Rector\\Php80\\Enum\\MatchKind' => $baseDir . '/rules/Php80/Enum/MatchKind.php',
|
||||
'Rector\\Php80\\MatchAndRefactor\\StrStartsWithMatchAndRefactor\\StrncmpMatchAndRefactor' => $baseDir . '/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php',
|
||||
@ -3092,7 +3091,6 @@ return array(
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DefaultValuePropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DoctrineColumnPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DoctrineColumnPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DoctrineRelationPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DoctrineRelationPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\GetterPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\GetterTypeDeclarationPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\SingleMethodAssignedNodePropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/SingleMethodAssignedNodePropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\VarDocPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/VarDocPropertyTypeInferer.php',
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
class ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36', '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\ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit12bb9e769debccf33e537fe22597fd36::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit12bb9e769debccf33e537fe22597fd36::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirecbee6bf1ebafa9718d4919e8805e81a1($fileIdentifier, $file);
|
||||
composerRequire12bb9e769debccf33e537fe22597fd36($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequirecbee6bf1ebafa9718d4919e8805e81a1($fileIdentifier, $file)
|
||||
function composerRequire12bb9e769debccf33e537fe22597fd36($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
class ComposerStaticInit12bb9e769debccf33e537fe22597fd36
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -2993,7 +2993,6 @@ class ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
'Rector\\Php74\\Rector\\StaticCall\\ExportToReflectionFunctionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php',
|
||||
'Rector\\Php74\\Tokenizer\\FollowedByCurlyBracketAnalyzer' => __DIR__ . '/../..' . '/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php',
|
||||
'Rector\\Php74\\TypeAnalyzer\\ObjectTypeAnalyzer' => __DIR__ . '/../..' . '/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php',
|
||||
'Rector\\Php74\\TypeAnalyzer\\PropertyUnionTypeResolver' => __DIR__ . '/../..' . '/rules/Php74/TypeAnalyzer/PropertyUnionTypeResolver.php',
|
||||
'Rector\\Php80\\Contract\\StrStartWithMatchAndRefactorInterface' => __DIR__ . '/../..' . '/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php',
|
||||
'Rector\\Php80\\Enum\\MatchKind' => __DIR__ . '/../..' . '/rules/Php80/Enum/MatchKind.php',
|
||||
'Rector\\Php80\\MatchAndRefactor\\StrStartsWithMatchAndRefactor\\StrncmpMatchAndRefactor' => __DIR__ . '/../..' . '/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php',
|
||||
@ -3487,7 +3486,6 @@ class ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DefaultValuePropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DoctrineColumnPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DoctrineColumnPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\DoctrineRelationPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DoctrineRelationPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\GetterPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\GetterTypeDeclarationPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\SingleMethodAssignedNodePropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/SingleMethodAssignedNodePropertyTypeInferer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\PropertyTypeInferer\\VarDocPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/VarDocPropertyTypeInferer.php',
|
||||
@ -3823,9 +3821,9 @@ class ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcbee6bf1ebafa9718d4919e8805e81a1::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit12bb9e769debccf33e537fe22597fd36::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit12bb9e769debccf33e537fe22597fd36::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit12bb9e769debccf33e537fe22597fd36::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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('RectorPrefix20211214\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1', false) && !interface_exists('ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1', false) && !trait_exists('ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1', false)) {
|
||||
spl_autoload_call('RectorPrefix20211214\ComposerAutoloaderInitcbee6bf1ebafa9718d4919e8805e81a1');
|
||||
if (!class_exists('ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36', false) && !interface_exists('ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36', false) && !trait_exists('ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36', false)) {
|
||||
spl_autoload_call('RectorPrefix20211214\ComposerAutoloaderInit12bb9e769debccf33e537fe22597fd36');
|
||||
}
|
||||
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('RectorPrefix20211214\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -78,9 +78,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20211214\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequirecbee6bf1ebafa9718d4919e8805e81a1')) {
|
||||
function composerRequirecbee6bf1ebafa9718d4919e8805e81a1() {
|
||||
return \RectorPrefix20211214\composerRequirecbee6bf1ebafa9718d4919e8805e81a1(...func_get_args());
|
||||
if (!function_exists('composerRequire12bb9e769debccf33e537fe22597fd36')) {
|
||||
function composerRequire12bb9e769debccf33e537fe22597fd36() {
|
||||
return \RectorPrefix20211214\composerRequire12bb9e769debccf33e537fe22597fd36(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user