@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param array<string, mixed> $labels |
272 | 272 | * @return array<string, mixed> |
273 | 273 | */ |
274 | - public function filter_labels( array $labels ): array { |
|
274 | + public function filter_labels(array $labels): array { |
|
275 | 275 | return $labels; |
276 | 276 | } |
277 | 277 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @param array<string, mixed> $args |
282 | 282 | * @return array<string, mixed> |
283 | 283 | */ |
284 | - public function filter_args( array $args ): array { |
|
284 | + public function filter_args(array $args): array { |
|
285 | 285 | return $args; |
286 | 286 | } |
287 | 287 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param Meta_Data[] $collection |
292 | 292 | * @return Meta_Data[] |
293 | 293 | */ |
294 | - public function meta_data( array $collection ): array { |
|
294 | + public function meta_data(array $collection): array { |
|
295 | 295 | return $collection; |
296 | 296 | } |
297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param Meta_Box[] $collection |
302 | 302 | * @return Meta_Box[] |
303 | 303 | */ |
304 | - public function meta_boxes( array $collection ): array { |
|
304 | + public function meta_boxes(array $collection): array { |
|
305 | 305 | return $collection; |
306 | 306 | } |
307 | 307 | } |
@@ -25,4 +25,4 @@ |
||
25 | 25 | |
26 | 26 | namespace PinkCrab\Registerables\Registration_Middleware; |
27 | 27 | |
28 | -interface Registerable{} |
|
28 | +interface Registerable {} |
@@ -35,5 +35,5 @@ |
||
35 | 35 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable |
36 | 36 | * @return void |
37 | 37 | */ |
38 | - public function register( Registerable $registerable ): void; |
|
38 | + public function register(Registerable $registerable): void; |
|
39 | 39 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | class Meta_Box_Validator extends Abstract_Validator { |
34 | 34 | |
35 | - protected const REQUIRED_FIELDS = array( 'key', 'label' ); |
|
35 | + protected const REQUIRED_FIELDS = array('key', 'label'); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Validates the class passed. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - public function validate( Registerable $object ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
43 | + public function validate(Registerable $object): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
44 | 44 | return false; //no op |
45 | 45 | } |
46 | 46 | |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @param mixed $meta_box |
51 | 51 | * @return bool |
52 | 52 | */ |
53 | - public function verify_meta_box( $meta_box ): bool { |
|
53 | + public function verify_meta_box($meta_box): bool { |
|
54 | 54 | // If this is not a valid post type, just bail here. |
55 | - if ( ! is_object( $meta_box ) || ! is_a( $meta_box, Meta_Box::class ) ) { |
|
56 | - $this->add_error( sprintf( '%s is not a valid Meta Box Model', is_object( $meta_box ) ? get_class( $meta_box ) : \gettype( $meta_box ) ) ); |
|
55 | + if ( ! is_object($meta_box) || ! is_a($meta_box, Meta_Box::class)) { |
|
56 | + $this->add_error(sprintf('%s is not a valid Meta Box Model', is_object($meta_box) ? get_class($meta_box) : \gettype($meta_box))); |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /* @var Meta_Box $object, already confirmed as a post type */ |
61 | 61 | |
62 | 62 | // Ensure all required fields are set. |
63 | - $this->has_required_fields( $meta_box ); |
|
63 | + $this->has_required_fields($meta_box); |
|
64 | 64 | |
65 | 65 | // Ensure can render view. |
66 | - $this->has_valid_view( $meta_box ); |
|
66 | + $this->has_valid_view($meta_box); |
|
67 | 67 | |
68 | 68 | // Check if the passed object has any errors. |
69 | 69 | return ! $this->has_errors(); |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * @param Meta_Box $meta_box |
76 | 76 | * @return void |
77 | 77 | */ |
78 | - protected function has_required_fields( Meta_Box $meta_box ): void { |
|
79 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
80 | - if ( ! is_string( $meta_box->{$field} ) |
|
81 | - || \mb_strlen( $meta_box->{$field} ) === 0 |
|
78 | + protected function has_required_fields(Meta_Box $meta_box): void { |
|
79 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
80 | + if ( ! is_string($meta_box->{$field} ) |
|
81 | + || \mb_strlen($meta_box->{$field} ) === 0 |
|
82 | 82 | ) { |
83 | - $this->add_error( sprintf( '%s is not set on %s Meta Box Model', $field, get_class( $meta_box ) ) ); |
|
83 | + $this->add_error(sprintf('%s is not set on %s Meta Box Model', $field, get_class($meta_box))); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
93 | 93 | * @return void |
94 | 94 | */ |
95 | - protected function has_valid_view( Meta_Box $meta_box ): void { |
|
96 | - if ( ! \is_callable( $meta_box->view ) |
|
97 | - && ( ! is_string( $meta_box->view_template ) |
|
98 | - || ( is_string( $meta_box->view_template ) && \mb_strlen( $meta_box->view_template ) === 0 ) |
|
95 | + protected function has_valid_view(Meta_Box $meta_box): void { |
|
96 | + if ( ! \is_callable($meta_box->view) |
|
97 | + && ( ! is_string($meta_box->view_template) |
|
98 | + || (is_string($meta_box->view_template) && \mb_strlen($meta_box->view_template) === 0) |
|
99 | 99 | ) |
100 | 100 | ) { |
101 | - $this->add_error( sprintf( '%s doesn\'t have a valid view defined.', get_class( $meta_box ) ) ); |
|
101 | + $this->add_error(sprintf('%s doesn\'t have a valid view defined.', get_class($meta_box))); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Post_Type_Validator extends Abstract_Validator { |
33 | 33 | |
34 | - protected const REQUIRED_FIELDS = array( 'key', 'singular', 'plural' ); |
|
34 | + protected const REQUIRED_FIELDS = array('key', 'singular', 'plural'); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function validate( Registerable $object ): bool { |
|
42 | + public function validate(Registerable $object): bool { |
|
43 | 43 | // If this is not a valid post type, just bail here. |
44 | - if ( ! is_a( $object, Post_Type::class ) ) { |
|
45 | - $this->add_error( sprintf( '%s is not a valid Post Type Model', get_class( $object ) ) ); |
|
44 | + if ( ! is_a($object, Post_Type::class)) { |
|
45 | + $this->add_error(sprintf('%s is not a valid Post Type Model', get_class($object))); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* @var Post_Type $object, already confirmed as a post type */ |
50 | 50 | |
51 | 51 | // Ensure all required fields are set. |
52 | - $this->has_required_fields( $object ); |
|
52 | + $this->has_required_fields($object); |
|
53 | 53 | |
54 | 54 | // Check if the passed object has any errors. |
55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @param Post_Type $post_type |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - protected function has_required_fields( Post_Type $post_type ): void { |
|
65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
66 | - if ( ! is_string( $post_type->{$field} ) |
|
67 | - || \mb_strlen( $post_type->{$field} ) === 0 |
|
64 | + protected function has_required_fields(Post_Type $post_type): void { |
|
65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
66 | + if ( ! is_string($post_type->{$field} ) |
|
67 | + || \mb_strlen($post_type->{$field} ) === 0 |
|
68 | 68 | ) { |
69 | - $this->add_error( sprintf( '%s is not set on %s Post Type Model', $field, get_class( $post_type ) ) ); |
|
69 | + $this->add_error(sprintf('%s is not set on %s Post Type Model', $field, get_class($post_type))); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Taxonomy_Validator extends Abstract_Validator { |
33 | 33 | |
34 | - protected const REQUIRED_FIELDS = array( 'slug', 'singular', 'plural' ); |
|
34 | + protected const REQUIRED_FIELDS = array('slug', 'singular', 'plural'); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function validate( Registerable $object ): bool { |
|
42 | + public function validate(Registerable $object): bool { |
|
43 | 43 | // If this is not a valid taxonomy, just bail here. |
44 | - if ( ! is_a( $object, Taxonomy::class ) ) { |
|
45 | - $this->add_error( sprintf( '%s is not a valid Taxonomy Model', get_class( $object ) ) ); |
|
44 | + if ( ! is_a($object, Taxonomy::class)) { |
|
45 | + $this->add_error(sprintf('%s is not a valid Taxonomy Model', get_class($object))); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* @var Taxonomy $object, already confirmed as a Taxonomy */ |
50 | 50 | |
51 | 51 | // Ensure all required fields are set. |
52 | - $this->has_required_fields( $object ); |
|
52 | + $this->has_required_fields($object); |
|
53 | 53 | |
54 | 54 | // Check if the passed object has any errors. |
55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @param Taxonomy $taxonomy |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - protected function has_required_fields( Taxonomy $taxonomy ): void { |
|
65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
66 | - if ( ! is_string( $taxonomy->{$field} ) |
|
67 | - || \mb_strlen( $taxonomy->{$field} ) === 0 |
|
64 | + protected function has_required_fields(Taxonomy $taxonomy): void { |
|
65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
66 | + if ( ! is_string($taxonomy->{$field} ) |
|
67 | + || \mb_strlen($taxonomy->{$field} ) === 0 |
|
68 | 68 | ) { |
69 | - $this->add_error( sprintf( '%s is not set on %s Taxonomy Model', $field, get_class( $taxonomy ) ) ); |
|
69 | + $this->add_error(sprintf('%s is not set on %s Taxonomy Model', $field, get_class($taxonomy))); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @return bool |
42 | 42 | */ |
43 | 43 | public function has_errors(): bool { |
44 | - return count( $this->errors ) >= 1; |
|
44 | + return count($this->errors) >= 1; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $error |
60 | 60 | * @return self |
61 | 61 | */ |
62 | - public function add_error( string $error ): self { |
|
62 | + public function add_error(string $error): self { |
|
63 | 63 | $this->errors[] = $error; |
64 | 64 | return $this; |
65 | 65 | } |
@@ -80,5 +80,5 @@ discard block |
||
80 | 80 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - abstract public function validate( Registerable $object ): bool; |
|
83 | + abstract public function validate(Registerable $object): bool; |
|
84 | 84 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected $meta_key; |
97 | 97 | |
98 | - public function __construct( string $meta_key ) { |
|
98 | + public function __construct(string $meta_key) { |
|
99 | 99 | $this->meta_key = $meta_key; |
100 | 100 | } |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string $meta_type Object type meta applies to |
107 | 107 | * @return self |
108 | 108 | */ |
109 | - public function meta_type( string $meta_type ): self { |
|
109 | + public function meta_type(string $meta_type): self { |
|
110 | 110 | $this->meta_type = $meta_type; |
111 | 111 | return $this; |
112 | 112 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string|null $object_subtype Holds a secondary object type, used for post type and taxonomy. |
118 | 118 | * @return self |
119 | 119 | */ |
120 | - public function object_subtype( ?string $object_subtype ): self { |
|
120 | + public function object_subtype(?string $object_subtype): self { |
|
121 | 121 | $this->object_subtype = $object_subtype ?? ''; |
122 | 122 | return $this; |
123 | 123 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $type |
130 | 130 | * @return self |
131 | 131 | */ |
132 | - public function type( string $type ): self { |
|
132 | + public function type(string $type): self { |
|
133 | 133 | $this->type = $type; |
134 | 134 | return $this; |
135 | 135 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * @param string $post_type |
141 | 141 | * @return self |
142 | 142 | */ |
143 | - public function post_type( string $post_type ): self { |
|
144 | - $this->meta_type( 'post' ); |
|
145 | - $this->object_subtype( $post_type ); |
|
143 | + public function post_type(string $post_type): self { |
|
144 | + $this->meta_type('post'); |
|
145 | + $this->object_subtype($post_type); |
|
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @param string $taxonomy |
153 | 153 | * @return self |
154 | 154 | */ |
155 | - public function taxonomy( string $taxonomy ): self { |
|
156 | - $this->meta_type( 'term' ); |
|
157 | - $this->object_subtype( $taxonomy ); |
|
155 | + public function taxonomy(string $taxonomy): self { |
|
156 | + $this->meta_type('term'); |
|
157 | + $this->object_subtype($taxonomy); |
|
158 | 158 | return $this; |
159 | 159 | } |
160 | 160 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return self |
167 | 167 | */ |
168 | - public function description( string $description ): self { |
|
168 | + public function description(string $description): self { |
|
169 | 169 | $this->description = $description; |
170 | 170 | return $this; |
171 | 171 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param bool $single Meta value is single value or array |
177 | 177 | * @return self |
178 | 178 | */ |
179 | - public function single( bool $single = true ): self { |
|
179 | + public function single(bool $single = true): self { |
|
180 | 180 | $this->single = $single; |
181 | 181 | return $this; |
182 | 182 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param mixed $default |
188 | 188 | * @return self |
189 | 189 | */ |
190 | - public function default( $default ): self { |
|
190 | + public function default($default): self { |
|
191 | 191 | $this->default = $default; |
192 | 192 | return $this; |
193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param callable(mixed):mixed $callback |
199 | 199 | * @return self |
200 | 200 | */ |
201 | - public function sanitize( callable $callback ): self { |
|
201 | + public function sanitize(callable $callback): self { |
|
202 | 202 | $this->callbacks['sanitize'] = $callback; |
203 | 203 | return $this; |
204 | 204 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param callable $callback |
210 | 210 | * @return self |
211 | 211 | */ |
212 | - public function permissions( callable $callback ): self { |
|
212 | + public function permissions(callable $callback): self { |
|
213 | 213 | $this->callbacks['permissions'] = $callback; |
214 | 214 | return $this; |
215 | 215 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param bool|array<mixed> $rest_schema Rest schema definitions |
221 | 221 | * @return self |
222 | 222 | */ |
223 | - public function rest_schema( $rest_schema ): self { |
|
223 | + public function rest_schema($rest_schema): self { |
|
224 | 224 | $this->rest_schema = $rest_schema; |
225 | 225 | return $this; |
226 | 226 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | ); |
243 | 243 | |
244 | 244 | // Set subtype. |
245 | - if ( $this->object_subtype !== null ) { |
|
245 | + if ($this->object_subtype !== null) { |
|
246 | 246 | $args['object_subtype'] = $this->object_subtype; |
247 | 247 | } |
248 | 248 | return $args; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @var string[] |
74 | 74 | */ |
75 | - public $object_type = array( 'post' ); |
|
75 | + public $object_type = array('post'); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Should this taxonomy have a hierarchy |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param array<string, mixed> $labels |
212 | 212 | * @return array<string, mixed> |
213 | 213 | */ |
214 | - public function filter_labels( array $labels ): array { |
|
214 | + public function filter_labels(array $labels): array { |
|
215 | 215 | return $labels; |
216 | 216 | } |
217 | 217 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param array<string, mixed> $args |
222 | 222 | * @return array<string, mixed> |
223 | 223 | */ |
224 | - public function filter_args( array $args ): array { |
|
224 | + public function filter_args(array $args): array { |
|
225 | 225 | return $args; |
226 | 226 | } |
227 | 227 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param Meta_Data[] $collection |
232 | 232 | * @return Meta_Data[] |
233 | 233 | */ |
234 | - public function meta_data( array $collection ): array { |
|
234 | + public function meta_data(array $collection): array { |
|
235 | 235 | return $collection; |
236 | 236 | } |
237 | 237 | } |