Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a closure for conditionals to phan
diff --git a/src/Phan/Analysis/PreOrderAnalysisVisitor.php b/src/Phan/Analysis/PreOrderAnalysisVisitor.php
index 8650cd3..feaaee4 100644
--- a/src/Phan/Analysis/PreOrderAnalysisVisitor.php
+++ b/src/Phan/Analysis/PreOrderAnalysisVisitor.php
@@ -508,11 +508,16 @@ class PreOrderAnalysisVisitor extends ScopeVisitor
*/
public function visitIfElem(Node $node) : Context
{
+ $closure_fqsen =
+ FullyQualifiedFunctionName::fromClosureInContext(
+ $this->context->withLineNumberStart($node->lineno ?? 0)
+ );
+
// Clone the scope for each branch of a conditional.
// They'll be merged upon existing all branches.
$context = $this->context->withScope(
clone($this->context->getScope())
- );
+ )->withClosureFQSEN($closure_fqsen);
// Look to see if any proofs we do within the condition
// can say anything about types within the statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.