Skip to content

Commit

Permalink
[TypeDeclaration] Skip ParamTypeDeclarationRector on NullType (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingimmick committed Aug 25, 2021
1 parent f9ee33b commit f78ffe3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector\Fixture;

class SkipNull
{
/**
* @param null $value
*/
public function someFunction($value)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
Expand Down Expand Up @@ -147,6 +148,10 @@ private function refactorParam(Param $param, ClassMethod | Function_ $functionLi
return;
}

if ($inferedType instanceof NullType) {
return;
}

if ($this->traitTypeAnalyzer->isTraitType($inferedType)) {
return;
}
Expand Down

0 comments on commit f78ffe3

Please sign in to comment.