From b19f484e4ae186a411c116ebd7898504ae0c6e02 Mon Sep 17 00:00:00 2001 From: Lars Moelleken Date: Wed, 28 Jan 2015 23:28:07 +0100 Subject: [PATCH] [-]: "remove accepted_args option, all arguments are always transmitted" - https://github.com/mistic100/PHP-Hooks/commit/16c9d198f5f711ea96cf162861d1df1a1fd80fed --- src/voku/helper/Hooks.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/voku/helper/Hooks.php b/src/voku/helper/Hooks.php index 929b8a9..91dc66c 100644 --- a/src/voku/helper/Hooks.php +++ b/src/voku/helper/Hooks.php @@ -12,14 +12,16 @@ * of the code comes from there. * * - * @version 0.1.3 - * @copyright 2011 - 2014 + * @version 0.1.5 + * @copyright 2011 - 2015 * @author Ohad Raz (email: admin@bainternet.info) * @link http://en.bainternet.info * @author David Miles * @link http://github.com/amereservant/PHP-Hooks * @author Lars Moelleken * @link https://github.com/voku/PHP-Hooks/ + * @author Damien "Mistic" Sorel (email: contact@git.strangeplanet.fr) + * @link http://www.strangeplanet.fr * * @license GNU General Public License v3.0 - license.txt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR @@ -162,17 +164,15 @@ public static function getInstance() * Lower numbers correspond with earlier execution, * and functions with the same priority are executed * in the order in which they were added to the action. - * @param integer $accepted_args (optional) The number of arguments the function accept (default 1). * * @return boolean true */ - public function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) + public function add_filter($tag, $function_to_add, $priority = 10) { $idx = $this->_filter_build_unique_id($tag, $function_to_add, $priority); $this->filters[$tag][$priority][$idx] = array( - 'function' => $function_to_add, - 'accepted_args' => $accepted_args + 'function' => $function_to_add ); unset($this->merged_filters[$tag]); @@ -334,7 +334,7 @@ public function apply_filters($tag, $value) if (!is_null($the_['function'])) { $args[1] = $value; - $value = call_user_func_array($the_['function'], array_slice($args, 1, (int)$the_['accepted_args'])); + $value = call_user_func_array($the_['function'], array_slice($args, 1)); } } } @@ -390,7 +390,7 @@ public function apply_filters_ref_array($tag, $args) do { foreach ((array)current($this->filters[$tag]) as $the_) { if (!is_null($the_['function'])) { - $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); + $args[0] = call_user_func_array($the_['function'], $args); } } } @@ -419,15 +419,14 @@ public function apply_filters_ref_array($tag, $args) * Lower numbers correspond with earlier execution, * and functions with the same priority are executed * in the order in which they were added to the action. - * @param integer $accepted_args (optional) The number of arguments the function accept (default 1). * * @access public * @since 1.0.0 * @return bool */ - public function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) + public function add_action($tag, $function_to_add, $priority = 10) { - return $this->add_filter($tag, $function_to_add, $priority, $accepted_args); + return $this->add_filter($tag, $function_to_add, $priority); } /** @@ -556,7 +555,7 @@ public function do_action($tag, $arg = '') do { foreach ((array)current($this->filters[$tag]) as $the_) { if (!is_null($the_['function'])) { - call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); + call_user_func_array($the_['function'], $args); } } } @@ -619,7 +618,7 @@ public function do_action_ref_array($tag, $args) do { foreach ((array)current($this->filters[$tag]) as $the_) { if (!is_null($the_['function'])) { - call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); + call_user_func_array($the_['function'], $args); } } }