File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ abstract class Enum
2222 protected $ value ;
2323
2424 /**
25- * Store instantiated reflection objects in a static cache.
25+ * Store existing constants in a static cache per object .
2626 * @var array
2727 */
28- protected static $ reflectionCache = array ();
28+ private static $ constantsCache = array ();
2929
3030 /**
3131 * Creates a new value of some type
@@ -64,10 +64,11 @@ public function __toString()
6464 public static function toArray ()
6565 {
6666 $ calledClass = get_called_class ();
67- if (!array_key_exists ($ calledClass , self ::$ reflectionCache )) {
68- self ::$ reflectionCache [$ calledClass ] = new \ReflectionClass ($ calledClass );
67+ if (!array_key_exists ($ calledClass , self ::$ constantsCache )) {
68+ $ reflectin = new \ReflectionClass ($ calledClass );
69+ self ::$ constantsCache [$ calledClass ] = $ reflection ->getConstants ();
6970 }
70- return $ reflection -> getConstants () ;
71+ return self :: $ constantsCache [ $ calledClass ] ;
7172 }
7273
7374 /**
You can’t perform that action at this time.
0 commit comments