mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit 3de7c697f5adc910481ff5873674284b2836dc50
3de7c697f5
[DX] Remove *AnnotationIncorrectNullableRector rules as works with unreliable docblocks and can have 2 solutions (#4719)
This commit is contained in:
parent
57a69ad4a0
commit
5602ee85cd
@ -14,10 +14,8 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnPar
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromStrictScalarReturnsRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
|
||||
@ -41,8 +39,7 @@ use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRea
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([AddArrowFunctionReturnTypeRector::class, ParamTypeByMethodCallTypeRector::class, TypedPropertyFromAssignsRector::class, ReturnAnnotationIncorrectNullableRector::class, VarAnnotationIncorrectNullableRector::class, ParamAnnotationIncorrectNullableRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, ReturnTypeFromStrictTypedPropertyRector::class, TypedPropertyFromStrictConstructorRector::class, TypedPropertyFromStrictConstructorReadonlyClassRector::class, ParamTypeFromStrictTypedPropertyRector::class, AddVoidReturnTypeWhereNoReturnRector::class, ReturnTypeFromReturnNewRector::class, TypedPropertyFromStrictGetterMethodReturnTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, ReturnTypeFromStrictBoolReturnExprRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, ReturnTypeFromStrictParamRector::class, TypedPropertyFromStrictSetUpRector::class, ParamTypeByParentCallTypeRector::class, AddParamTypeSplFixedArrayRector::class, AddParamTypeBasedOnPHPUnitDataProviderRector::class, AddParamTypeFromPropertyTypeRector::class, AddReturnTypeDeclarationFromYieldsRector::class, ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictTypedCallRector::class, ReturnNeverTypeRector::class, EmptyOnNullableObjectToInstanceOfRector::class, PropertyTypeFromStrictSetterGetterRector::class, ReturnTypeFromStrictTernaryRector::class, BoolReturnTypeFromStrictScalarReturnsRector::class, NumericReturnTypeFromStrictScalarReturnsRector::class, StrictArrayParamDimFetchRector::class, ReturnUnionTypeRector::class]);
|
||||
$rectorConfig->rules([AddArrowFunctionReturnTypeRector::class, ParamTypeByMethodCallTypeRector::class, TypedPropertyFromAssignsRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, ReturnTypeFromStrictTypedPropertyRector::class, TypedPropertyFromStrictConstructorRector::class, TypedPropertyFromStrictConstructorReadonlyClassRector::class, ParamTypeFromStrictTypedPropertyRector::class, AddVoidReturnTypeWhereNoReturnRector::class, ReturnTypeFromReturnNewRector::class, TypedPropertyFromStrictGetterMethodReturnTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, ReturnTypeFromStrictBoolReturnExprRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, ReturnTypeFromStrictParamRector::class, TypedPropertyFromStrictSetUpRector::class, ParamTypeByParentCallTypeRector::class, AddParamTypeSplFixedArrayRector::class, AddParamTypeBasedOnPHPUnitDataProviderRector::class, AddParamTypeFromPropertyTypeRector::class, AddReturnTypeDeclarationFromYieldsRector::class, ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictTypedCallRector::class, ReturnNeverTypeRector::class, EmptyOnNullableObjectToInstanceOfRector::class, PropertyTypeFromStrictSetterGetterRector::class, ReturnTypeFromStrictTernaryRector::class, BoolReturnTypeFromStrictScalarReturnsRector::class, NumericReturnTypeFromStrictScalarReturnsRector::class, StrictArrayParamDimFetchRector::class, ReturnUnionTypeRector::class]);
|
||||
$rectorConfig->rule(StrictStringParamConcatRector::class);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 360 Rules Overview
|
||||
# 357 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
|
||||
- [Transform](#transform) (22)
|
||||
|
||||
- [TypeDeclaration](#typedeclaration) (44)
|
||||
- [TypeDeclaration](#typedeclaration) (41)
|
||||
|
||||
- [Visibility](#visibility) (3)
|
||||
|
||||
@ -7701,30 +7701,6 @@ Change numeric return type based on strict returns type operations
|
||||
|
||||
<br>
|
||||
|
||||
### ParamAnnotationIncorrectNullableRector
|
||||
|
||||
Add or remove null type from `@param` phpdoc typehint based on php parameter type declaration
|
||||
|
||||
- class: [`Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector`](../rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php)
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
- * @param \DateTime[] $dateTimes
|
||||
+ * @param \DateTime[]|null $dateTimes
|
||||
*/
|
||||
public function setDateTimes(?array $dateTimes): self
|
||||
{
|
||||
$this->dateTimes = $dateTimes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### ParamTypeByMethodCallTypeRector
|
||||
|
||||
Change param type based on passed method call type
|
||||
@ -7829,28 +7805,6 @@ Add property type based on strict setter and getter method
|
||||
|
||||
<br>
|
||||
|
||||
### ReturnAnnotationIncorrectNullableRector
|
||||
|
||||
Add or remove null type from `@return` phpdoc typehint based on php return type declaration
|
||||
|
||||
- class: [`Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector`](../rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php)
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
- * @return \DateTime[]
|
||||
+ * @return \DateTime[]|null
|
||||
*/
|
||||
public function getDateTimes(): ?array
|
||||
{
|
||||
return $this->dateTimes;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### ReturnNeverTypeRector
|
||||
|
||||
Add "never" return-type for methods that never return anything
|
||||
@ -8288,25 +8242,6 @@ Add strict typed property based on `setUp()` strict typed assigns in TestCase
|
||||
|
||||
<br>
|
||||
|
||||
### VarAnnotationIncorrectNullableRector
|
||||
|
||||
Add or remove null type from `@var` phpdoc typehint based on php property type declaration
|
||||
|
||||
- class: [`Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector`](../rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php)
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
- * @var DateTime[]
|
||||
+ * @var DateTime[]|null
|
||||
*/
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### WhileNullableToInstanceofRector
|
||||
|
||||
Change while null compare to strict instanceof check
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PhpDocParser;
|
||||
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
final class PhpDocInfoAnalyzer
|
||||
{
|
||||
public function isVarDocAlreadySet(PhpDocInfo $phpDocInfo) : bool
|
||||
{
|
||||
foreach (['@var', '@phpstan-var', '@psalm-var'] as $tagName) {
|
||||
$varType = $phpDocInfo->getVarType($tagName);
|
||||
if (!$varType instanceof MixedType) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Guard;
|
||||
|
||||
use RectorPrefix202308\Nette\Utils\Strings;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class PhpDocNestedAnnotationGuard
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* Regex is used to count annotations including nested annotations
|
||||
*
|
||||
* @see https://regex101.com/r/G7wODT/1
|
||||
* @var string
|
||||
*/
|
||||
private const SIMPLE_ANNOTATION_REGEX = '/@[A-z]+\\(?/i';
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
/**
|
||||
* Check if rector accidentally skipped annotation during parsing which it should not have (this bug is likely related to parsing of annotations
|
||||
* in phpstan / rector)
|
||||
*/
|
||||
public function isPhpDocCommentCorrectlyParsed(Node $node) : bool
|
||||
{
|
||||
$comments = $node->getAttribute(AttributeKey::COMMENTS, []);
|
||||
if ((\is_array($comments) || $comments instanceof \Countable ? \count($comments) : 0) !== 1) {
|
||||
return \true;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
/** @var Doc $phpDoc */
|
||||
$phpDoc = $comments[0];
|
||||
$originalPhpDocText = $phpDoc->getText();
|
||||
/**
|
||||
* This is a safeguard to skip cases where the PhpStan / Rector phpdoc parser parses annotations incorrectly (ie.: nested annotations)
|
||||
*/
|
||||
$parsedPhpDocText = (string) $phpDocInfo->getPhpDocNode();
|
||||
return !$this->hasAnnotationCountChanged($originalPhpDocText, $parsedPhpDocText);
|
||||
}
|
||||
private function hasAnnotationCountChanged(string $originalPhpDocText, string $updatedPhpDocText) : bool
|
||||
{
|
||||
$originalAnnotationCount = \count(Strings::matchAll($originalPhpDocText, self::SIMPLE_ANNOTATION_REGEX));
|
||||
$reconstructedAnnotationCount = \count(Strings::matchAll($updatedPhpDocText, self::SIMPLE_ANNOTATION_REGEX));
|
||||
return $originalAnnotationCount !== $reconstructedAnnotationCount;
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Helper;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ConstFetch;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPStan\Type\ClosureType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class PhpDocNullableTypeHelper
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\StaticTypeMapper\StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
|
||||
*/
|
||||
private $valueResolver;
|
||||
public function __construct(StaticTypeMapper $staticTypeMapper, ValueResolver $valueResolver)
|
||||
{
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->valueResolver = $valueResolver;
|
||||
}
|
||||
/**
|
||||
* @return Type|null Returns null if it was not possible to resolve new php doc type or if update is not required
|
||||
*/
|
||||
public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType(Type $phpDocType, Type $phpParserType) : ?Type
|
||||
{
|
||||
if ($phpParserType instanceof MixedType) {
|
||||
return null;
|
||||
}
|
||||
return $this->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo($phpDocType, $this->isParserTypeContainingNullType($phpParserType));
|
||||
}
|
||||
/**
|
||||
* @return Type|null Returns null if it was not possible to resolve new php doc param type or if update is not required
|
||||
*/
|
||||
public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndParamNode(Type $phpDocType, Param $param) : ?Type
|
||||
{
|
||||
if ($param->type === null) {
|
||||
return null;
|
||||
}
|
||||
$phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
|
||||
if ($phpParserType instanceof UnionType) {
|
||||
$isPhpParserTypeContainingNullType = TypeCombinator::containsNull($phpParserType);
|
||||
} elseif ($param->default instanceof Expr) {
|
||||
$value = $this->valueResolver->getValue($param->default);
|
||||
$isPhpParserTypeContainingNullType = $value === null || $param->default instanceof ConstFetch && $value === 'null';
|
||||
} else {
|
||||
$isPhpParserTypeContainingNullType = \false;
|
||||
}
|
||||
$resolvedType = $this->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo($phpDocType, $isPhpParserTypeContainingNullType);
|
||||
if ($resolvedType instanceof UnionType) {
|
||||
return $this->cleanNullableMixed($resolvedType);
|
||||
}
|
||||
if ($resolvedType instanceof Type) {
|
||||
return $resolvedType;
|
||||
}
|
||||
if (!$phpDocType instanceof UnionType) {
|
||||
return null;
|
||||
}
|
||||
$cleanNullableMixed = $this->cleanNullableMixed($phpDocType);
|
||||
if ($cleanNullableMixed === $phpDocType) {
|
||||
return null;
|
||||
}
|
||||
return $cleanNullableMixed;
|
||||
}
|
||||
/**
|
||||
* @param array<Type> $updatedDocTypes
|
||||
*
|
||||
* @return array<Type>
|
||||
*/
|
||||
private function appendOrPrependNullTypeIfAppropriate(bool $isPhpParserTypeContainingNullType, bool $isPhpDocTypeContainingClosureType, array $updatedDocTypes) : array
|
||||
{
|
||||
if (!$isPhpParserTypeContainingNullType) {
|
||||
return $updatedDocTypes;
|
||||
}
|
||||
if ($isPhpDocTypeContainingClosureType) {
|
||||
\array_unshift($updatedDocTypes, new NullType());
|
||||
} else {
|
||||
$updatedDocTypes[] = new NullType();
|
||||
}
|
||||
return $updatedDocTypes;
|
||||
}
|
||||
private function hasClosureType(Type $phpDocType) : bool
|
||||
{
|
||||
if ($phpDocType instanceof ClosureType) {
|
||||
return \true;
|
||||
}
|
||||
if ($phpDocType instanceof UnionType) {
|
||||
foreach ($phpDocType->getTypes() as $subType) {
|
||||
if ($subType instanceof ClosureType) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function hasNullType(Type $phpDocType) : bool
|
||||
{
|
||||
if ($phpDocType instanceof UnionType) {
|
||||
return TypeCombinator::containsNull($phpDocType);
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @return Type[]
|
||||
*/
|
||||
private function resolveUpdatedDocTypes(Type $phpDocType) : array
|
||||
{
|
||||
$updatedDocTypes = [];
|
||||
if ($phpDocType instanceof UnionType) {
|
||||
foreach ($phpDocType->getTypes() as $subType) {
|
||||
if ($subType instanceof NullType) {
|
||||
continue;
|
||||
}
|
||||
$updatedDocTypes[] = $subType;
|
||||
}
|
||||
} else {
|
||||
$updatedDocTypes[] = $phpDocType;
|
||||
}
|
||||
return $updatedDocTypes;
|
||||
}
|
||||
private function cleanNullableMixed(UnionType $unionType) : Type
|
||||
{
|
||||
if (!TypeCombinator::containsNull($unionType)) {
|
||||
return $unionType;
|
||||
}
|
||||
$types = $unionType->getTypes();
|
||||
foreach ($types as $type) {
|
||||
if ($type instanceof MixedType) {
|
||||
return TypeCombinator::removeNull($unionType);
|
||||
}
|
||||
}
|
||||
return $unionType;
|
||||
}
|
||||
private function isItRequiredToRemoveOrAddNullTypeToUnion(bool $phpDocTypeContainsNullType, bool $phpParserTypeContainsNullType) : bool
|
||||
{
|
||||
return $phpParserTypeContainsNullType && !$phpDocTypeContainsNullType || !$phpParserTypeContainsNullType && $phpDocTypeContainsNullType;
|
||||
}
|
||||
/**
|
||||
* @param Type[] $updatedDocTypes
|
||||
*/
|
||||
private function composeUpdatedPhpDocType(array $updatedDocTypes) : Type
|
||||
{
|
||||
return \count($updatedDocTypes) === 1 ? $updatedDocTypes[0] : new UnionType($updatedDocTypes);
|
||||
}
|
||||
private function isParserTypeContainingNullType(Type $phpParserType) : bool
|
||||
{
|
||||
if ($phpParserType instanceof UnionType) {
|
||||
return TypeCombinator::containsNull($phpParserType);
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo(Type $phpDocType, bool $isPhpParserTypeContainingNullType) : ?Type
|
||||
{
|
||||
$isPhpDocTypeContainingNullType = $this->hasNullType($phpDocType);
|
||||
$isPhpDocTypeContainingClosureType = $this->hasClosureType($phpDocType);
|
||||
$updatedDocTypes = $this->resolveUpdatedDocTypes($phpDocType);
|
||||
if (!$this->isItRequiredToRemoveOrAddNullTypeToUnion($isPhpDocTypeContainingNullType, $isPhpParserTypeContainingNullType)) {
|
||||
return null;
|
||||
}
|
||||
$updatedDocTypes = $this->appendOrPrependNullTypeIfAppropriate($isPhpParserTypeContainingNullType, $isPhpDocTypeContainingClosureType, $updatedDocTypes);
|
||||
return $this->composeUpdatedPhpDocType($updatedDocTypes);
|
||||
}
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard;
|
||||
use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\ParamAnalyzer;
|
||||
use Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector\ParamAnnotationIncorrectNullableRectorTest
|
||||
*/
|
||||
final class ParamAnnotationIncorrectNullableRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator
|
||||
*/
|
||||
private $typeComparator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper
|
||||
*/
|
||||
private $phpDocNullableTypeHelper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard
|
||||
*/
|
||||
private $phpDocNestedAnnotationGuard;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory
|
||||
*/
|
||||
private $paramPhpDocNodeFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\NodeAnalyzer\ParamAnalyzer
|
||||
*/
|
||||
private $paramAnalyzer;
|
||||
public function __construct(TypeComparator $typeComparator, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, ParamPhpDocNodeFactory $paramPhpDocNodeFactory, ParamAnalyzer $paramAnalyzer)
|
||||
{
|
||||
$this->typeComparator = $typeComparator;
|
||||
$this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper;
|
||||
$this->phpDocNestedAnnotationGuard = $phpDocNestedAnnotationGuard;
|
||||
$this->paramPhpDocNodeFactory = $paramPhpDocNodeFactory;
|
||||
$this->paramAnalyzer = $paramAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add or remove null type from @param phpdoc typehint based on php parameter type declaration', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @param \DateTime[] $dateTimes
|
||||
*/
|
||||
public function setDateTimes(?array $dateTimes): self
|
||||
{
|
||||
$this->dateTimes = $dateTimes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @param \DateTime[]|null $dateTimes
|
||||
*/
|
||||
public function setDateTimes(?array $dateTimes): self
|
||||
{
|
||||
$this->dateTimes = $dateTimes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class, Function_::class];
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::TYPED_PROPERTIES;
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod|Function_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($node->getParams() === []) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
return $this->updateParamTagsIfRequired($phpDocNode, $node, $phpDocInfo);
|
||||
}
|
||||
private function wasUpdateOfParamTypeRequired(PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : bool
|
||||
{
|
||||
// better skip, could crash hard
|
||||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||
return \false;
|
||||
}
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
||||
// override existing type
|
||||
if ($paramTagValueNode instanceof ParamTagValueNode) {
|
||||
// already set
|
||||
$currentType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $param);
|
||||
if ($this->typeComparator->areTypesEqual($currentType, $newType)) {
|
||||
return \false;
|
||||
}
|
||||
$paramTagValueNode->type = $typeNode;
|
||||
} else {
|
||||
$paramTagValueNode = $this->paramPhpDocNodeFactory->create($typeNode, $param);
|
||||
$phpDocInfo->addTagValueNode($paramTagValueNode);
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @return ClassMethod|Function_|null
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node
|
||||
*/
|
||||
private function updateParamTagsIfRequired(PhpDocNode $phpDocNode, $node, PhpDocInfo $phpDocInfo) : ?Node
|
||||
{
|
||||
$paramTagValueNodes = $phpDocNode->getParamTagValues();
|
||||
$paramTagWasUpdated = \false;
|
||||
foreach ($paramTagValueNodes as $paramTagValueNode) {
|
||||
$param = $this->paramAnalyzer->getParamByName($paramTagValueNode->parameterName, $node);
|
||||
if (!$param instanceof Param) {
|
||||
continue;
|
||||
}
|
||||
$docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $node);
|
||||
$updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndParamNode($docType, $param);
|
||||
if (!$updatedPhpDocType instanceof Type) {
|
||||
continue;
|
||||
}
|
||||
if ($this->wasUpdateOfParamTypeRequired($phpDocInfo, $updatedPhpDocType, $param, $paramTagValueNode->parameterName)) {
|
||||
$paramTagWasUpdated = \true;
|
||||
}
|
||||
}
|
||||
return $paramTagWasUpdated ? $node : null;
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard;
|
||||
use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper;
|
||||
use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector\ReturnAnnotationIncorrectNullableRectorTest
|
||||
*/
|
||||
final class ReturnAnnotationIncorrectNullableRector extends AbstractScopeAwareRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper
|
||||
*/
|
||||
private $phpDocNullableTypeHelper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard
|
||||
*/
|
||||
private $classMethodReturnTypeOverrideGuard;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard
|
||||
*/
|
||||
private $phpDocNestedAnnotationGuard;
|
||||
public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard)
|
||||
{
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
$this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper;
|
||||
$this->classMethodReturnTypeOverrideGuard = $classMethodReturnTypeOverrideGuard;
|
||||
$this->phpDocNestedAnnotationGuard = $phpDocNestedAnnotationGuard;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add or remove null type from @return phpdoc typehint based on php return type declaration', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @return \DateTime[]
|
||||
*/
|
||||
public function getDateTimes(): ?array
|
||||
{
|
||||
return $this->dateTimes;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @return \DateTime[]|null
|
||||
*/
|
||||
public function getDateTimes(): ?array
|
||||
{
|
||||
return $this->dateTimes;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class, Function_::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod|Function_ $node
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
{
|
||||
$returnType = $node->getReturnType();
|
||||
if ($returnType === null) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node, $scope)) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$returnTagValueNode = $phpDocInfo->getReturnTagValue();
|
||||
if (!$returnTagValueNode instanceof ReturnTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
$phpStanDocTypeNode = $returnTagValueNode->type;
|
||||
$phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnType);
|
||||
$docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($phpStanDocTypeNode, $node);
|
||||
$updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType($docType, $phpParserType);
|
||||
if (!$updatedPhpDocType instanceof Type) {
|
||||
return null;
|
||||
}
|
||||
$hasReturnTypeChanged = $this->phpDocTypeChanger->changeReturnType($node, $phpDocInfo, $updatedPhpDocType);
|
||||
if ($hasReturnTypeChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Rector\Property;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PhpDocParser\PhpDocInfoAnalyzer;
|
||||
use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard;
|
||||
use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector\VarAnnotationIncorrectNullableRectorTest
|
||||
*/
|
||||
final class VarAnnotationIncorrectNullableRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper
|
||||
*/
|
||||
private $phpDocNullableTypeHelper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard
|
||||
*/
|
||||
private $phpDocNestedAnnotationGuard;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpDocParser\PhpDocInfoAnalyzer
|
||||
*/
|
||||
private $phpDocInfoAnalyzer;
|
||||
public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, PhpDocInfoAnalyzer $phpDocInfoAnalyzer)
|
||||
{
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
$this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper;
|
||||
$this->phpDocNestedAnnotationGuard = $phpDocNestedAnnotationGuard;
|
||||
$this->phpDocInfoAnalyzer = $phpDocInfoAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add or remove null type from @var phpdoc typehint based on php property type declaration', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var DateTime[]
|
||||
*/
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var DateTime[]|null
|
||||
*/
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Property::class];
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::TYPED_PROPERTIES;
|
||||
}
|
||||
/**
|
||||
* @param Property $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (\count($node->props) !== 1) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
if (!$this->phpDocInfoAnalyzer->isVarDocAlreadySet($phpDocInfo)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->type === null) {
|
||||
return null;
|
||||
}
|
||||
$phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->type);
|
||||
$varTagValueNode = $phpDocInfo->getVarTagValueNode();
|
||||
if (!$varTagValueNode instanceof VarTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
$docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $node);
|
||||
$updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType($docType, $phpParserType);
|
||||
if (!$updatedPhpDocType instanceof Type) {
|
||||
return null;
|
||||
}
|
||||
$this->phpDocTypeChanger->changeVarType($node, $phpDocInfo, $updatedPhpDocType);
|
||||
if (!$phpDocInfo->hasChanged()) {
|
||||
return null;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'b00b694fc423331a17c02f2ad225fbbacc750d2a';
|
||||
public const PACKAGE_VERSION = '3de7c697f5adc910481ff5873674284b2836dc50';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-08 11:00:44';
|
||||
public const RELEASE_DATE = '2023-08-08 14:21:45';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitbce1b6d116ed3e3aa349ef6dfa5de7cd::getLoader();
|
||||
return ComposerAutoloaderInit68b9c3caf5bc49fdc0a10057e30efb6d::getLoader();
|
||||
|
6
vendor/composer/autoload_classmap.php
vendored
6
vendor/composer/autoload_classmap.php
vendored
@ -2289,7 +2289,6 @@ return array(
|
||||
'Rector\\PhpDocDecorator\\PhpDocFromTypeDeclarationDecorator' => $vendorDir . '/rector/rector-downgrade-php/src/PhpDocDecorator/PhpDocFromTypeDeclarationDecorator.php',
|
||||
'Rector\\PhpDocParser\\NodeTraverser\\SimpleCallableNodeTraverser' => $baseDir . '/packages/PhpDocParser/NodeTraverser/SimpleCallableNodeTraverser.php',
|
||||
'Rector\\PhpDocParser\\NodeVisitor\\CallableNodeVisitor' => $baseDir . '/packages/PhpDocParser/NodeVisitor/CallableNodeVisitor.php',
|
||||
'Rector\\PhpDocParser\\PhpDocInfoAnalyzer' => $baseDir . '/packages/PhpDocParser/PhpDocInfoAnalyzer.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\Contract\\PhpDocNodeVisitorInterface' => $baseDir . '/packages/PhpDocParser/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\Exception\\InvalidTraverseException' => $baseDir . '/packages/PhpDocParser/PhpDocParser/Exception/InvalidTraverseException.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\PhpDocNodeTraverser' => $baseDir . '/packages/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php',
|
||||
@ -2633,9 +2632,7 @@ return array(
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\PropertyDefaultAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\Contract\\PHPStan\\TypeWithClassTypeSpecifierInterface' => $baseDir . '/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php',
|
||||
'Rector\\TypeDeclaration\\FunctionLikeReturnTypeResolver' => $baseDir . '/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\PhpDocNestedAnnotationGuard' => $baseDir . '/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\PropertyTypeOverrideGuard' => $baseDir . '/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php',
|
||||
'Rector\\TypeDeclaration\\Helper\\PhpDocNullableTypeHelper' => $baseDir . '/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php',
|
||||
'Rector\\TypeDeclaration\\Matcher\\PropertyAssignMatcher' => $baseDir . '/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php',
|
||||
'Rector\\TypeDeclaration\\NodeAnalyzer\\AutowiredClassMethodOrPropertyAnalyzer' => $baseDir . '/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\NodeAnalyzer\\CallTypesResolver' => $baseDir . '/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php',
|
||||
@ -2668,10 +2665,8 @@ return array(
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\AddVoidReturnTypeWhereNoReturnRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\BoolReturnTypeFromStrictScalarReturnsRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/BoolReturnTypeFromStrictScalarReturnsRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\NumericReturnTypeFromStrictScalarReturnsRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/NumericReturnTypeFromStrictScalarReturnsRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamAnnotationIncorrectNullableRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamTypeByMethodCallTypeRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamTypeByParentCallTypeRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnAnnotationIncorrectNullableRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnNeverTypeRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnTypeFromReturnDirectArrayRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnDirectArrayRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnTypeFromReturnNewRector' => $baseDir . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php',
|
||||
@ -2698,7 +2693,6 @@ return array(
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictGetterMethodReturnTypeRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictSetUpRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictSetUpRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\VarAnnotationIncorrectNullableRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\StmtsAwareInterface\\DeclareStrictTypesRector' => $baseDir . '/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\While_\\WhileNullableToInstanceofRector' => $baseDir . '/rules/TypeDeclaration/Rector/While_/WhileNullableToInstanceofRector.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictBoolExprAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictBoolExprAnalyzer.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
class ComposerAutoloaderInit68b9c3caf5bc49fdc0a10057e30efb6d
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitbce1b6d116ed3e3aa349ef6dfa5de7cd', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit68b9c3caf5bc49fdc0a10057e30efb6d', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitbce1b6d116ed3e3aa349ef6dfa5de7cd', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit68b9c3caf5bc49fdc0a10057e30efb6d', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
14
vendor/composer/autoload_static.php
vendored
14
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
class ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2543,7 +2543,6 @@ class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
'Rector\\PhpDocDecorator\\PhpDocFromTypeDeclarationDecorator' => __DIR__ . '/..' . '/rector/rector-downgrade-php/src/PhpDocDecorator/PhpDocFromTypeDeclarationDecorator.php',
|
||||
'Rector\\PhpDocParser\\NodeTraverser\\SimpleCallableNodeTraverser' => __DIR__ . '/../..' . '/packages/PhpDocParser/NodeTraverser/SimpleCallableNodeTraverser.php',
|
||||
'Rector\\PhpDocParser\\NodeVisitor\\CallableNodeVisitor' => __DIR__ . '/../..' . '/packages/PhpDocParser/NodeVisitor/CallableNodeVisitor.php',
|
||||
'Rector\\PhpDocParser\\PhpDocInfoAnalyzer' => __DIR__ . '/../..' . '/packages/PhpDocParser/PhpDocInfoAnalyzer.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\Contract\\PhpDocNodeVisitorInterface' => __DIR__ . '/../..' . '/packages/PhpDocParser/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\Exception\\InvalidTraverseException' => __DIR__ . '/../..' . '/packages/PhpDocParser/PhpDocParser/Exception/InvalidTraverseException.php',
|
||||
'Rector\\PhpDocParser\\PhpDocParser\\PhpDocNodeTraverser' => __DIR__ . '/../..' . '/packages/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php',
|
||||
@ -2887,9 +2886,7 @@ class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\PropertyDefaultAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\Contract\\PHPStan\\TypeWithClassTypeSpecifierInterface' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php',
|
||||
'Rector\\TypeDeclaration\\FunctionLikeReturnTypeResolver' => __DIR__ . '/../..' . '/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\PhpDocNestedAnnotationGuard' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\PropertyTypeOverrideGuard' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php',
|
||||
'Rector\\TypeDeclaration\\Helper\\PhpDocNullableTypeHelper' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php',
|
||||
'Rector\\TypeDeclaration\\Matcher\\PropertyAssignMatcher' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php',
|
||||
'Rector\\TypeDeclaration\\NodeAnalyzer\\AutowiredClassMethodOrPropertyAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\NodeAnalyzer\\CallTypesResolver' => __DIR__ . '/../..' . '/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php',
|
||||
@ -2922,10 +2919,8 @@ class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\AddVoidReturnTypeWhereNoReturnRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\BoolReturnTypeFromStrictScalarReturnsRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/BoolReturnTypeFromStrictScalarReturnsRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\NumericReturnTypeFromStrictScalarReturnsRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/NumericReturnTypeFromStrictScalarReturnsRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamAnnotationIncorrectNullableRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamTypeByMethodCallTypeRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ParamTypeByParentCallTypeRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnAnnotationIncorrectNullableRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnNeverTypeRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnTypeFromReturnDirectArrayRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnDirectArrayRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\ClassMethod\\ReturnTypeFromReturnNewRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php',
|
||||
@ -2952,7 +2947,6 @@ class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictGetterMethodReturnTypeRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictSetUpRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictSetUpRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\Property\\VarAnnotationIncorrectNullableRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\StmtsAwareInterface\\DeclareStrictTypesRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php',
|
||||
'Rector\\TypeDeclaration\\Rector\\While_\\WhileNullableToInstanceofRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/While_/WhileNullableToInstanceofRector.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictBoolExprAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictBoolExprAnalyzer.php',
|
||||
@ -3010,9 +3004,9 @@ class ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitbce1b6d116ed3e3aa349ef6dfa5de7cd::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit68b9c3caf5bc49fdc0a10057e30efb6d::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
12
vendor/composer/installed.json
vendored
12
vendor/composer/installed.json
vendored
@ -979,17 +979,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan",
|
||||
"version": "1.10.27",
|
||||
"version_normalized": "1.10.27.0",
|
||||
"version": "1.10.28",
|
||||
"version_normalized": "1.10.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
|
||||
"reference": "a9f44dcea06f59d1363b100bb29f297b311fa640"
|
||||
"reference": "e4545b55904ebef470423d3ddddb74fa7325497a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/a9f44dcea06f59d1363b100bb29f297b311fa640",
|
||||
"reference": "a9f44dcea06f59d1363b100bb29f297b311fa640",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/e4545b55904ebef470423d3ddddb74fa7325497a",
|
||||
"reference": "e4545b55904ebef470423d3ddddb74fa7325497a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -998,7 +998,7 @@
|
||||
"conflict": {
|
||||
"phpstan\/phpstan-shim": "*"
|
||||
},
|
||||
"time": "2023-08-05T09:57:55+00:00",
|
||||
"time": "2023-08-08T12:33:42+00:00",
|
||||
"bin": [
|
||||
"phpstan",
|
||||
"phpstan.phar"
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
BIN
vendor/phpstan/phpstan/phpstan.phar
vendored
BIN
vendor/phpstan/phpstan/phpstan.phar
vendored
Binary file not shown.
26
vendor/phpstan/phpstan/phpstan.phar.asc
vendored
26
vendor/phpstan/phpstan/phpstan.phar.asc
vendored
@ -1,16 +1,16 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmTOHQkACgkQUcZzBf/C
|
||||
5cDbgg/9F8+W1+38zrsKYJmyOUUWwl6hDdjUYtv07edR6JEQApKqZ4/UaLwygSO/
|
||||
oK7FUE8ZPgeA5/k2Pofr5F2Owx583jXm/HWTcQ2iWLocAfrO4EplDSON1LIufkXZ
|
||||
AnYL8HQ9SitnfMwZme7CeEskYn9vOg4wqljVZcLDA9tCDp6zcOlenuYkkgasJ9pP
|
||||
QnlOWJhwfn8W02ZK3th0W+RE/cHuGNHqqTnnsu//eG99WUF6DK7tq8zrQohPoIbV
|
||||
QGN3JflzmJSLLvSLxZMOm8QBcusycKViKmiDnKnYUguocIWdMhDHDwe5cxboeLyt
|
||||
gRzkCdIM0lJ542qSDVyv6Jp2XzcfvCKWMUzGniVGlhUkEkotazZCwxOZ86o47CdM
|
||||
FJApHoejfAFR0R5dYLMSkHNlphudccorUtZEodk7mnkLsHwCsR8fB5V9FTw7QnWJ
|
||||
yWCDt14xvhSbCmBdSgLPjTvSfdwaAhOuqtb8dwcQ+1LxYh8UgrMxw0sD4JadMXLf
|
||||
l+BcyPI6I7Lf2WvLyiXTzr2JG3E3aNZzPPp8xnmaGSB8yMSbS2zk4cCrwNKX58IE
|
||||
FLOpyFtrgK0lNeA6T32AleAe4Srng6GPEoJQBER7dpd7yM3VmUBCN94Ov7RRNk8k
|
||||
xdftD42RJnpKl7/tkOoeI2iCnR9uzyy6PoSOvLnirAYceWyvCdM=
|
||||
=IhWk
|
||||
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmTSNgUACgkQUcZzBf/C
|
||||
5cA8rw/9EPjeTcTM6JkrBgoTxcowt5dQyQIlihqHZTymzi+sHyDRbCoE4/jXRRYL
|
||||
xDbyKn6rb0klsdRkWtcfPmzTyNmPby7Ue61M6TdO9MNPbHQ75GOW6B72Lhvm8uAW
|
||||
ackyZPO49hNsB2uT0ND5eVKKABQDa9qoiM+iiO06Sv6mvLyX5xP20SZTy/S7iEWd
|
||||
EpCWkqmVHcdym2nQEIZVlmuI1tedMIMHTUdpRQPplwpGCbp1NJj3mGjix2ioGxaQ
|
||||
EsfXWblsrG7zaYDSFRVBTFQHMfcsPD7vrXNC6/47Z+69467cCcsKf9xUnLKeJqcc
|
||||
2l5qTfV3nm9oiKs9zNlGeyoTIgVRpRnvXmpmtDfZn0eFgBaYp2rBmNWQKhMHtlyJ
|
||||
x1PFS3rWe3lgaKD4VRm9gcOVW12Ikpc0ZNez9wgldRx8gzYFUW8XgEGsT1nnnTdC
|
||||
80KKjd8AgCkoqR2NJs2Es1nFfJVKv8QkcndBAfzRTwTyMbI5716S2EMhcVBZxdS/
|
||||
xf07/geRkBZUjahqarNH0RnClEN2XpRyjnMMaReiMBerMuuCHD7YfwenivgVqnZ3
|
||||
MFvzw7/IGO2pnxGP7Mop+FzrB3me7OvOP6reyOj/wR7uJyZu4328XZ2cvlkTEuSI
|
||||
PyqJiQxkeuhX9I2NaYL8HMrNMgzPIrn4fRmsNjKGqfAnjevo2qQ=
|
||||
=UH7D
|
||||
-----END PGP SIGNATURE-----
|
||||
|
Loading…
x
Reference in New Issue
Block a user