evaluateReturnType(returnTypeList, docBlock, method);
typeNames = returnTypeList.toArray(new String[returnTypeList
.size()]);
}
if (typeNames != null) {
MultiTypeType evalMultiType = null;
for (String typeName : typeNames) {
Matcher m = ARRAY_TYPE_PATTERN.matcher(typeName);
Matcher multi = MULTITYPE_PATTERN.matcher(typeName);
if (m.find()) {
int offset = 0;
try {
offset = method.getSourceRange().getOffset();
} catch (ModelException e) {
}
evaluated.add(getArrayType(m.group(), currentNamespace,
offset));
} else if (typeName.endsWith(BRACKETS)
&& typeName.length() > 2) {
int offset = 0;
try {
offset = method.getSourceRange().getOffset();
} catch (ModelException e) {
}
evaluated.add(getArrayType(
typeName.substring(0, typeName.length() - 2),
currentNamespace, offset));
} else {
boolean isMulti = false;
if (multi.find()) {
if (evalMultiType == null) {
evalMultiType = new MultiTypeType();
}
isMulti = true;
typeName = multi.group(1);
}
AbstractMethodReturnTypeGoal goal = (AbstractMethodReturnTypeGoal) getGoal();
IType[] types = goal.getTypes();
if (typeName.equals(SELF_RETURN_TYPE) && types != null) {
for (IType t : types) {
IEvaluatedType type = getEvaluatedType(
PHPModelUtils.getFullName(t), null);
if (type != null) {
if (isMulti) {
evalMultiType.addType(type);
} else {
evaluated.add(type);
}
}
}
} else {
if (currentNamespace != null) {
PHPDocBlock docBlock = PHPModelUtils
.getDocBlock(method);
ModuleDeclaration moduleDeclaration = SourceParserUtil
.getModuleDeclaration(currentNamespace
.getSourceModule());
if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) {
// check if the first part
// is an
// alias,then get the full
// name
String prefix = typeName
.substring(
0,
typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
final Map<String, UsePart> result = PHPModelUtils
.getAliasToNSMap(prefix,
moduleDeclaration,
docBlock.sourceStart(),
currentNamespace, true);
if (result.containsKey(prefix)) {
String fullName = result.get(prefix)
.getNamespace()
.getFullyQualifiedName();
typeName = typeName.replace(prefix,
fullName);
if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
typeName = NamespaceReference.NAMESPACE_SEPARATOR
+ typeName;
}
}
} else if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) < 0) {
String prefix = typeName;
final Map<String, UsePart> result = PHPModelUtils
.getAliasToNSMap(prefix,
moduleDeclaration,
docBlock.sourceStart(),
currentNamespace, true);
if (result.containsKey(prefix)) {
String fullName = result.get(prefix)
.getNamespace()
.getFullyQualifiedName();
typeName = fullName;
if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
typeName = NamespaceReference.NAMESPACE_SEPARATOR
+ typeName;
}
}
}
}
IEvaluatedType type = getEvaluatedType(typeName,
currentNamespace);
if (type != null) {
if (isMulti) {
evalMultiType.addType(type);
} else {
evaluated.add(type);
}
}
}