@@ -29,7 +29,7 @@ abstract class Enum
2929     * 
3030     * @var array 
3131     */ 
32-     private  static  $ cachearray ();
32+     protected  static  $ cachearray ();
3333
3434    /** 
3535     * Creates a new value of some type 
@@ -62,15 +62,15 @@ public function getValue()
6262     */ 
6363    public  function  getKey ()
6464    {
65-         return  self ::search ($ this value );
65+         return  static ::search ($ this value );
6666    }
6767
6868    /** 
6969     * @return string 
7070     */ 
7171    public  function  __toString ()
7272    {
73-         return  (string )  $ this value ;
73+         return  (string )$ this value ;
7474    }
7575
7676    /** 
@@ -80,7 +80,7 @@ public function __toString()
8080     */ 
8181    public  static  function  keys ()
8282    {
83-         return  array_keys (self ::toArray ());
83+         return  array_keys (static ::toArray ());
8484    }
8585
8686    /** 
@@ -92,7 +92,7 @@ public static function values()
9292    {
9393        $ valuesarray ();
9494
95-         foreach  (self ::toArray () as  $ key$ value
95+         foreach  (static ::toArray () as  $ key$ value
9696            $ values$ keynew  static ($ value
9797        }
9898
@@ -107,23 +107,24 @@ public static function values()
107107    public  static  function  toArray ()
108108    {
109109        $ classget_called_class ();
110-         if  (!array_key_exists ($ classself ::$ cache
111-             $ reflectionnew  \ReflectionClass ($ class
112-             self ::$ cache$ class$ reflectiongetConstants ();
110+         if  (!array_key_exists ($ classstatic ::$ cache
111+             $ reflection            = new  \ReflectionClass ($ class
112+             static ::$ cache$ class$ reflectiongetConstants ();
113113        }
114114
115-         return  self ::$ cache$ class
115+         return  static ::$ cache$ class
116116    }
117117
118118    /** 
119119     * Check if is valid enum value 
120120     * 
121121     * @param $value 
122+      * 
122123     * @return bool 
123124     */ 
124125    public  static  function  isValid ($ value
125126    {
126-         return  in_array ($ valueself ::toArray (), true );
127+         return  in_array ($ valuestatic ::toArray (), true );
127128    }
128129
129130    /** 
@@ -135,7 +136,8 @@ public static function isValid($value)
135136     */ 
136137    public  static  function  isValidKey ($ key
137138    {
138-         $ arrayself ::toArray ();
139+         $ arraystatic ::toArray ();
140+ 
139141        return  isset ($ array$ key
140142    }
141143
@@ -148,7 +150,7 @@ public static function isValidKey($key)
148150     */ 
149151    public  static  function  search ($ value
150152    {
151-         return  array_search ($ valueself ::toArray (), true );
153+         return  array_search ($ valuestatic ::toArray (), true );
152154    }
153155
154156    /** 
@@ -162,8 +164,9 @@ public static function search($value)
162164     */ 
163165    public  static  function  __callStatic ($ name$ arguments
164166    {
165-         if  (defined ("static:: $ name )) {
166-             return  new  static (constant ("static:: $ name ));
167+         $ arraystatic ::toArray ();
168+         if  (isset ($ array$ name
169+             return  new  static ($ array$ name
167170        }
168171
169172        throw  new  \BadMethodCallException ("No static method or enum constant ' $ name' in class  "  . get_called_class ());
0 commit comments