Commit 31e34faa authored by Travis Staley's avatar Travis Staley Committed by Wouter van Oortmerssen

Changing array to be an associative array so that the Name function can work…

Changing array to be an associative array so that the Name function can work with non-sequential enums as well as those beginning at something other than zero. (#5151)

Also including the resulting changes in php files.
parent 4d98faa5
......@@ -828,7 +828,7 @@ class PhpGenerator : public BaseGenerator {
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
++it) {
auto &ev = **it;
code += Indent + Indent + "\"" + ev.name + "\",\n";
code += Indent + Indent + enum_def.name + "::" + ev.name + "=>" + "\"" + ev.name + "\",\n";
}
code += Indent + ");\n\n";
......
......@@ -11,10 +11,10 @@ class Any
const MyGame_Example2_Monster = 3;
private static $names = array(
"NONE",
"Monster",
"TestSimpleTableWithEnum",
"MyGame_Example2_Monster",
Any::NONE=>"NONE",
Any::Monster=>"Monster",
Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum",
Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster",
);
public static function Name($e)
......
......@@ -11,10 +11,10 @@ class AnyAmbiguousAliases
const M3 = 3;
private static $names = array(
"NONE",
"M1",
"M2",
"M3",
AnyAmbiguousAliases::NONE=>"NONE",
AnyAmbiguousAliases::M1=>"M1",
AnyAmbiguousAliases::M2=>"M2",
AnyAmbiguousAliases::M3=>"M3",
);
public static function Name($e)
......
......@@ -11,10 +11,10 @@ class AnyUniqueAliases
const M2 = 3;
private static $names = array(
"NONE",
"M",
"T",
"M2",
AnyUniqueAliases::NONE=>"NONE",
AnyUniqueAliases::M=>"M",
AnyUniqueAliases::T=>"T",
AnyUniqueAliases::M2=>"M2",
);
public static function Name($e)
......
......@@ -10,9 +10,9 @@ class Color
const Blue = 8;
private static $names = array(
"Red",
"Green",
"Blue",
Color::Red=>"Red",
Color::Green=>"Green",
Color::Blue=>"Blue",
);
public static function Name($e)
......
......@@ -10,9 +10,9 @@ class EnumInNestedNS
const C = 2;
private static $names = array(
"A",
"B",
"C",
EnumInNestedNS::A=>"A",
EnumInNestedNS::B=>"B",
EnumInNestedNS::C=>"C",
);
public static function Name($e)
......
......@@ -12,13 +12,13 @@ class Character
const Unused = 6;
private static $names = array(
"NONE",
"MuLan",
"Rapunzel",
"Belle",
"BookFan",
"Other",
"Unused",
Character::NONE=>"NONE",
Character::MuLan=>"MuLan",
Character::Rapunzel=>"Rapunzel",
Character::Belle=>"Belle",
Character::BookFan=>"BookFan",
Character::Other=>"Other",
Character::Unused=>"Unused",
);
public static function Name($e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment