private IGoal produceNextSubgoal(IGoal previousGoal,
IEvaluatedType previousResult, GoalState goalState) {
ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
CallExpression expression = (CallExpression) typedGoal.getExpression();
// just starting to evaluate method, evaluate method receiver first:
if (state == STATE_INIT) {
ASTNode receiver = expression.getReceiver();
if (receiver == null) {
state = STATE_GOT_RECEIVER;
} else {
state = STATE_WAITING_RECEIVER;
return new ExpressionTypeGoal(goal.getContext(), receiver);
}
}
// receiver must been evaluated now, lets evaluate method return type:
if (state == STATE_WAITING_RECEIVER) {
receiverType = previousResult;
previousResult = null;
if (receiverType == null) {
return null;
}
state = STATE_GOT_RECEIVER;
}
// we've evaluated receiver, lets evaluate the method return type now
// (using PHP Doc first):
if (state == STATE_GOT_RECEIVER) {
state = STATE_WAITING_METHOD_PHPDOC;
return new PHPDocMethodReturnTypeGoal(typedGoal.getContext(),
receiverType, expression.getName());
}
// PHPDoc logic is done, start evaluating 'return' statements here:
if (state == STATE_WAITING_METHOD_PHPDOC) {
if (goalState != GoalState.PRUNED && previousResult != null
&& previousResult != UnknownType.INSTANCE) {
result = previousResult;
previousResult = null;
// BUG 404031, stop read if found not simple element
if (!PHPTypeInferenceUtils.isSimple(result)) {
return null;
}
}
state = STATE_WAITING_METHOD;
CallArgumentsList args = expression.getArgs();
String[] argNames = null;
if (args != null && args.getChilds() != null) {
List<ASTNode> childs = args.getChilds();
int i = 0;
argNames = new String[childs.size()];
for (ASTNode o : childs) {
if (o instanceof Scalar) {
Scalar arg = (Scalar) o;
argNames[i] = ASTUtils.stripQuotes(arg.getValue());
}
i++;
}
}
return new MethodElementReturnTypeGoal(typedGoal.getContext(),
receiverType, expression.getName(), argNames);
}
if (state == STATE_WAITING_METHOD) {
if (goalState != GoalState.PRUNED && previousResult != null
&& previousResult != UnknownType.INSTANCE) {