Skip to content

Commit a9d1137

Browse files
committed
docblocks
[skip ci]
1 parent 79c73b2 commit a9d1137

File tree

7 files changed

+133
-54
lines changed

7 files changed

+133
-54
lines changed

src/Event/Hook.php

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,42 @@
66

77
class 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
{

src/Exception/WP_ErrorException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class WP_ErrorException extends \RuntimeException
88
{
9+
/**
10+
* WP_ErrorException Constructor.
11+
*
12+
* @param WP_Error $error The error to set the message from
13+
*/
914
public function __construct(WP_Error $error)
1015
{
1116
$this->message = $error->get_error_message();

src/Meta/Meta.php

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,33 @@ class Meta
1111
* @var string
1212
*/
1313
protected $type;
14-
14+
/**
15+
* The object ID this metadata is for
16+
* @var int
17+
*/
1518
protected $object_id;
16-
19+
/**
20+
* The key the metadata is for
21+
* @var string
22+
*/
1723
protected $key;
1824

1925
/**
26+
* Meta Constructor.
27+
*
2028
* @param string $type Meta type
2129
* @param int|string $object_id ID of the object metadata is for
2230
* @param string $key Meta key
2331
*/
2432
public function __construct($type, $object_id, $key)
2533
{
2634
$this->type = $type;
27-
$this->object_id = $object_id;
35+
$this->object_id = (int) $object_id;
2836
$this->key = $key;
2937
}
3038

3139
/**
32-
* Get the single meta data
40+
* Get the single meta data.
3341
*
3442
* @return mixed
3543
*/
@@ -39,7 +47,7 @@ public function get()
3947
}
4048

4149
/**
42-
* Get all meta data
50+
* Get all meta data.
4351
*
4452
* @return Collection
4553
*/
@@ -49,7 +57,7 @@ public function all()
4957
}
5058

5159
/**
52-
* Set the meta value
60+
* Set the meta value.
5361
*
5462
* @param mixed $value
5563
* @param string $prev_value
@@ -62,10 +70,12 @@ public function set($value, $prev_value = '')
6270
}
6371

6472
/**
65-
* Add metadata for the specified object
73+
* Add metadata for the specified object.
6674
*
6775
* @param mixed $value The value to add
68-
* @param bool $unique
76+
* @param bool $unique Whether the specified metadata key should be unique
77+
* for the object. If true, and the object already has
78+
* a value for the specified metadata key, no change will be made.
6979
*
7080
* @return int|false The meta ID on success, false on failure.
7181
*/
@@ -93,7 +103,7 @@ public function delete($value = '')
93103
}
94104

95105
/**
96-
* Determine if a meta key is set for a given object
106+
* Determine if a meta key is set for a given object.
97107
*
98108
* @return bool True of the key is set, false if not.
99109
*/
@@ -103,23 +113,32 @@ public function exists()
103113
}
104114

105115
/**
106-
* Get the object_id
116+
* Get the object_id.
107117
*
108-
* @return int|string
118+
* @return int Object ID
109119
*/
110120
public function getObjectId()
111121
{
112122
return $this->object_id;
113123
}
114124

115125
/**
126+
* Magic getter.
127+
*
128+
* @param string $property The called unaccessible property name
116129
*
130+
* @return mixed
117131
*/
118132
public function __get($property)
119133
{
120134
return $this->get($property);
121135
}
122136

137+
/**
138+
* Get the string representation of the meta data.
139+
*
140+
* @return string The meta value
141+
*/
123142
public function __toString()
124143
{
125144
return $this->get();

src/Post/Exception/ModelPostTypeMismatchException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ class ModelPostTypeMismatchException extends \RuntimeException
99
{
1010
const MESSAGE_FORMAT = '{modelClass} instantiated with post of type "{givenPostType}", but requires a post of type "{modelPostType}".';
1111

12+
/**
13+
* The model's full class name
14+
* @var string
15+
*/
1216
protected $modelClass;
17+
/**
18+
* The post object
19+
* @var WP_Post
20+
*/
1321
protected $post;
1422

23+
/**
24+
* ModelPostTypeMismatchException Constructor.
25+
*
26+
* @param string $modelClass The model's full class name
27+
* @param WP_Post $post The post object
28+
*/
1529
public function __construct($modelClass, WP_Post $post)
1630
{
1731
$this->modelClass = $modelClass;

src/Post/PostType.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PostType
2626
/**
2727
* PostType Constructor
2828
*
29-
* @param object post type object
29+
* @param stdClass $object The WordPress post type object
3030
*/
3131
public function __construct(stdClass $object)
3232
{
@@ -38,10 +38,10 @@ public function __construct(stdClass $object)
3838
*
3939
* Loads an existing type, or returns a new builder for registering a new type.
4040
*
41-
* @param string $slug string - the post type slug ("name")
41+
* @param string $slug The post type slug
4242
*
43-
* @return mixed static - if the post type has been registered
44-
* PostTypeBuilder otherwise
43+
* @return static|PostTypeBuilder If the post type has been registered, a new static instance is returned.
44+
* Otherwise a new PostTypeBuilder is created for building a new post type to register.
4545
*/
4646
public static function make($slug)
4747
{
@@ -55,7 +55,7 @@ public static function make($slug)
5555
/**
5656
* Create a new instance from an existing type.
5757
*
58-
* @param string $slug post type id (slug/name)
58+
* @param string $slug The post type slug
5959
*
6060
* @return static
6161
*/
@@ -71,6 +71,8 @@ public static function load($slug)
7171
/**
7272
* Checks if a post type with this slug has been registered.
7373
*
74+
* @param string $slug The post type slug
75+
*
7476
* @return bool
7577
*/
7678
public static function exists($slug)
@@ -91,8 +93,8 @@ public function object()
9193
/**
9294
* Check for feature support.
9395
*
94-
* @param mixed $features string - feature
95-
* array - many features
96+
* @param string,...|array $features string - First feature of possible many,
97+
* array - Many features to check support for.
9698
*
9799
* @return mixed
98100
*/

0 commit comments

Comments
 (0)