ソースを参照

[php] fixed typed cast to NativeArray (closes #10576)

Aleksandr Kuzmenko 3 年 前
コミット
1e2a0b4bee

+ 1 - 0
extra/CHANGES.txt

@@ -10,6 +10,7 @@
 	all : fixed timers execution order for timers with small time delta (#10567)
 	js : fixed constructors with rest arguments when compiling for ES3, ES5 (#10490)
 	php : excluded E_DEPRECATED notices from error reporting (#10502)
+	php : fixed safe casts to native arrays (#10576)
 	nullsafety : fixed false error on extern var fields without initialization (#10448)
 
 2021-10-22 4.2.4:

+ 2 - 0
src/generators/genphp7.ml

@@ -1416,6 +1416,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 								| TAbstract ({ a_path = ["php"],"NativeIndexedArray" }, [param]) -> (self#use_t param) ^ "[]"
 								| _ -> "array"
 							)
+						| (["php"],"NativeArray") -> "array"
 						| _ when Meta.has Meta.CoreType abstr.a_meta -> "mixed"
 						| _ -> self#use_t abstr.a_this
 		(**
@@ -2072,6 +2073,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 							| "float" -> "'Float'"
 							| "bool" -> "'Bool'"
 							| "string" -> "'String'"
+							| "array" -> "'array'"
 							| "mixed" -> "'Dynamic'"
 							| "Enum" -> "'Enum'"
 							| "Class" -> "'Class'"

+ 1 - 1
std/php/Boot.hx

@@ -339,7 +339,7 @@ class Boot {
 				if (value.is_string()) {
 					return value;
 				}
-			case 'php\\NativeArray':
+			case 'array':
 				if (value.is_array()) {
 					return value;
 				}

+ 10 - 0
tests/unit/src/unit/issues/Issue10576.hx

@@ -0,0 +1,10 @@
+package unit.issues;
+
+class Issue10576 extends Test {
+#if php
+	function test() {
+		cast(new php.NativeArray(), php.NativeArray);
+        noAssert();
+	}
+#end
+}