cache = ((IModelCacheContext) context).getCache();
}
// Handle $this variable reference
if (variableReference.getName().equals("$this")) { //$NON-NLS-1$
if (context instanceof MethodContext) {
MethodContext methodContext = (MethodContext) context;
final LambdaFunctionDeclaration[] lambdas = new LambdaFunctionDeclaration[1];
ContextFinder contextFinder = new ContextFinder(
methodContext.getSourceModule()) {
@Override
public boolean visit(Expression s) throws Exception {
if (s instanceof LambdaFunctionDeclaration) {
LambdaFunctionDeclaration lambda = (LambdaFunctionDeclaration) s;
if (variableReference.sourceStart() > lambda
.sourceStart()
&& variableReference.sourceEnd() < lambda
.sourceEnd()) {
lambdas[0] = lambda;
}
}
return super.visit(s);
}
};
try {
methodContext.getRootNode().traverse(contextFinder);
} catch (Exception e) {
}
PHPVersion phpVersion = ProjectOptions
.getPhpVersion(methodContext.getSourceModule()
.getScriptProject().getProject());
if (lambdas[0] != null
&& (lambdas[0].isStatic() || phpVersion
.isLessThan(PHPVersion.PHP5_4))) {
this.results.add(new SimpleType(SimpleType.TYPE_NULL));
} else {
IEvaluatedType instanceType = methodContext
.getInstanceType();
if (instanceType != null) {
this.results.add(instanceType);
} else {
this.results.add(new SimpleType(SimpleType.TYPE_NULL));