@@ -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 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param string $key |
109 | 109 | */ |
110 | - final public function __construct( string $key ) { |
|
110 | + final public function __construct(string $key) { |
|
111 | 111 | $this->key = $key; |
112 | 112 | } |
113 | 113 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param string $key |
118 | 118 | * @return self |
119 | 119 | */ |
120 | - public static function normal( string $key ): self { |
|
121 | - $meta_box = new static( $key ); |
|
120 | + public static function normal(string $key): self { |
|
121 | + $meta_box = new static($key); |
|
122 | 122 | $meta_box->context = 'normal'; |
123 | 123 | return $meta_box; |
124 | 124 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $key |
130 | 130 | * @return self |
131 | 131 | */ |
132 | - public static function side( string $key ): self { |
|
133 | - $meta_box = new static( $key ); |
|
132 | + public static function side(string $key): self { |
|
133 | + $meta_box = new static($key); |
|
134 | 134 | $meta_box->context = 'side'; |
135 | 135 | return $meta_box; |
136 | 136 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string $label |
142 | 142 | * @return self |
143 | 143 | */ |
144 | - public function label( string $label ): self { |
|
144 | + public function label(string $label): self { |
|
145 | 145 | $this->label = $label; |
146 | 146 | return $this; |
147 | 147 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string|array<mixed>|\WP_Screen $screen |
153 | 153 | * @return self |
154 | 154 | */ |
155 | - public function screen( $screen ): self { |
|
156 | - array_push( $this->screen, $screen ); |
|
155 | + public function screen($screen): self { |
|
156 | + array_push($this->screen, $screen); |
|
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param array<string, mixed> $view_vars |
164 | 164 | * @return self |
165 | 165 | */ |
166 | - public function view_vars( array $view_vars ): self { |
|
166 | + public function view_vars(array $view_vars): self { |
|
167 | 167 | $this->view_vars = $view_vars; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param string $view_template |
176 | 176 | * @return self |
177 | 177 | */ |
178 | - public function view_template( string $view_template ): self { |
|
178 | + public function view_template(string $view_template): self { |
|
179 | 179 | $this->view_template = $view_template; |
180 | 180 | return $this; |
181 | 181 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param callable $callable |
188 | 188 | * @return self |
189 | 189 | */ |
190 | - public function view( $callable ): self { |
|
190 | + public function view($callable): self { |
|
191 | 191 | $this->view = $callable; |
192 | 192 | return $this; |
193 | 193 | } |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param int $params |
202 | 202 | * @return self |
203 | 203 | */ |
204 | - public function add_action( string $hook, callable $callable, int $priority = 10, int $params = 1 ): self { |
|
205 | - $this->actions[ $hook ] = |
|
204 | + public function add_action(string $hook, callable $callable, int $priority = 10, int $params = 1): self { |
|
205 | + $this->actions[$hook] = |
|
206 | 206 | array( |
207 | 207 | 'callback' => $callable, |
208 | 208 | 'priority' => $priority, |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param callable(\WP_Post $post,array<string, mixed> $args):array<string, mixed> $view_data_filter |
219 | 219 | * @return self |
220 | 220 | */ |
221 | - public function view_data_filter( callable $view_data_filter ): self { |
|
221 | + public function view_data_filter(callable $view_data_filter): self { |
|
222 | 222 | $this->view_data_filter = $view_data_filter; |
223 | 223 | return $this; |
224 | 224 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | * @return Meta_Data[] |
46 | 46 | * @codeCoverageIgnore |
47 | 47 | */ |
48 | - public function meta_data( array $meta_data ): array { |
|
48 | + public function meta_data(array $meta_data): array { |
|
49 | 49 | return $meta_data; |
50 | 50 | } |
51 | 51 |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @return Registrar |
55 | 55 | * @throws Exception If not valid registerable type passed. |
56 | 56 | */ |
57 | - public function create_from_registerable( Registerable $registerable ): Registrar { |
|
58 | - switch ( true ) { |
|
59 | - case is_a( $registerable, Post_Type::class ): |
|
60 | - return new Post_Type_Registrar( new Post_Type_Validator(), new Meta_Data_Registrar() ); |
|
57 | + public function create_from_registerable(Registerable $registerable): Registrar { |
|
58 | + switch (true) { |
|
59 | + case is_a($registerable, Post_Type::class): |
|
60 | + return new Post_Type_Registrar(new Post_Type_Validator(), new Meta_Data_Registrar()); |
|
61 | 61 | |
62 | - case is_a( $registerable, Taxonomy::class ): |
|
63 | - return new Taxonomy_Registrar( new Taxonomy_Validator(), new Meta_Data_Registrar() ); |
|
62 | + case is_a($registerable, Taxonomy::class): |
|
63 | + return new Taxonomy_Registrar(new Taxonomy_Validator(), new Meta_Data_Registrar()); |
|
64 | 64 | |
65 | 65 | default: |
66 | - $type = get_class( $registerable ); |
|
67 | - throw new Exception( 'Invalid registerable (' . $type . ')type (no dispatcher exists)' ); |
|
66 | + $type = get_class($registerable); |
|
67 | + throw new Exception('Invalid registerable (' . $type . ')type (no dispatcher exists)'); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param \PinkCrab\Loader\Hook_Loader $loader |
76 | 76 | * @return Meta_Box_Registrar |
77 | 77 | */ |
78 | - public function meta_box_registrar( DI_Container $container, Hook_Loader $loader ): Meta_Box_Registrar { |
|
79 | - return new Meta_Box_Registrar( new Meta_Box_Validator(), $container, $loader ); |
|
78 | + public function meta_box_registrar(DI_Container $container, Hook_Loader $loader): Meta_Box_Registrar { |
|
79 | + return new Meta_Box_Registrar(new Meta_Box_Validator(), $container, $loader); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -64,30 +64,30 @@ discard block |
||
64 | 64 | * @param Meta_Box $meta_box |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - public function register( Meta_Box $meta_box ): void { |
|
67 | + public function register(Meta_Box $meta_box): void { |
|
68 | 68 | |
69 | - if ( ! $this->validator->verify_meta_box( $meta_box ) ) { |
|
69 | + if ( ! $this->validator->verify_meta_box($meta_box)) { |
|
70 | 70 | throw new Exception( |
71 | 71 | sprintf( |
72 | 72 | 'Failed validating meta box model(%s) with errors: %s', |
73 | - get_class( $meta_box ), |
|
74 | - join( ', ', $this->validator->get_errors() ) |
|
73 | + get_class($meta_box), |
|
74 | + join(', ', $this->validator->get_errors()) |
|
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Set the view using View, if not traditional callback supplied and a defined template. |
80 | - if ( ! \is_callable( $meta_box->view ) && is_string( $meta_box->view_template ) ) { |
|
81 | - $meta_box = $this->set_view_callback_from_renderable( $meta_box ); |
|
80 | + if ( ! \is_callable($meta_box->view) && is_string($meta_box->view_template)) { |
|
81 | + $meta_box = $this->set_view_callback_from_renderable($meta_box); |
|
82 | 82 | } |
83 | - if ( \is_callable( $meta_box->view ) ) { |
|
84 | - $meta_box = $this->set_view_callback_from_callable( $meta_box ); |
|
83 | + if (\is_callable($meta_box->view)) { |
|
84 | + $meta_box = $this->set_view_callback_from_callable($meta_box); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Add meta_box to loader. |
88 | 88 | $this->loader->action( |
89 | 89 | 'add_meta_boxes', |
90 | - function() use ( $meta_box ) : void { |
|
90 | + function() use ($meta_box) : void { |
|
91 | 91 | \add_meta_box( |
92 | 92 | $meta_box->key, |
93 | 93 | $meta_box->label, |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | // Deffer adding meta box hooks until we can asses the current screen. |
104 | 104 | $this->loader->action( |
105 | 105 | 'current_screen', |
106 | - function() use ( $meta_box ) { |
|
106 | + function() use ($meta_box) { |
|
107 | 107 | // If we have any hook calls, add them to the loader. |
108 | - if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) { |
|
109 | - foreach ( $meta_box->actions as $handle => $hook ) { |
|
110 | - add_action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] ); |
|
108 | + if ($this->is_active($meta_box) && ! empty($meta_box->actions)) { |
|
109 | + foreach ($meta_box->actions as $handle => $hook) { |
|
110 | + add_action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
122 | 122 | * @return \PinkCrab\Registerables\Meta_Box |
123 | 123 | */ |
124 | - protected function set_view_callback_from_callable( Meta_Box $meta_box ): Meta_Box { |
|
124 | + protected function set_view_callback_from_callable(Meta_Box $meta_box): Meta_Box { |
|
125 | 125 | |
126 | 126 | // Get the current view callback. |
127 | 127 | $current_callback = $meta_box->view; |
128 | 128 | |
129 | 129 | $meta_box->view( |
130 | - function ( \WP_Post $post, array $args ) use ( $meta_box, $current_callback ) { |
|
130 | + function(\WP_Post $post, array $args) use ($meta_box, $current_callback) { |
|
131 | 131 | |
132 | 132 | // Set the view args |
133 | 133 | $args['args']['post'] = $post; |
134 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); |
|
134 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); |
|
135 | 135 | |
136 | 136 | // Render the callback. |
137 | - if ( \is_callable( $current_callback ) ) { |
|
138 | - call_user_func( $current_callback, $post, $args ); |
|
137 | + if (\is_callable($current_callback)) { |
|
138 | + call_user_func($current_callback, $post, $args); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | ); |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
150 | 150 | * @return \PinkCrab\Registerables\Meta_Box |
151 | 151 | */ |
152 | - protected function set_view_callback_from_renderable( Meta_Box $meta_box ): Meta_Box { |
|
152 | + protected function set_view_callback_from_renderable(Meta_Box $meta_box): Meta_Box { |
|
153 | 153 | |
154 | 154 | // Create View(View) |
155 | - $view = $this->container->create( View::class ); |
|
156 | - if ( is_null( $view ) || ! is_a( $view, View::class ) ) { |
|
157 | - throw new Exception( 'View not defined' ); |
|
155 | + $view = $this->container->create(View::class); |
|
156 | + if (is_null($view) || ! is_a($view, View::class)) { |
|
157 | + throw new Exception('View not defined'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $meta_box->view( |
161 | - function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) { |
|
161 | + function(\WP_Post $post, array $args) use ($meta_box, $view) { |
|
162 | 162 | |
163 | 163 | $args['args']['post'] = $post; |
164 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); |
|
164 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); |
|
165 | 165 | |
166 | 166 | // @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this) |
167 | - $view->render( $meta_box->view_template, $args['args'] ); |
|
167 | + $view->render($meta_box->view_template, $args['args']); |
|
168 | 168 | } |
169 | 169 | ); |
170 | 170 | |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return boolean |
178 | 178 | */ |
179 | - protected function is_active( Meta_Box $meta_box ): bool { |
|
179 | + protected function is_active(Meta_Box $meta_box): bool { |
|
180 | 180 | global $current_screen; |
181 | 181 | |
182 | - return ! is_null( $current_screen ) |
|
183 | - && ! empty( $current_screen->post_type ) |
|
184 | - && in_array( $current_screen->post_type, $meta_box->screen, true ); |
|
182 | + return ! is_null($current_screen) |
|
183 | + && ! empty($current_screen->post_type) |
|
184 | + && in_array($current_screen->post_type, $meta_box->screen, true); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param array<string, mixed> $view_args |
193 | 193 | * @return array<string, mixed> |
194 | 194 | */ |
195 | - public function filter_view_args( Meta_Box $meta_box, \WP_Post $post, array $view_args ): array { |
|
196 | - if ( is_callable( $meta_box->view_data_filter ) ) { |
|
197 | - $view_args = ( $meta_box->view_data_filter )( $post, $view_args ); |
|
195 | + public function filter_view_args(Meta_Box $meta_box, \WP_Post $post, array $view_args): array { |
|
196 | + if (is_callable($meta_box->view_data_filter)) { |
|
197 | + $view_args = ($meta_box->view_data_filter)($post, $view_args); |
|
198 | 198 | } |
199 | 199 | return $view_args; |
200 | 200 | } |
@@ -107,11 +107,11 @@ |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | - * Registers a Meta Data object as defined REST field. |
|
111 | - * |
|
112 | - * @param \PinkCrab\Registerables\Meta_Data $meta |
|
113 | - * @return void |
|
114 | - */ |
|
110 | + * Registers a Meta Data object as defined REST field. |
|
111 | + * |
|
112 | + * @param \PinkCrab\Registerables\Meta_Data $meta |
|
113 | + * @return void |
|
114 | + */ |
|
115 | 115 | public function register_meta_rest_field( Meta_Data $meta ) { |
116 | 116 | // Skip if not sub type defined for post or term. |
117 | 117 | if ( null === $meta->get_subtype() ) { |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @return bool |
38 | 38 | * @throws \Exception if fails to register meta data. |
39 | 39 | */ |
40 | - public function register_for_post_type( Meta_Data $meta, string $post_type ):bool { |
|
41 | - return $this->register_meta( $meta, 'post', $post_type ); |
|
40 | + public function register_for_post_type(Meta_Data $meta, string $post_type):bool { |
|
41 | + return $this->register_meta($meta, 'post', $post_type); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @return bool |
50 | 50 | * @throws \Exception if fails to register meta data. |
51 | 51 | */ |
52 | - public function register_for_term( Meta_Data $meta, string $taxonomy ):bool { |
|
53 | - return $this->register_meta( $meta, 'term', $taxonomy ); |
|
52 | + public function register_for_term(Meta_Data $meta, string $taxonomy):bool { |
|
53 | + return $this->register_meta($meta, 'term', $taxonomy); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | * @throws \Exception if fails to register meta data. |
62 | 62 | */ |
63 | - public function register_for_user( Meta_Data $meta ): bool { |
|
64 | - return $this->register_meta( $meta, 'user', '' ); |
|
63 | + public function register_for_user(Meta_Data $meta): bool { |
|
64 | + return $this->register_meta($meta, 'user', ''); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @return bool |
72 | 72 | * @throws \Exception if fails to register meta data. |
73 | 73 | */ |
74 | - public function register_for_comment( Meta_Data $meta ): bool { |
|
75 | - return $this->register_meta( $meta, 'comment', '' ); |
|
74 | + public function register_for_comment(Meta_Data $meta): bool { |
|
75 | + return $this->register_meta($meta, 'comment', ''); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -86,25 +86,25 @@ discard block |
||
86 | 86 | * @return bool |
87 | 87 | * @throws \Exception if fails to register meta data. |
88 | 88 | */ |
89 | - protected function register_meta( Meta_Data $meta, string $meta_type, string $sub_type ): bool { |
|
89 | + protected function register_meta(Meta_Data $meta, string $meta_type, string $sub_type): bool { |
|
90 | 90 | // Clone and set the post type, while enforcing it as a post meta. |
91 | 91 | $meta = clone $meta; |
92 | - $meta->object_subtype( $sub_type ); |
|
93 | - $meta->meta_type( $meta_type ); |
|
92 | + $meta->object_subtype($sub_type); |
|
93 | + $meta->meta_type($meta_type); |
|
94 | 94 | |
95 | 95 | // Normalise rest schema model to array. |
96 | - $meta = $this->normalise_rest_schema( $meta ); |
|
96 | + $meta = $this->normalise_rest_schema($meta); |
|
97 | 97 | |
98 | - $result = register_meta( $meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args() ); |
|
99 | - if ( ! $result ) { |
|
98 | + $result = register_meta($meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args()); |
|
99 | + if ( ! $result) { |
|
100 | 100 | throw new \Exception( |
101 | 101 | "Failed to register {$meta->get_meta_key()} (meta) for {$sub_type} of {$meta_type} type" |
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Maybe register rest fields. |
106 | - if ( false !== $meta->get_rest_schema() ) { |
|
107 | - $this->register_meta_rest_field( $meta ); |
|
106 | + if (false !== $meta->get_rest_schema()) { |
|
107 | + $this->register_meta_rest_field($meta); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | return $result; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @param \PinkCrab\Registerables\Meta_Data $meta |
120 | 120 | * @return \PinkCrab\Registerables\Meta_Data |
121 | 121 | */ |
122 | - protected function normalise_rest_schema( Meta_Data $meta ): Meta_Data { |
|
123 | - if ( \class_exists( 'PinkCrab\WP_Rest_Schema\Argument\Argument' ) |
|
122 | + protected function normalise_rest_schema(Meta_Data $meta): Meta_Data { |
|
123 | + if (\class_exists('PinkCrab\WP_Rest_Schema\Argument\Argument') |
|
124 | 124 | && $meta->get_rest_schema() instanceof \PinkCrab\WP_Rest_Schema\Argument\Argument |
125 | 125 | ) { |
126 | - $meta->rest_schema( \PinkCrab\WP_Rest_Schema\Parser\Argument_Parser::for_meta_data( $meta->get_rest_schema() ) ); |
|
126 | + $meta->rest_schema(\PinkCrab\WP_Rest_Schema\Parser\Argument_Parser::for_meta_data($meta->get_rest_schema())); |
|
127 | 127 | } |
128 | 128 | return $meta; |
129 | 129 | } |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * @param \PinkCrab\Registerables\Meta_Data $meta |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - public function register_meta_rest_field( Meta_Data $meta ) { |
|
137 | + public function register_meta_rest_field(Meta_Data $meta) { |
|
138 | 138 | // Skip if not sub type defined for post or term. |
139 | - if ( null === $meta->get_subtype() ) { |
|
139 | + if (null === $meta->get_subtype()) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | 143 | add_action( |
144 | 144 | 'rest_api_init', |
145 | - function () use ( $meta ) { |
|
145 | + function() use ($meta) { |
|
146 | 146 | register_rest_field( |
147 | 147 | $meta->get_subtype(), |
148 | 148 | $meta->get_meta_key(), |
149 | 149 | array( // @phpstan-ignore-line WP Docblock doesn't give enough details of callable param types, so throws false positive |
150 | - 'get_callback' => $meta->get_rest_view() ?? $this->create_rest_get_method( $meta ), |
|
150 | + 'get_callback' => $meta->get_rest_view() ?? $this->create_rest_get_method($meta), |
|
151 | 151 | 'schema' => $meta->get_rest_schema(), |
152 | - 'update_callback' => $meta->get_rest_update() ?? $this->create_rest_update_method( $meta ), |
|
152 | + 'update_callback' => $meta->get_rest_update() ?? $this->create_rest_update_method($meta), |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | } |
@@ -162,23 +162,23 @@ discard block |
||
162 | 162 | * @param \PinkCrab\Registerables\Meta_Data $meta |
163 | 163 | * @return callable(array<mixed>):void |
164 | 164 | */ |
165 | - protected function create_rest_get_method( Meta_Data $meta ): callable { |
|
166 | - return function( $model ) use ( $meta ) { |
|
167 | - switch ( $meta->get_meta_type() ) { |
|
165 | + protected function create_rest_get_method(Meta_Data $meta): callable { |
|
166 | + return function($model) use ($meta) { |
|
167 | + switch ($meta->get_meta_type()) { |
|
168 | 168 | case 'post': |
169 | - $value = get_post_meta( $model['id'], $meta->get_meta_key(), true ); |
|
169 | + $value = get_post_meta($model['id'], $meta->get_meta_key(), true); |
|
170 | 170 | break; |
171 | 171 | |
172 | 172 | case 'term': |
173 | - $value = get_term_meta( $model['id'], $meta->get_meta_key(), true ); |
|
173 | + $value = get_term_meta($model['id'], $meta->get_meta_key(), true); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case 'user': |
177 | - $value = get_user_meta( $model['id'], $meta->get_meta_key(), true ); |
|
177 | + $value = get_user_meta($model['id'], $meta->get_meta_key(), true); |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case 'comment': |
181 | - $value = get_comment_meta( $model['id'], $meta->get_meta_key(), true ); |
|
181 | + $value = get_comment_meta($model['id'], $meta->get_meta_key(), true); |
|
182 | 182 | break; |
183 | 183 | |
184 | 184 | default: |
@@ -196,31 +196,31 @@ discard block |
||
196 | 196 | * @param Meta_Data $meta |
197 | 197 | * @return \Closure(mixed, \WP_Post|\WP_Term|\WP_User|\WP_Comment): mixed |
198 | 198 | */ |
199 | - protected function create_rest_update_method( Meta_Data $meta ): \Closure { |
|
199 | + protected function create_rest_update_method(Meta_Data $meta): \Closure { |
|
200 | 200 | /** |
201 | 201 | * @param mixed $value |
202 | 202 | * @param \WP_Post|\WP_Term|\WP_User|\WP_Comment $object |
203 | 203 | */ |
204 | - return function( $value, $object ) use ( $meta ) { |
|
205 | - switch ( $meta->get_meta_type() ) { |
|
204 | + return function($value, $object) use ($meta) { |
|
205 | + switch ($meta->get_meta_type()) { |
|
206 | 206 | case 'post': |
207 | 207 | /** @var \WP_Post $object */ |
208 | - update_post_meta( $object->ID, $meta->get_meta_key(), $value ); |
|
208 | + update_post_meta($object->ID, $meta->get_meta_key(), $value); |
|
209 | 209 | break; |
210 | 210 | |
211 | 211 | case 'term': |
212 | 212 | /** @var \WP_Term $object */ |
213 | - update_term_meta( $object->term_id, $meta->get_meta_key(), $value ); |
|
213 | + update_term_meta($object->term_id, $meta->get_meta_key(), $value); |
|
214 | 214 | break; |
215 | 215 | |
216 | 216 | case 'user': |
217 | 217 | /** @var \WP_User $object */ |
218 | - update_user_meta( $object->ID, $meta->get_meta_key(), $value ); |
|
218 | + update_user_meta($object->ID, $meta->get_meta_key(), $value); |
|
219 | 219 | break; |
220 | 220 | |
221 | 221 | case 'comment': |
222 | 222 | /** @var \WP_Comment $object */ |
223 | - update_comment_meta( (int) $object->comment_ID, $meta->get_meta_key(), $value ); |
|
223 | + update_comment_meta((int) $object->comment_ID, $meta->get_meta_key(), $value); |
|
224 | 224 | break; |
225 | 225 | |
226 | 226 | default: |
@@ -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 {} |