Skip to content

Commit

Permalink
#2283 - Fix return types in docblock for multiple return types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Oct 2, 2021
1 parent bcb9db3 commit 475c164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Library/Stubs/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ protected function buildMethod(ClassMethod $method, bool $isInterface, string $i
if ($method->hasReturnTypes()) {
$supported = 0;

if (array_key_exists('object', $method->getReturnTypes()) && 1 === count($method->getReturnClassTypes())) {
if (array_key_exists('object', $method->getReturnTypes())) {
$return = key($method->getReturnClassTypes());
++$supported;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ protected function buildMethod(ClassMethod $method, bool $isInterface, string $i
}

// PHP doesn't support multiple return types (yet?)
if ($supported > 1) {
if ($supported > 1 || array_key_exists('variable', $method->getReturnTypes())) {
$return = '';
}
} elseif ($method->isVoid()) {
Expand Down
10 changes: 10 additions & 0 deletions stub/stubs.zep
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ class Stubs

let data = array_merge(data, func_get_args());
}

public function testMultiReturnTypeWithMixedInDocAndEmptyInSignature1() -> array | object
{
return [];
}

public function testMultiReturnTypeWithMixedInDocAndEmptyInSignature2() -> var | bool
{
return false;
}
}

0 comments on commit 475c164

Please sign in to comment.