@@ -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 | } |
@@ -38,6 +38,6 @@ |
||
38 | 38 | * @return Meta_Data[] |
39 | 39 | * @codeCoverageIgnore |
40 | 40 | */ |
41 | - abstract public function meta_data( array $meta_data ): array; |
|
41 | + abstract public function meta_data(array $meta_data): array; |
|
42 | 42 | |
43 | 43 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @var string[] |
74 | 74 | */ |
75 | - public array $object_type = array( 'post' ); |
|
75 | + public array $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 | } |
@@ -24,4 +24,4 @@ |
||
24 | 24 | |
25 | 25 | namespace PinkCrab\Registerables\Module\Middleware; |
26 | 26 | |
27 | -interface Registerable{} |
|
27 | +interface Registerable {} |
@@ -45,10 +45,10 @@ |
||
45 | 45 | ## Unused methods |
46 | 46 | |
47 | 47 | /** @inheritDoc */ |
48 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
48 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
49 | 49 | /** @inheritDoc */ |
50 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
50 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
51 | 51 | /** @inheritDoc */ |
52 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
52 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
53 | 53 | |
54 | 54 | } |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | protected $default = ''; |
71 | 71 | |
72 | 72 | /** |
73 | - * The meta fields callbacks |
|
74 | - * |
|
75 | - * @var array{ |
|
76 | - * sanitize: null|callable, |
|
77 | - * permissions: null|callable, |
|
78 | - * rest_view: null|callable(mixed[]): void, |
|
79 | - * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
80 | - * } |
|
81 | - */ |
|
73 | + * The meta fields callbacks |
|
74 | + * |
|
75 | + * @var array{ |
|
76 | + * sanitize: null|callable, |
|
77 | + * permissions: null|callable, |
|
78 | + * rest_view: null|callable(mixed[]): void, |
|
79 | + * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
80 | + * } |
|
81 | + */ |
|
82 | 82 | protected array $callbacks = array( |
83 | 83 | 'sanitize' => null, |
84 | 84 | 'permissions' => null, |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Sets the GET callback for REST requests. |
|
235 | - * |
|
236 | - * @param callable|null $callback |
|
237 | - * @return self |
|
238 | - */ |
|
234 | + * Sets the GET callback for REST requests. |
|
235 | + * |
|
236 | + * @param callable|null $callback |
|
237 | + * @return self |
|
238 | + */ |
|
239 | 239 | public function rest_view( ?callable $callback ): self { |
240 | 240 | $this->callbacks['rest_view'] = $callback; |
241 | 241 | return $this; |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
315 | - * Gets the GET callback for REST requests. |
|
316 | - * |
|
317 | - * @return null|callable(mixed[]): void |
|
318 | - */ |
|
315 | + * Gets the GET callback for REST requests. |
|
316 | + * |
|
317 | + * @return null|callable(mixed[]): void |
|
318 | + */ |
|
319 | 319 | public function get_rest_view(): ?callable { |
320 | 320 | return $this->callbacks['rest_view']; |
321 | 321 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected string $meta_key; |
102 | 102 | |
103 | - public function __construct( string $meta_key ) { |
|
103 | + public function __construct(string $meta_key) { |
|
104 | 104 | $this->meta_key = $meta_key; |
105 | 105 | } |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $meta_type Object type meta applies to |
112 | 112 | * @return self |
113 | 113 | */ |
114 | - public function meta_type( string $meta_type ): self { |
|
114 | + public function meta_type(string $meta_type): self { |
|
115 | 115 | $this->meta_type = $meta_type; |
116 | 116 | return $this; |
117 | 117 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param string|null $object_subtype Holds a secondary object type, used for post type and taxonomy. |
123 | 123 | * @return self |
124 | 124 | */ |
125 | - public function object_subtype( ?string $object_subtype ): self { |
|
125 | + public function object_subtype(?string $object_subtype): self { |
|
126 | 126 | $this->object_subtype = $object_subtype ?? ''; |
127 | 127 | return $this; |
128 | 128 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $type |
135 | 135 | * @return self |
136 | 136 | */ |
137 | - public function type( string $type ): self { |
|
137 | + public function type(string $type): self { |
|
138 | 138 | $this->type = $type; |
139 | 139 | return $this; |
140 | 140 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string $post_type |
146 | 146 | * @return self |
147 | 147 | */ |
148 | - public function post_type( string $post_type ): self { |
|
149 | - $this->meta_type( 'post' ); |
|
150 | - $this->object_subtype( $post_type ); |
|
148 | + public function post_type(string $post_type): self { |
|
149 | + $this->meta_type('post'); |
|
150 | + $this->object_subtype($post_type); |
|
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param string $taxonomy |
158 | 158 | * @return self |
159 | 159 | */ |
160 | - public function taxonomy( string $taxonomy ): self { |
|
161 | - $this->meta_type( 'term' ); |
|
162 | - $this->object_subtype( $taxonomy ); |
|
160 | + public function taxonomy(string $taxonomy): self { |
|
161 | + $this->meta_type('term'); |
|
162 | + $this->object_subtype($taxonomy); |
|
163 | 163 | return $this; |
164 | 164 | } |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return self |
172 | 172 | */ |
173 | - public function description( string $description ): self { |
|
173 | + public function description(string $description): self { |
|
174 | 174 | $this->description = $description; |
175 | 175 | return $this; |
176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param boolean $single Meta value is single value or array |
182 | 182 | * @return self |
183 | 183 | */ |
184 | - public function single( bool $single = true ): self { |
|
184 | + public function single(bool $single = true): self { |
|
185 | 185 | $this->single = $single; |
186 | 186 | return $this; |
187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed $default_value |
193 | 193 | * @return self |
194 | 194 | */ |
195 | - public function default( $default_value ): self { |
|
195 | + public function default($default_value): self { |
|
196 | 196 | $this->default = $default_value; |
197 | 197 | return $this; |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param callable(mixed):mixed $callback |
204 | 204 | * @return self |
205 | 205 | */ |
206 | - public function sanitize( callable $callback ): self { |
|
206 | + public function sanitize(callable $callback): self { |
|
207 | 207 | $this->callbacks['sanitize'] = $callback; |
208 | 208 | return $this; |
209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param callable $callback |
215 | 215 | * @return self |
216 | 216 | */ |
217 | - public function permissions( callable $callback ): self { |
|
217 | + public function permissions(callable $callback): self { |
|
218 | 218 | $this->callbacks['permissions'] = $callback; |
219 | 219 | return $this; |
220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param boolean|array<mixed> $rest_schema|PinkCrab\WP_Rest_Schema\Argument\Argument Rest schema definitions |
226 | 226 | * @return self |
227 | 227 | */ |
228 | - public function rest_schema( $rest_schema ): self { |
|
228 | + public function rest_schema($rest_schema): self { |
|
229 | 229 | $this->rest_schema = $rest_schema; |
230 | 230 | return $this; |
231 | 231 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param callable|null $callback |
237 | 237 | * @return self |
238 | 238 | */ |
239 | - public function rest_view( ?callable $callback ): self { |
|
239 | + public function rest_view(?callable $callback): self { |
|
240 | 240 | $this->callbacks['rest_view'] = $callback; |
241 | 241 | return $this; |
242 | 242 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment):void $callback |
248 | 248 | * @return self |
249 | 249 | */ |
250 | - public function rest_update( ?callable $callback ): self { |
|
250 | + public function rest_update(?callable $callback): self { |
|
251 | 251 | $this->callbacks['rest_update'] = $callback; |
252 | 252 | return $this; |
253 | 253 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | ); |
270 | 270 | |
271 | 271 | // Set subtype. |
272 | - if ( $this->object_subtype !== null ) { |
|
272 | + if ($this->object_subtype !== null) { |
|
273 | 273 | $args['object_subtype'] = $this->object_subtype; |
274 | 274 | } |
275 | 275 | return $args; |
@@ -35,5 +35,5 @@ |
||
35 | 35 | * @param \PinkCrab\Registerables\Module\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 | } |
@@ -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\Module\Middleware\Registerable $object_instance |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - abstract public function validate( Registerable $object_instance ): bool; |
|
83 | + abstract public function validate(Registerable $object_instance): bool; |
|
84 | 84 | } |
@@ -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\Module\Middleware\Registerable $object_instance |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function validate( Registerable $object_instance ): bool { |
|
42 | + public function validate(Registerable $object_instance): bool { |
|
43 | 43 | // If this is not a valid taxonomy, just bail here. |
44 | - if ( ! is_a( $object_instance, Taxonomy::class ) ) { |
|
45 | - $this->add_error( sprintf( '%s is not a valid Taxonomy Model', get_class( $object_instance ) ) ); |
|
44 | + if ( ! is_a($object_instance, Taxonomy::class)) { |
|
45 | + $this->add_error(sprintf('%s is not a valid Taxonomy Model', get_class($object_instance))); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* @var Taxonomy $object_instance, already confirmed as a Taxonomy */ |
50 | 50 | |
51 | 51 | // Ensure all required fields are set. |
52 | - $this->has_required_fields( $object_instance ); |
|
52 | + $this->has_required_fields($object_instance); |
|
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 | } |