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 { ...@@ -828,7 +828,7 @@ class PhpGenerator : public BaseGenerator {
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
++it) { ++it) {
auto &ev = **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"; code += Indent + ");\n\n";
......
...@@ -11,10 +11,10 @@ class Any ...@@ -11,10 +11,10 @@ class Any
const MyGame_Example2_Monster = 3; const MyGame_Example2_Monster = 3;
private static $names = array( private static $names = array(
"NONE", Any::NONE=>"NONE",
"Monster", Any::Monster=>"Monster",
"TestSimpleTableWithEnum", Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum",
"MyGame_Example2_Monster", Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster",
); );
public static function Name($e) public static function Name($e)
......
...@@ -11,10 +11,10 @@ class AnyAmbiguousAliases ...@@ -11,10 +11,10 @@ class AnyAmbiguousAliases
const M3 = 3; const M3 = 3;
private static $names = array( private static $names = array(
"NONE", AnyAmbiguousAliases::NONE=>"NONE",
"M1", AnyAmbiguousAliases::M1=>"M1",
"M2", AnyAmbiguousAliases::M2=>"M2",
"M3", AnyAmbiguousAliases::M3=>"M3",
); );
public static function Name($e) public static function Name($e)
......
...@@ -11,10 +11,10 @@ class AnyUniqueAliases ...@@ -11,10 +11,10 @@ class AnyUniqueAliases
const M2 = 3; const M2 = 3;
private static $names = array( private static $names = array(
"NONE", AnyUniqueAliases::NONE=>"NONE",
"M", AnyUniqueAliases::M=>"M",
"T", AnyUniqueAliases::T=>"T",
"M2", AnyUniqueAliases::M2=>"M2",
); );
public static function Name($e) public static function Name($e)
......
...@@ -10,9 +10,9 @@ class Color ...@@ -10,9 +10,9 @@ class Color
const Blue = 8; const Blue = 8;
private static $names = array( private static $names = array(
"Red", Color::Red=>"Red",
"Green", Color::Green=>"Green",
"Blue", Color::Blue=>"Blue",
); );
public static function Name($e) public static function Name($e)
......
...@@ -10,9 +10,9 @@ class EnumInNestedNS ...@@ -10,9 +10,9 @@ class EnumInNestedNS
const C = 2; const C = 2;
private static $names = array( private static $names = array(
"A", EnumInNestedNS::A=>"A",
"B", EnumInNestedNS::B=>"B",
"C", EnumInNestedNS::C=>"C",
); );
public static function Name($e) public static function Name($e)
......
...@@ -12,13 +12,13 @@ class Character ...@@ -12,13 +12,13 @@ class Character
const Unused = 6; const Unused = 6;
private static $names = array( private static $names = array(
"NONE", Character::NONE=>"NONE",
"MuLan", Character::MuLan=>"MuLan",
"Rapunzel", Character::Rapunzel=>"Rapunzel",
"Belle", Character::Belle=>"Belle",
"BookFan", Character::BookFan=>"BookFan",
"Other", Character::Other=>"Other",
"Unused", Character::Unused=>"Unused",
); );
public static function Name($e) 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