[TypeDeclaration] Register ParamAnnotationIncorrectNullableRector to type-declaration config set (#2071)

* [TypeDeclaration] Register ParamAnnotationIncorrectNullableRector to type-declaration config set

* [ci-review] Rector Rectify

* clean up unneeded ClassMethodReturnTypeOverrideGuard usage

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2022-04-14 21:52:49 +07:00 committed by GitHub
parent d30a86313f
commit 09499098eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 9 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector;
@ -28,4 +29,5 @@ return static function (RectorConfig $rectorConfig): void {
$services->set(TypedPropertyFromAssignsRector::class);
$services->set(ReturnAnnotationIncorrectNullableRector::class);
$services->set(VarAnnotationIncorrectNullableRector::class);
$services->set(ParamAnnotationIncorrectNullableRector::class);
};

View File

@ -8,7 +8,7 @@ final class AnnotationToAttribute
{
/**
* @param class-string|string $tag
* @param class-string $attributeClass
* @param class-string|null $attributeClass
*/
public function __construct(
private readonly string $tag,

View File

@ -18,7 +18,6 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard;
use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper;
use Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory;
use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -31,7 +30,6 @@ final class ParamAnnotationIncorrectNullableRector extends AbstractRector
private readonly TypeComparator $typeComparator,
private readonly PhpDocNullableTypeHelper $phpDocNullableTypeHelper,
private readonly PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard,
private readonly ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard,
private readonly ParamPhpDocNodeFactory $paramPhpDocNodeFactory
) {
}
@ -94,10 +92,6 @@ CODE_SAMPLE
return null;
}
if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) {
return null;
}
if (! $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) {
return null;
}
@ -131,8 +125,7 @@ CODE_SAMPLE
Type $newType,
Param $param,
string $paramName
): bool
{
): bool {
// better skip, could crash hard
if ($phpDocInfo->hasInvalidTag('@param')) {
return false;