Skip to content

Commit b3296fb

Browse files
committed
Downgrading to php 5.6
1 parent a71ff04 commit b3296fb

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

Diff for: src/HookStorage.php

+33-10
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,38 @@ public static function get($objectOrClass, $hook)
7474
*/
7575
public static function getHookId($object)
7676
{
77-
$func = (function($object) {
77+
$func = ClosureHelper::getInstance()->getHookClosure();
78+
79+
$bcl = $func->bindTo($object, $object);
80+
81+
return $bcl($object);
82+
}
83+
84+
private function __construct()
85+
{
86+
}
87+
}
88+
89+
class ClosureHelper
90+
{
91+
private function __construct()
92+
{
93+
}
94+
95+
private static $instance = null;
96+
97+
public static function getInstance()
98+
{
99+
if(null === self::$instance) {
100+
self::$instance = new self();
101+
}
102+
103+
return self::$instance;
104+
}
105+
106+
public function getHookClosure()
107+
{
108+
return function($object) {
78109
if (false == property_exists($object, 'hookId')) {
79110
$object->hookId = null;
80111
}
@@ -84,14 +115,6 @@ public static function getHookId($object)
84115
}
85116

86117
return $object->hookId;
87-
});
88-
89-
$bcl = $func->bindTo($object, $object);
90-
91-
return $bcl($object);
92-
}
93-
94-
private function __construct()
95-
{
118+
};
96119
}
97120
}

Diff for: src/functions/objects.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function set_object($context, $key, $object)
2727
}
2828
});
2929

30-
$bcl = $func->bindTo($object, $object);
30+
$bcl = $func->bindTo($context, $context);
3131

3232
return $bcl($key, $object);
3333
}

0 commit comments

Comments
 (0)