diff --git a/rules/type-declaration/src/Rector/ClassMethod/AddArrayReturnDocTypeRector.php b/rules/type-declaration/src/Rector/ClassMethod/AddArrayReturnDocTypeRector.php index bb21dde271e9..8f912eaa74c7 100644 --- a/rules/type-declaration/src/Rector/ClassMethod/AddArrayReturnDocTypeRector.php +++ b/rules/type-declaration/src/Rector/ClassMethod/AddArrayReturnDocTypeRector.php @@ -109,9 +109,11 @@ public function refactor(Node $node): ?Node return null; } - /** @var PhpDocInfo $phpDocInfo */ + /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); - $phpDocInfo->changeReturnType($inferedType); + if ($phpDocInfo instanceof PhpDocInfo) { + $phpDocInfo->changeReturnType($inferedType); + } return $node; }