Skip to content

Commit

Permalink
[php] Use property_exists instead of isset when checking function…
Browse files Browse the repository at this point in the history
… fields (#5470)

* Use `property_exists` instead of `isset` when checking function fields

* Add test
  • Loading branch information
mockey authored and nadako committed Jul 19, 2016
1 parent 96aa3e3 commit 208714c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/generators/genphp.ml
Expand Up @@ -987,9 +987,9 @@ and gen_tfield ctx e e1 s =
| _ ->
gen_expr ctx e1) in

spr ctx "(isset(";
gen_field_access ctx true e1 s;
spr ctx ") ? ";
spr ctx "(property_exists(";
ob e1.eexpr;
print ctx ", \"%s\") ? " (s_ident s);
gen_field_access ctx true e1 s;
spr ctx ": array(";
ob e1.eexpr;
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/src/unit/issues/Issue5470.hx
@@ -0,0 +1,10 @@
package unit.issues;

class Issue5470 extends unit.Test {
var cb:Void->Void;

function test() {
eq(new Issue5470().cb, null);
}

}

0 comments on commit 208714c

Please sign in to comment.