Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dedoc/documentor
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko committed May 14, 2024
2 parents 2753026 + 7d87f52 commit 1a8aff1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Infer/Scope/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getType(Node $node): Type

if ($node instanceof Node\Expr\Ternary) {
return Union::wrap([
$this->getType($node->if),
$this->getType($node->if ?? $node->cond),
$this->getType($node->else),
]);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Infer/Scope/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ function getStatementTypeForScopeTest(string $statement, array $extensions = [])
})->with([
['unknown() ? 1 : null', 'int(1)|null'],
['unknown() ? 1 : 1', 'int(1)'],
['unknown() ?: 1', 'unknown|int(1)'],
['(int) unknown() ?: 1', 'int|int(1)'],
['1 ?: 1', 'int(1)'],
['unknown() ? 1 : unknown()', 'int(1)|unknown'],
['unknown() ? unknown() : unknown()', 'unknown'],
['unknown() ?: unknown()', 'unknown'],
['unknown() ?: true ?: 1', 'unknown|boolean(true)|int(1)'],
['unknown() ?: unknown() ?: unknown()', 'unknown'],
]);

0 comments on commit 1a8aff1

Please sign in to comment.