Procházet zdrojové kódy

[php] don't generate constructors in interfaces (fixes #8249)

Aleksandr Kuzmenko před 6 roky
rodič
revize
19c2778eaf

+ 1 - 1
src/generators/genphp7.ml

@@ -3431,7 +3431,7 @@ class class_builder ctx (cls:tclass) =
 			Check if this class requires constructor to be generated even if there is no user-defined one
 		*)
 		method private constructor_is_required =
-			if List.length self#get_namespace > 0 then
+			if cls.cl_interface || List.length self#get_namespace > 0 then
 				false
 			else begin
 				let required = ref false in

+ 4 - 0
tests/misc/php/projects/Issue8249/compile.hxml

@@ -0,0 +1,4 @@
+-cp src
+-main Main
+-php bin
+--cmd php bin/index.php

+ 10 - 0
tests/misc/php/projects/Issue8249/src/Main.hx

@@ -0,0 +1,10 @@
+interface Test {
+    @:keep final test : String;
+}
+
+class Main implements Test {
+    public final test : String = "ok";
+    public function new() {}
+
+    static function main() {}
+}