/** * {@inheritdoc} */ public function resolveVariableType(Node $node) { if ($node instanceof Node\Expr\Assign) { // $this->x = ... // excluding $this->$x = ... if ($node->var instanceof Node\Expr\PropertyFetch) { // $stub[$key]->x = ... ; if not tested a php notice will occur // @TODO change to be able to use all types of properties like $x->x = 10 if ($node->var->var instanceof Node\Expr\ArrayDimFetch) { return; } // @TODO change to be able to use all types of properties like $x->x = 10 if ($node->var->var->name !== 'this' || !is_string($node->var->name)) { return; } // $this->x = new X(); if ($node->expr instanceof Node\Expr\New_) { if ($node->expr->class instanceof Node\Name) { $type = $node->expr->class->toString(); $node->var->setAttribute('guessedType', $type); $this->table->setClassProperty($node->var->name, $type); } } // $this->x = $y; if ($node->expr instanceof Node\Expr\Variable) { $type = $this->table->lookUp($node->expr->name)->type(); $node->var->setAttribute('guessedType', $type); $this->table->setClassProperty($node->var->name, $type); } // $this->x = $this->y; if ($node->expr instanceof Node\Expr\PropertyFetch) { $type = $this->table->lookUpClassProperty($node->expr->name)->type(); $node->var->setAttribute('guessedType', $type); $this->table->setClassProperty($node->var->name, $type); } } } }
public function testSetClassPropertyThrowsException() { $this->setExpectedException('Exception', 'Illegal State there is no class scope above'); $table = new SymbolTable(); $table->setClassProperty('property', 'type'); }