Skip to content

Instantly share code, notes, and snippets.

@dasl-
Created August 1, 2024 00:57
Show Gist options
  • Save dasl-/00dbdf26f0d82a562bb4a713a6267863 to your computer and use it in GitHub Desktop.
Save dasl-/00dbdf26f0d82a562bb4a713a6267863 to your computer and use it in GitHub Desktop.
diff --git a/src/Phan/Analysis/PostOrderAnalysisVisitor.php b/src/Phan/Analysis/PostOrderAnalysisVisitor.php
index a7557675d..089072f24 100644
--- a/src/Phan/Analysis/PostOrderAnalysisVisitor.php
+++ b/src/Phan/Analysis/PostOrderAnalysisVisitor.php
@@ -1632,7 +1632,8 @@ class PostOrderAnalysisVisitor extends AnalysisVisitor
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()
+ // TODO: this check could be performed outside the for loop? more efficient.
+ if (!$method->hasDependentReturnType() || $method_return_type->isEmpty()
|| $method->isReturnTypeUndefined()
) {
if (!$is_trait) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment