Skip to content

Commit bb69d12

Browse files
Return if var type has changed in PhpDocTypeChanger
1 parent db8a1b2 commit bb69d12

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,25 @@ public function __construct(
5858
) {
5959
}
6060

61-
public function changeVarType(Stmt $stmt, PhpDocInfo $phpDocInfo, Type $newType): void
61+
public function changeVarType(Stmt $stmt, PhpDocInfo $phpDocInfo, Type $newType): bool
6262
{
6363
// better skip, could crash hard
6464
if ($phpDocInfo->hasInvalidTag('@var')) {
65-
return;
65+
return false;
6666
}
6767

6868
// make sure the tags are not identical, e.g imported class vs FQN class
6969
if ($this->typeComparator->areTypesEqual($phpDocInfo->getVarType(), $newType)) {
70-
return;
70+
return false;
7171
}
7272

7373
// prevent existing type override by mixed
7474
if (! $phpDocInfo->getVarType() instanceof MixedType && $newType instanceof ConstantArrayType && $newType->getIterableValueType() instanceof NeverType) {
75-
return;
75+
return false;
7676
}
7777

7878
if (! $this->newPhpDocFromPHPStanTypeGuard->isLegal($newType)) {
79-
return;
79+
return false;
8080
}
8181

8282
// override existing type
@@ -94,6 +94,7 @@ public function changeVarType(Stmt $stmt, PhpDocInfo $phpDocInfo, Type $newType)
9494
}
9595

9696
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($stmt);
97+
return true;
9798
}
9899

99100
public function changeReturnType(FunctionLike $functionLike, PhpDocInfo $phpDocInfo, Type $newType): bool

0 commit comments

Comments
 (0)