Skip to content

Commit

Permalink
[php] fixed typed cast to NativeArray (closes #10576)
Browse files Browse the repository at this point in the history
  • Loading branch information
RealyUniqueName committed Feb 5, 2022
1 parent 0b27b10 commit 1e2a0b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/generators/genphp7.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
(**
Expand Down Expand Up @@ -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'"
Expand Down
2 changes: 1 addition & 1 deletion std/php/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class Boot {
if (value.is_string()) {
return value;
}
case 'php\\NativeArray':
case 'array':
if (value.is_array()) {
return value;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/src/unit/issues/Issue10576.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package unit.issues;

class Issue10576 extends Test {
#if php
function test() {
cast(new php.NativeArray(), php.NativeArray);
noAssert();
}
#end
}

0 comments on commit 1e2a0b4

Please sign in to comment.