66
77class Hook
88{
9+ /**
10+ * The action or filter handle attached to.
11+ * @var string
12+ */
913 protected $ handle ;
10-
14+ /**
15+ * The callback object holding the target callable.
16+ * @var Callback
17+ */
1118 protected $ callback ;
12-
19+ /**
20+ * The number of parameters defined in the callback's signature.
21+ * @var int
22+ */
1323 protected $ callbackParamCount ;
14-
24+ /**
25+ * The action or filter priority the callback is registered on.
26+ * @var mixed
27+ */
1528 protected $ priority ;
16-
29+ /**
30+ * The number of times the callback has been invoked.
31+ * @var int
32+ */
1733 protected $ iterations ;
18-
34+ /**
35+ * The maximum number of iterations allowed for the callback to be invoked.
36+ * @var int
37+ */
1938 protected $ maxIterations ;
2039
2140
2241 /**
23- * Create a new Hook instance
42+ * Create a new Hook instance.
2443 *
25- * @param string $handle action or filter handle
44+ * @param string $handle Action or filter handle
2645 * @param int $priority
2746 *
2847 * @return static
@@ -33,9 +52,9 @@ public static function on($handle, $priority = 10)
3352 }
3453
3554 /**
36- * Create a new Hook instance
55+ * Create a new Hook instance.
3756 *
38- * @param string $handle action or filter handle
57+ * @param string $handle Action or filter handle
3958 * @param int $priority
4059 */
4160 public function __construct ($ handle , $ priority = 10 )
@@ -45,9 +64,9 @@ public function __construct($handle, $priority = 10)
4564 }
4665
4766 /**
48- * Set the callback to be invoked by the action or filter
67+ * Set the callback to be invoked by the action or filter.
4968 *
50- * @param callable $callback
69+ * @param callable $callback The callback to be invoked
5170 *
5271 * @return $this
5372 */
@@ -60,7 +79,7 @@ public function setCallback(callable $callback)
6079 }
6180
6281 /**
63- * Set the hook in WordPress
82+ * Set the hook in WordPress.
6483 *
6584 * Both actions and filters are registered as filters.
6685 *
@@ -74,7 +93,7 @@ public function listen()
7493 }
7594
7695 /**
77- * Unset the hook in WordPress
96+ * Unset the hook in WordPress.
7897 *
7998 * @return $this
8099 */
@@ -86,9 +105,12 @@ public function remove()
86105 }
87106
88107 /**
89- * Control invocation of the callback
108+ * Control invocation of the callback.
109+ *
110+ * @param $given The first argument passed to the callback.
111+ * Needed to return for filters.
90112 *
91- * @return mixed callback returned value
113+ * @return mixed Returned value from Callback
92114 */
93115 public function mediateCallback ($ given = null )
94116 {
@@ -100,13 +122,13 @@ public function mediateCallback($given = null)
100122 }
101123
102124 /**
103- * Whether or not the callback should be invoked
125+ * Whether or not the callback should be invoked.
104126 *
105- * @param array $args all arguments passed to the callback
127+ * @param array $arguments All arguments passed to the callback
106128 *
107129 * @return bool
108130 */
109- public function shouldInvoke (array $ args )
131+ public function shouldInvoke (array $ arguments )
110132 {
111133 if ($ this ->hasExceededIterations ()) {
112134 return false ;
@@ -116,11 +138,11 @@ public function shouldInvoke(array $args)
116138 }
117139
118140 /**
119- * Call the callback
141+ * Call the callback.
120142 *
121- * @param array $arguments the arguments expected by the callback
143+ * @param array $arguments All arguments passed to the callback
122144 *
123- * @return mixed returned output from the callback
145+ * @return mixed The value returned from the callback
124146 */
125147 protected function invokeCallback ($ arguments )
126148 {
@@ -132,7 +154,7 @@ protected function invokeCallback($arguments)
132154 }
133155
134156 /**
135- * Set the callback to only be invoked one time
157+ * Set the callback to only be invokable one time.
136158 *
137159 * @return $this
138160 */
@@ -144,9 +166,9 @@ public function once()
144166 }
145167
146168 /**
147- * Set the callback to only be invoked the given number of times
169+ * Set the maximum number of callback invocations to allow.
148170 *
149- * @param int $times maimum iterations of invocations to allow
171+ * @param int $times The maximum iterations of invocations to allow
150172 *
151173 * @return $this
152174 */
@@ -158,7 +180,7 @@ public function onlyXtimes($times)
158180 }
159181
160182 /**
161- * Prevent the callback from being triggered again
183+ * Prevent the callback from being triggered again.
162184 *
163185 * @return $this
164186 */
@@ -170,9 +192,9 @@ public function bypass()
170192 }
171193
172194 /**
173- * Set the priority the callback should be registered with
195+ * Set the priority the callback should be registered with.
174196 *
175- * @param string|int $ priority
197+ * @param mixed $priority The callback priority
176198 *
177199 * @return $this
178200 */
@@ -188,9 +210,9 @@ public function withPriority($priority)
188210 }
189211
190212 /**
191- * Whether or not the callback has reached the limit of allowed invocations
213+ * Whether or not the callback has reached the limit of allowed invocations.
192214 *
193- * @return boolean true for limit reached, otherwise false
215+ * @return boolean true for limit reached/exceeded , otherwise false
194216 */
195217 protected function hasExceededIterations ()
196218 {
0 commit comments