Skip to content

Commit

Permalink
[TypeDeclaration] Register ParamAnnotationIncorrectNullableRector to …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
samsonasik and actions-user committed Apr 14, 2022
1 parent d30a863 commit 0949909
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config/set/type-declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -28,4 +29,5 @@
$services->set(TypedPropertyFromAssignsRector::class);
$services->set(ReturnAnnotationIncorrectNullableRector::class);
$services->set(VarAnnotationIncorrectNullableRector::class);
$services->set(ParamAnnotationIncorrectNullableRector::class);
};
2 changes: 1 addition & 1 deletion rules/Php80/ValueObject/AnnotationToAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;

Expand All @@ -31,7 +30,6 @@ public function __construct(
private readonly TypeComparator $typeComparator,
private readonly PhpDocNullableTypeHelper $phpDocNullableTypeHelper,
private readonly PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard,
private readonly ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard,
private readonly ParamPhpDocNodeFactory $paramPhpDocNodeFactory
) {
}
Expand Down Expand Up @@ -94,10 +92,6 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) {
return null;
}

if (! $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) {
return null;
}
Expand Down Expand Up @@ -131,8 +125,7 @@ private function wasUpdateOfParamTypeRequired(
Type $newType,
Param $param,
string $paramName
): bool
{
): bool {
// better skip, could crash hard
if ($phpDocInfo->hasInvalidTag('@param')) {
return false;
Expand Down

0 comments on commit 0949909

Please sign in to comment.