Browse Source

[php] fixed case sensitivity of types in `use` section of generated php code (fixes #10820)

Aleksandr Kuzmenko 2 years ago
parent
commit
ee56c20b54

+ 2 - 2
src/generators/genphp7.ml

@@ -1141,13 +1141,13 @@ let type_name_used_in_namespace ctx type_path as_name namespace =
 				List.iter
 				List.iter
 					(fun ctx_type ->
 					(fun ctx_type ->
 						let wrapper = get_wrapper ctx_type in
 						let wrapper = get_wrapper ctx_type in
-						Hashtbl.add ctx.pgc_namespaces_types_cache wrapper#get_namespace wrapper#get_name
+						Hashtbl.add ctx.pgc_namespaces_types_cache wrapper#get_namespace (StringHelper.uppercase wrapper#get_name)
 					)
 					)
 					ctx.pgc_common.types;
 					ctx.pgc_common.types;
 				Hashtbl.find_all ctx.pgc_namespaces_types_cache namespace
 				Hashtbl.find_all ctx.pgc_namespaces_types_cache namespace
 			| types -> types
 			| types -> types
 	in
 	in
-	List.mem as_name types
+	List.mem (StringHelper.uppercase as_name) types
 	&& (namespace, as_name) <> type_path
 	&& (namespace, as_name) <> type_path
 
 
 (**
 (**

+ 8 - 0
tests/misc/php/projects/Issue10820/Foo.hx

@@ -0,0 +1,8 @@
+class PAckFoo extends pack.Foo {}
+
+class Foo{
+	public var bar	: PAckFoo;
+	public function new(){
+		bar = new PAckFoo();
+	}
+}

+ 8 - 0
tests/misc/php/projects/Issue10820/Main.hx

@@ -0,0 +1,8 @@
+class Main {
+	static var tmp:Any;
+
+	static function main() {
+		// pack.Foo.test();
+		tmp = new Foo().bar;
+	}
+}

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

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

+ 5 - 0
tests/misc/php/projects/Issue10820/pack/Foo.hx

@@ -0,0 +1,5 @@
+package pack;
+
+class Foo {
+    public function new() {}
+}