Skip to content

Commit 496e474

Browse files
committed
gen_stub: Compare phpdoc return type in --verify
1 parent 49e030d commit 496e474

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

build/gen_stub.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,11 +1932,12 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
19321932
$aliasArgs, $aliasedArgs
19331933
);
19341934

1935-
if ((!$aliasedFunc->isMethod() || $aliasedFunc->isFinalMethod()) &&
1936-
(!$aliasFunc->isMethod() || $aliasFunc->isFinalMethod()) &&
1937-
$aliasFunc->return != $aliasedFunc->return
1938-
) {
1939-
$errors[] = "{$aliasFunc->name}() and {$aliasedFunc->name}() must have the same return type";
1935+
if (!$aliasedFunc->name->isConstructor() && !$aliasFunc->name->isConstructor()) {
1936+
$aliasedReturnType = $aliasedFunc->return->type ?? $aliasedFunc->return->phpDocType;
1937+
$aliasReturnType = $aliasFunc->return->type ?? $aliasFunc->return->phpDocType;
1938+
if ($aliasReturnType != $aliasedReturnType) {
1939+
$errors[] = "{$aliasFunc->name}() and {$aliasedFunc->name}() must have the same return type";
1940+
}
19401941
}
19411942
}
19421943

0 commit comments

Comments
 (0)