Browse Source

[php] fix invoking functions stored in dynamic static vars (fixes #6158)

Alexander Kuzmenko 8 years ago
parent
commit
c8fd576d7e
2 changed files with 17 additions and 0 deletions
  1. 8 0
      src/generators/genphp.ml
  2. 9 0
      tests/unit/src/unit/issues/Issue6158.hx

+ 8 - 0
src/generators/genphp.ml

@@ -568,6 +568,14 @@ and gen_call ctx e el =
 			concat ctx "," (gen_value ctx) params;
 			spr ctx ")";
 		);
+	| TField ({ eexpr = TTypeExpr _ }, FStatic (_, {cf_type = TDynamic _; cf_kind = Var _})) , params ->
+		spr ctx "call_user_func(";
+		ctx.is_call <- true;
+		gen_value ctx e;
+		ctx.is_call <- false;
+		spr ctx ", ";
+		concat ctx ", " (gen_value ctx) el;
+		spr ctx ")";
 	| TLocal { v_name = "__set__" }, { eexpr = TConst (TString code) } :: el ->
 		print ctx "$%s" code;
 		genargs el;

+ 9 - 0
tests/unit/src/unit/issues/Issue6158.hx

@@ -0,0 +1,9 @@
+package unit.issues;
+
+class Issue6158 extends unit.Test {
+    public static var fn:Dynamic = function(a:Int, b:Int, c:Int) return '$a,$b,$c';
+
+    function test() {
+        eq('1,2,3', fn(1, 2, 3));
+    }
+}