$hooks = function($meta, $type) use ($inspector, $instance) { if (isset($meta[$type])) { $run = array(); foreach ($meta[$type] as $method) { $hookMeta = $inspector->getMethodMeta($method); if (in_array($method, $run) && !empty($hookMeta["@once"])) { continue; } $instance->$method(); $run[] = $method; } } }; $hooks($methodMeta, "@before");
This hooks function has a use in it what's going on?
I can't think of .... Master Wang told
Reply content:
$hooks = function($meta, $type) use ($inspector, $instance) { if (isset($meta[$type])) { $run = array(); foreach ($meta[$type] as $method) { $hookMeta = $inspector->getMethodMeta($method); if (in_array($method, $run) && !empty($hookMeta["@once"])) { continue; } $instance->$method(); $run[] = $method; } } }; $hooks($methodMeta, "@before");
This hooks function has a use in it what's going on?
I can't think of .... Master Wang told
5.3 In the new closure syntax, use is used to capture variables into anonymous functions, see:
http://www.php.net/manual/zh/functions.anonymous.php
Http://www.cnblogs.com/melonblog/archive/2013/05/01/3052611.html