Browse Source

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

Alexander Kuzmenko 8 years ago
parent
commit
2615daf8e5
3 changed files with 18 additions and 1 deletions
  1. 8 0
      src/generators/genphp.ml
  2. 1 1
      tests/RunCi.hx
  3. 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;

+ 1 - 1
tests/RunCi.hx

@@ -722,7 +722,7 @@ class RunCi {
 					case Php7:
 						if (systemName == "Linux") {
 							getSpodDependencies();
-							runCommand("phpenv", ["global", "7.0"]);
+							runCommand("phpenv", ["global", "7.0"], false, true);
 							runCommand("haxe", ["compile-php7.hxml"].concat(args));
 							runCommand("php", ["bin/php7/index.php"]);
 

+ 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));
+    }
+}