private function getPropertyType(PhpType $objType = null, $propName, \PHPParser_Node $n, LinkedFlowScope $scope) { // Check whether the scope contains inferred type information about the property, // or fallback to the wider property type if not available. Scopes could // contain information about properties if we have reverse interpreted // the property previously. $qualifiedName = self::getQualifiedName($n); $var = $scope->getSlot($qualifiedName); if (null !== $var && null !== ($varType = $var->getType())) { if ($varType->equals($this->typeRegistry->getNativeType('unknown')) && $var !== $this->syntacticScope->getSlot($qualifiedName)) { // If the type of this qualified name has been checked in this scope, // then use CHECKED_UNKNOWN_TYPE instead to indicate that. // TODO: The checked unknown type has not really proved useful in // practice. Consider removing it entirely. return $this->typeRegistry->getNativeType('unknown_checked'); } return $varType; } $propertyType = null; if (null !== $objType && null !== ($objType = $objType->toMaybeObjectType()) && $objType instanceof Clazz && $objType->hasProperty($propName)) { $propertyType = $objType->getProperty($propName)->getPhpType(); } return $propertyType ?: $this->typeRegistry->getNativeType('unknown'); }
private function getVarType(LinkedFlowScope $scope, $name) { $slot = $scope->getSlot($name); $this->assertNotNull($slot, 'Scope does not contain slot named "' . $name . '".'); return $slot->getType(); }