Skip to content

Instantly share code, notes, and snippets.

@egonSchiele
Created March 11, 2016 02:15
Show Gist options
  • Save egonSchiele/abe1a2da1401aa2b4988 to your computer and use it in GitHub Desktop.
Save egonSchiele/abe1a2da1401aa2b4988 to your computer and use it in GitHub Desktop.
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