/**
  * @inheritDoc
  */
 public function resolveVariableType(Node $node)
 {
     // $this->call()
     if ($node instanceof Node\Expr\MethodCall && property_exists($node->var, 'name') && null === $node->getAttribute('guessedType', null)) {
         if ('container' == $node->var->name && $this->isController($this->table->lookUp('this')->type())) {
             $context = self::CONTAINER;
         } else {
             $context = $this->table->lookUp($node->var->name)->type();
         }
         $type = $this->getType($context, $node->name, $node);
         if (null !== $type) {
             $node->setAttribute('guessedType', $type);
         }
     }
     // $x = $this->call()
     if ($node instanceof Node\Expr\Assign && $node->var instanceof Node\Expr\Variable && $node->expr instanceof Node\Expr\MethodCall && property_exists($node->expr->var, 'name') && null === $node->getAttribute('guessedType', null)) {
         if ('container' == $node->expr->var->name && $this->isController($this->table->lookUp('this')->type())) {
             $context = self::CONTAINER;
         } else {
             $context = $this->table->lookUp($node->expr->var->name)->type();
         }
         $type = $this->getType($context, $node->expr->name, $node->expr);
         if (null !== $type) {
             $node->var->setAttribute('guessedType', $type);
             $this->table->setSymbol($node->var->name, $type);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function resolveVariableType(Node $node)
 {
     if ($node instanceof Node\Expr\Assign) {
         // $x = ...
         if ($node->var instanceof Node\Expr\Variable) {
             // skips variable names like ${$node->nodeName}
             if (!is_string($node->var->name)) {
                 return;
             }
             // $x = new X();
             if ($node->expr instanceof Node\Expr\New_) {
                 if ($node->expr->class instanceof Node\Name) {
                     $type = $node->expr->class->toString();
                     $this->table->setSymbol($node->var->name, $type);
                     $node->var->setAttribute('guessedType', $type);
                 }
             }
             // $x = $y;
             if ($node->expr instanceof Node\Expr\Variable) {
                 $type = $this->table->lookUp($node->expr->name)->type();
                 $node->var->setAttribute('guessedType', $type);
                 $this->table->setSymbol($node->var->name, $type);
             }
             // $x = $this->x
             if ($node->expr instanceof Node\Expr\PropertyFetch) {
                 $type = $this->table->lookUpClassProperty($node->expr->name)->type();
                 $node->var->setAttribute('guessedType', $type);
                 $this->table->setSymbol($node->var->name, $type);
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function resolveVariableType(Node $node)
 {
     if ($node instanceof Node\Param) {
         if ($node->type instanceof Node\Name) {
             $this->table->setSymbol($node->name, $node->type->toString());
         }
     }
 }
 public function enterNode(Node $node)
 {
     if ($node instanceof Node\Stmt\ClassLike) {
         $this->table->enterScope(new TableScope(TableScope::CLASS_LIKE_SCOPE));
         $this->table->setSymbol('this', $node->namespacedName->toString());
     }
     if ($node instanceof Node\Stmt\ClassMethod) {
         $this->table->enterScope(new TableScope(TableScope::CLASS_METHOD_SCOPE));
     }
     if ($node instanceof Node\Stmt\Function_) {
         $this->table->enterScope(new TableScope(TableScope::FUNCTION_SCOPE));
     }
     $this->resolver->resolveVariableType($node);
     return;
 }
 public function testAddSymbol()
 {
     $table = new SymbolTable();
     $classScope = $this->prophesize('SensioLabs\\DeprecationDetector\\TypeGuessing\\SymbolTable\\TableScope');
     $classScope->scope()->willReturn(TableScope::GLOBAL_SCOPE);
     $classScope->setSymbol(new Symbol('var', 'class'))->shouldBeCalled();
     $classScope = $classScope->reveal();
     $table->enterScope($classScope);
     $table->setSymbol('var', 'class');
 }