function inferPropertyFetch(Node\Expr\PropertyFetch $expr, $inside, $scope) { $class = $this->inferType($inside, $expr->var, $scope); if (!empty($class) && $class[0] != "!") { if (gettype($expr->name) == 'string') { $classDef = $this->index->getClass($class); if ($classDef) { $prop = Util::findProperty($classDef, strval($expr->name), $this->index); if ($prop) { /* $type = $prop->getAttribute("namespacedType") ?: ""; if(!empty($type)) { if($type[0]=='\\') { $type=substr($type,1); } return $type; }*/ } } } } return Scope::MIXED_TYPE; }
/** * @param Class_ $node * @param $name * @param SymbolTable $symbolTable * @return ClassMethod */ static function findProperty(Class_ $node, $name, SymbolTable $symbolTable) { while ($node) { $properties = \Guardrail\NodeVisitors\Grabber::filterByType($node->stmts, \PhpParser\Node\Stmt\Property::class); /** @var Property[] $propertyList */ foreach ($properties as $props) { /** @var Property $props */ foreach ($props->props as $prop) { if (strcasecmp($prop->name, $name) == 0) { return $prop; } } } if ($node->extends) { $parent = $node->extends->toString(); $node = $symbolTable->getClass($parent); } else { return null; } } return null; }