Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function refactor(Node $node): ?Node
}

// is already set
/** @var PhpDocInfo $phpDocInfo */
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if (! $phpDocInfo->getVarType() instanceof MixedType) {
if ($phpDocInfo !== null && ! $phpDocInfo->getVarType() instanceof MixedType) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;

use PhpParser\Node\Stmt\Property;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\NodeTypeResolver\Node\AttributeKey;
Expand All @@ -14,8 +15,11 @@ final class VarDocPropertyTypeInferer implements PropertyTypeInfererInterface
{
public function inferProperty(Property $property): Type
{
/** @var PhpDocInfo $phpDocInfo */
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return new MixedType();
}

return $phpDocInfo->getVarType();
}
Expand Down