Created
November 6, 2023 19:29
-
-
Save dasl-/12fe1fa8322c4bc8b9b551de3102d960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Phan/Analysis/PostOrderAnalysisVisitor.php b/src/Phan/Analysis/PostOrderAnalysisVisitor.php | |
index a7557675d..1d51b9c63 100644 | |
--- a/src/Phan/Analysis/PostOrderAnalysisVisitor.php | |
+++ b/src/Phan/Analysis/PostOrderAnalysisVisitor.php | |
@@ -1621,31 +1621,31 @@ class PostOrderAnalysisVisitor extends AnalysisVisitor | |
// Check for failing to return a value, or returning a value in a void method. | |
if ($method_return_type->hasRealTypeSet()) { | |
if (!$this->checkIsValidReturnExpressionForType($node, $method_return_type->asRealUnionType(), $method)) { | |
return $context; | |
} | |
} | |
// This leaves functions which aren't syntactically generators. | |
// Figure out what is actually being returned | |
// TODO: Properly check return values of array shapes | |
foreach ($this->getReturnTypes($context, $expr, $node->lineno) as $lineno => [$expression_type, $inner_node]) { | |
// If there is no declared type, see if we can deduce | |
// what it should be based on the return type | |
if ($method_return_type->isEmpty() | |
- || $method->isReturnTypeUndefined() | |
+ || $method->isReturnTypeUndefined() || true // see config: allow_overriding_vague_return_types | |
) { | |
if (!$is_trait) { | |
$method->setIsReturnTypeUndefined(true); | |
// Set the inferred type of the method based | |
// on what we're returning | |
$method->setUnionType($method->getUnionType()->withUnionType($expression_type)); | |
} | |
// No point in comparing this type to the | |
// type we just set | |
continue; | |
} | |
// Check if the return type is compatible with the declared return type. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment