File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed
Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ abstract class Enum
3737 private static $ constants = array ();
3838
3939 /**
40- * A List of of available enumerator names by enumeration class
40+ * A List of available enumerator names by enumeration class
4141 *
4242 * @var array ["$class" => ["$name0", ...], ...]
4343 */
@@ -130,22 +130,20 @@ final public function getName()
130130 */
131131 final public function getOrdinal ()
132132 {
133- if ($ this ->ordinal !== null ) {
134- return $ this ->ordinal ;
135- }
136-
137- // detect ordinal
138- $ ordinal = 0 ;
139- $ value = $ this ->value ;
140- foreach (self ::detectConstants (static ::class) as $ constValue ) {
141- if ($ value === $ constValue ) {
142- break ;
133+ if ($ this ->ordinal === null ) {
134+ $ ordinal = 0 ;
135+ $ value = $ this ->value ;
136+ foreach (self ::detectConstants (static ::class) as $ constValue ) {
137+ if ($ value === $ constValue ) {
138+ break ;
139+ }
140+ ++$ ordinal ;
143141 }
144- ++$ ordinal ;
142+
143+ $ this ->ordinal = $ ordinal ;
145144 }
146145
147- $ this ->ordinal = $ ordinal ;
148- return $ ordinal ;
146+ return $ this ->ordinal ;
149147 }
150148
151149 /**
@@ -263,7 +261,7 @@ final public static function byOrdinal($ordinal)
263261 }
264262
265263 $ const = $ class . ':: ' . $ name ;
266- return self ::$ instances [$ class ][$ name ] = new $ class (\constant ($ const ));
264+ return self ::$ instances [$ class ][$ name ] = new $ class (\constant ($ const ), $ ordinal );
267265 }
268266
269267 /**
You can’t perform that action at this time.
0 commit comments