String[] typeNames = null;
if (method instanceof IPHPDocAwareElement) {
typeNames = ((IPHPDocAwareElement) method).getReturnTypes();
} else {
List<String> returnTypeList = new LinkedList<String>();
PHPDocBlock docBlock = PHPModelUtils.getDocBlock(method);
if (docBlock == null) {
return null;
}
PHPDocTag[] tags = docBlock.getTags(PHPDocTagKinds.PARAM);
if (tags != null && tags.length > 0) {
for (PHPDocTag phpDocTag : tags) {
if (phpDocTag.getReferences() != null
&& phpDocTag.getReferences().length > 0) {
for (SimpleReference ref : phpDocTag
.getReferences()) {
if (ref instanceof TypeReference) {
String type = ref.getName();
if (type != null && isValidType(type, project)) {
returnTypeList.add(type);
}
}
}
}
}
}
typeNames = returnTypeList.toArray(new String[returnTypeList
.size()]);
}
if (typeNames != null) {
for (String typeName : typeNames) {
Matcher m = ARRAY_TYPE_PATTERN.matcher(typeName);
if (m.find()) {
int offset = 0;
try {
offset = method.getSourceRange().getOffset();
} catch (ModelException e) {
}
IEvaluatedType t = getArrayType(m.group(), currentNamespace, offset);
String name = t.getTypeName();
if (!evaluated.contains(name) && name.startsWith("$"))
evaluated.add(t);
} 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);
}
} 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();