aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-01-06 15:33:21 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-01-06 15:33:21 +0100
commit290418207ea74e6053d5c98933cf5fcb3a41dcfd (patch)
tree77c22156fb24278d3885c0fa77d018abcdfe5523
parent75f94a48b4b0c63aae1a120c27d81f41069dba7c (diff)
downloadPraspel-290418207ea74e6053d5c98933cf5fcb3a41dcfd.zip
Praspel-290418207ea74e6053d5c98933cf5fcb3a41dcfd.tar.gz
Praspel-290418207ea74e6053d5c98933cf5fcb3a41dcfd.tar.bz2
Preambler: Use non-static cache in handler.
The static cache approach in the handler is wrong. Static means shared, and we do not want it to be shared amongst instances of `Handler`. The cache must be dynamic and must belong to the current instance of an `Handler`.
-rw-r--r--Preambler/Handler.php29
1 files changed, 20 insertions, 9 deletions
diff --git a/Preambler/Handler.php b/Preambler/Handler.php
index b51e917..0112992 100644
--- a/Preambler/Handler.php
+++ b/Preambler/Handler.php
@@ -54,7 +54,21 @@ class Handler
*
* @var \Hoa\Consistency\Xcallable
*/
- protected $__callable = null;
+ protected $__callable = null;
+
+ /**
+ * Generated reflection object.
+ *
+ * This is a cache.
+ */
+ private $__reflectionObject = null;
+
+ /**
+ * Generated object.
+ *
+ * This is a cache.
+ */
+ private $__object = null;
@@ -80,10 +94,7 @@ class Handler
*/
public function __getReflectionObject(&$object)
{
- static $_out = null;
- static $_object = null;
-
- if (null === $_out) {
+ if (null === $this->__reflectionObject) {
$callback = $this->__getCallable()->getValidCallback();
if (!is_object($callback[0])) {
@@ -94,13 +105,13 @@ class Handler
);
}
- $_object = $callback[0];
- $_out = new \ReflectionObject($_object);
+ $this->__object = $callback[0];
+ $this->__reflectionObject = new \ReflectionObject($this->__object);
}
- $object = $_object;
+ $object = $this->__object;
- return $_out;
+ return $this->__reflectionObject;
}
/**