From 0255ade5e0dbcc1db27a9c6131d40cac76c31094 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenko Date: Sun, 4 Feb 2018 18:14:14 +0300 Subject: [PATCH] [php] added "object" to keywords list (fixes #6838) --- extra/CHANGES.txt | 1 + src/generators/genphp7.ml | 2 +- std/php/Boot.hx | 2 +- tests/unit/src/unit/issues/Issue6838.hx | 12 ++++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue6838.hx diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index bfb88f152c8..774a29ab21d 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -22,6 +22,7 @@ php : added `php.Syntax.code()` instead of deprecated `untyped __php__()` (#6708) php : added methods to `php.Syntax` for each php operator: `??`, `?:`, `**` etc. (#6708) php : fixed multiple file uploads in php.Web.parseMultiPart() (#4173) + php : fixed an issue with "Object" used as a class name for PHP 7.2 (it's a new keyword in php) (#6838) python : add ssl support for http requests python : improve Sys.print(ln) code generation (#6184) js : generate faster code for `x.iterator()` calls (#6669) diff --git a/src/generators/genphp7.ml b/src/generators/genphp7.ml index e65a0b25c3f..2be1d840060 100644 --- a/src/generators/genphp7.ml +++ b/src/generators/genphp7.ml @@ -140,7 +140,7 @@ let is_keyword str = | "print" | "private" | "protected" | "public" | "require" | "require_once" | "return" | "static" | "switch" | "throw" | "trait" | "try" | "unset" | "use" | "var" | "while" | "xor" | "yield" | "__class__" | "__dir__" | "__file__" | "__function__" | "__line__" | "__method__" | "__trait__" | "__namespace__" | "int" | "float" - | "bool" | "string" | "true" | "false" | "null" | "parent" | "void" | "iterable" + | "bool" | "string" | "true" | "false" | "null" | "parent" | "void" | "iterable" | "object" -> true | _ -> false diff --git a/std/php/Boot.hx b/std/php/Boot.hx index 643da915e7b..75a5eec6da4 100644 --- a/std/php/Boot.hx +++ b/std/php/Boot.hx @@ -245,7 +245,7 @@ class Boot { | "print" | "private" | "protected" | "public" | "require" | "require_once" | "return" | "static" | "switch" | "throw" | "trait" | "try" | "unset" | "use" | "var" | "while" | "xor" | "yield" | "__class__" | "__dir__" | "__file__" | "__function__" | "__line__" | "__method__" | "__trait__" | "__namespace__" | "int" | "float" - | "bool" | "string" | "true" | "false" | "null" | "parent" | "void" | "iterable": + | "bool" | "string" | "true" | "false" | "null" | "parent" | "void" | "iterable" | "object": part += '_hx'; case _: } diff --git a/tests/unit/src/unit/issues/Issue6838.hx b/tests/unit/src/unit/issues/Issue6838.hx new file mode 100644 index 00000000000..636ffd8d1e5 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue6838.hx @@ -0,0 +1,12 @@ +package unit.issues; + +class Issue6838 extends unit.Test { + function test() { + var o = new Object(); + eq('unit.issues._Issue6838.Object', Type.getClassName(Type.getClass(o))); + } +} + +private class Object { + public function new() {} +} \ No newline at end of file