From b80b3b60ff436da739b8006cd2a5431c39fac42d Mon Sep 17 00:00:00 2001 From: Marty Wallace Date: Wed, 13 Jul 2016 16:49:26 +1000 Subject: [PATCH] Fixed a bug in Enum::getAll(). --- composer.json | 2 +- src/Tempest/Utils/Enum.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index c3a48b9..40346ed 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "martywallace/tempest", - "version": "2.2.0", + "version": "2.2.1", "description": "A tiny PHP framework.", "homepage": "https://github.com/MartyWallace/Tempest", "type": "library", diff --git a/src/Tempest/Utils/Enum.php b/src/Tempest/Utils/Enum.php index 618f611..4291ffc 100644 --- a/src/Tempest/Utils/Enum.php +++ b/src/Tempest/Utils/Enum.php @@ -12,7 +12,7 @@ abstract class Enum { /** @var string[] */ - private static $_reflection; + private static $_reflections = array(); /** * Get all the constants defined by this enum. @@ -20,18 +20,18 @@ abstract class Enum { * @return array */ public static function getAll() { - return self::_reflect()->getConstants(); + return static::_reflect()->getConstants(); } /** * @return ReflectionClass */ - private static function _reflect() { - if (empty(self::$_reflection)) { - self::$_reflection = new ReflectionClass(static::class); + protected static function _reflect() { + if (!array_key_exists(static::class, self::$_reflections)) { + self::$_reflections[static::class] = new ReflectionClass(static::class); } - return self::$_reflection; + return self::$_reflections[static::class]; } } \ No newline at end of file