public static PhpCallable BindToPhpCallable(MethodBase[] targets) { Debug.Assert(targets.All(t => t.IsStatic), "Only static methods can be bound to PhpCallable delegate."); // (Context ctx, PhpValue[] arguments) var ps = new ParameterExpression[] { Expression.Parameter(typeof(Context), "ctx"), Expression.Parameter(typeof(PhpValue[]), "argv") }; // invoke targets var invocation = OverloadBinder.BindOverloadCall(typeof(PhpValue), null, targets, ps[0], ps[1]); Debug.Assert(invocation.Type == typeof(PhpValue)); // compile & create delegate var lambda = Expression.Lambda<PhpCallable>(invocation, targets[0].Name + "#" + targets.Length, true, ps); return lambda.Compile(); }