Skip to content

Commit

Permalink
[Php80] Handle Remove Doc Array Typed UnionTypesRector (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Aug 16, 2021
1 parent 2dbf877 commit 4da0d5f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Rector\Tests\Php80\Rector\FunctionLike\UnionTypesRector\Fixture;

final class RemoveDocArrayTyped2
{
/**
* @param bool|float|int|string|array<mixed> $value
*/
public function normalizeNodeValue($value)
{
return $value;
}
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\FunctionLike\UnionTypesRector\Fixture;

final class RemoveDocArrayTyped2
{
public function normalizeNodeValue(bool|float|int|string|array $value)
{
return $value;
}
}

?>
5 changes: 5 additions & 0 deletions rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\Param;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
use Rector\NodeNameResolver\NodeNameResolver;
Expand Down Expand Up @@ -61,6 +62,10 @@ private function hasGenericType(BracketsAwareUnionTypeNode $bracketsAwareUnionTy

foreach ($types as $type) {
if ($type instanceof GenericTypeNode) {
if ($type->type instanceof IdentifierTypeNode && $type->type->name === 'array') {
continue;
}

return true;
}
}
Expand Down

0 comments on commit 4da0d5f

Please sign in to comment.