public function testScopeChanges()
 {
     $function = new \PHPParser_Node_Stmt_Function('foo', array('stmts' => $functionBlock = new BlockNode(array(new \PHPParser_Node_Expr_Assign(new \PHPParser_Node_Expr_Variable('foo'), $closure = new \PHPParser_Node_Expr_Closure(array('stmts' => $closureBlock = new BlockNode(array()))))))));
     $callback = $this->getMock('Scrutinizer\\PhpAnalyzer\\PhpParser\\Traversal\\CallbackInterface');
     $functionScope = $closureScope = null;
     $t = new NodeTraversal($callback);
     $callback->expects($this->atLeastOnce())->method('shouldTraverse')->will($this->returnValue(true));
     $self = $this;
     $callback->expects($this->atLeastOnce())->method('visit')->will($this->returnCallback(function (NodeTraversal $t, \PHPParser_Node $node, \PHPParser_Node $parent = null) use(&$functionScope, &$closureScope, $function, $closure, $self) {
         if (null === $parent) {
             $functionScope = $t->getScope();
             $self->assertSame(1, $t->getScopeDepth());
             $self->assertSame($function, $t->getScopeRoot());
         }
         if ($parent instanceof \PHPParser_Node_Expr_Closure) {
             $closureScope = $t->getScope();
             $self->assertSame(2, $t->getScopeDepth());
             $self->assertSame($closure, $t->getScopeRoot());
         }
     }));
     $t->traverse($function);
     $this->assertInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\Scope\\Scope', $functionScope);
     $this->assertInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\Scope\\Scope', $closureScope);
     $this->assertNotSame($functionScope, $closureScope);
 }