Passed
Push — master ( 24b191...649fed )
by Glynn
07:28 queued 04:26
created
src/Registrar/Taxonomy_Registrar.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected $validator;
42 42
 
43
-	public function __construct( Taxonomy_Validator $validator ) {
43
+	public function __construct(Taxonomy_Validator $validator) {
44 44
 		$this->validator = $validator;
45 45
 	}
46 46
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
51 51
 	 * @return void
52 52
 	 */
53
-	public function register( Registerable $registerable ): void {
53
+	public function register(Registerable $registerable): void {
54 54
 		/** @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables */
55 55
 
56
-		if ( ! $this->validator->validate( $registerable ) ) {
56
+		if ( ! $this->validator->validate($registerable)) {
57 57
 			throw new Exception(
58 58
 				sprintf(
59 59
 					'Failed validating taxonomy model(%s) with errors: %s',
60
-					get_class( $registerable ),
61
-					join( ', ', $this->validator->get_errors() )
60
+					get_class($registerable),
61
+					join(', ', $this->validator->get_errors())
62 62
 				)
63 63
 			);
64 64
 		}
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 			$result = \register_taxonomy(
69 69
 				$registerable->slug,
70 70
 				$registerable->object_type,
71
-				$this->compile_args( $registerable )
71
+				$this->compile_args($registerable)
72 72
 			);
73 73
 
74
-			if ( is_a( $result, \WP_Error::class ) ) {
75
-				throw new Exception( join( $result->get_error_messages() ) );
74
+			if (is_a($result, \WP_Error::class)) {
75
+				throw new Exception(join($result->get_error_messages()));
76 76
 			}
77
-		} catch ( \Throwable $th ) {
78
-			throw new Exception( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" );
77
+		} catch (\Throwable $th) {
78
+			throw new Exception("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})");
79 79
 		}
80 80
 
81 81
 		// Register any associated meta data.
82
-		$this->register_meta_data( $registerable );
82
+		$this->register_meta_data($registerable);
83 83
 
84 84
 	}
85 85
 
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
90 90
 	 * @return void
91 91
 	 */
92
-	protected function register_meta_data( Taxonomy $taxonomy ): void {
92
+	protected function register_meta_data(Taxonomy $taxonomy): void {
93 93
 
94 94
 		// Get all meta fields for taxonomy.
95
-		$meta_fields = $taxonomy->meta_data( array() );
95
+		$meta_fields = $taxonomy->meta_data(array());
96 96
 
97 97
 		// Attempt to register all Meta for taxonomy.
98 98
 		try {
99
-			foreach ( $meta_fields as $meta_field ) {
99
+			foreach ($meta_fields as $meta_field) {
100 100
 				// Set object data for this taxonomy.
101
-				$meta_field->object_subtype( $taxonomy->slug );
102
-				$meta_field->meta_type( 'term' );
101
+				$meta_field->object_subtype($taxonomy->slug);
102
+				$meta_field->meta_type('term');
103 103
 
104
-				$result = register_meta( $meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args() );
105
-				if ( ! $result ) {
106
-					throw new Exception( "Failed to register {$meta_field->get_meta_key()} (meta) for {$taxonomy->singular} taxonomy" );
104
+				$result = register_meta($meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args());
105
+				if ( ! $result) {
106
+					throw new Exception("Failed to register {$meta_field->get_meta_key()} (meta) for {$taxonomy->singular} taxonomy");
107 107
 				}
108 108
 			}
109
-		} catch ( \Throwable $th ) {
110
-			throw new Exception( $th->getMessage() );
109
+		} catch (\Throwable $th) {
110
+			throw new Exception($th->getMessage());
111 111
 		}
112 112
 	}
113 113
 
@@ -117,59 +117,59 @@  discard block
 block discarded – undo
117 117
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
118 118
 	 * @return array<string, string|int|array<string, string>>
119 119
 	 */
120
-	protected function compile_args( Taxonomy $taxonomy ): array {
120
+	protected function compile_args(Taxonomy $taxonomy): array {
121 121
 		// Create the labels.
122 122
 		$base_labels = array(
123 123
 			'name'                  => $taxonomy->plural,
124 124
 			'singular_name'         => $taxonomy->singular,
125
-			'menu_name'             => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ),
125
+			'menu_name'             => \ucfirst(\esc_attr($taxonomy->plural ?? '')),
126 126
 			/* translators: %s: Taxonomy plural name */
127
-			'search_items'          => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
127
+			'search_items'          => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
128 128
 			/* translators: %s: Taxonomy plural name */
129
-			'popular_items'         => wp_sprintf( _x( 'Popular %s', '**', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
129
+			'popular_items'         => wp_sprintf(_x('Popular %s', '**', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
130 130
 			/* translators: %s: Taxonomy singular name */
131
-			'edit_item'             => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
131
+			'edit_item'             => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
132 132
 			/* translators: %s: Taxonomy singular name */
133
-			'view_item'             => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
133
+			'view_item'             => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
134 134
 			/* translators: %s: Taxonomy singular name */
135
-			'update_item'           => wp_sprintf( _x( 'Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
135
+			'update_item'           => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
136 136
 			/* translators: %s: Taxonomy singular name */
137
-			'add_new_item'          => wp_sprintf( _x( 'Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
137
+			'add_new_item'          => wp_sprintf(_x('Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
138 138
 			/* translators: %s: Taxonomy singular name */
139
-			'new_item_name'         => wp_sprintf( _x( 'New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
139
+			'new_item_name'         => wp_sprintf(_x('New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
140 140
 			/* translators: %s: Taxonomy plural name */
141
-			'not_found'             => wp_sprintf( _x( 'No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
141
+			'not_found'             => wp_sprintf(_x('No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
142 142
 			/* translators: %s: Taxonomy plural name */
143
-			'items_list'            => wp_sprintf( _x( '%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
143
+			'items_list'            => wp_sprintf(_x('%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
144 144
 			/* translators: %s: Taxonomy plural name */
145
-			'items_list_navigation' => wp_sprintf( _x( '%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
145
+			'items_list_navigation' => wp_sprintf(_x('%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
146 146
 			/* translators: %s: Taxonomy plural name */
147
-			'all_items'             => wp_sprintf( _x( 'All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
148
-			'most_used'             => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ),
147
+			'all_items'             => wp_sprintf(_x('All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
148
+			'most_used'             => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'),
149 149
 			/* translators: %s: Taxonomy plural name */
150
-			'back_to_items'         => wp_sprintf( _x( '← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
150
+			'back_to_items'         => wp_sprintf(_x('← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
151 151
 			/* translators: %s: Taxonomy singular name */
152
-			'item_link'             => wp_sprintf( _x( '%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->singular ?? '' ) ) ),
152
+			'item_link'             => wp_sprintf(_x('%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->singular ?? ''))),
153 153
 			/* translators: %s: Taxonomy singular name */
154
-			'item_link_description' => wp_sprintf( _x( 'A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
154
+			'item_link_description' => wp_sprintf(_x('A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
155 155
 		);
156 156
 
157 157
 		$tag_labels = array(
158 158
 			/* translators: %s: Taxonomy plural name */
159
-			'separate_items_with_commas' => wp_sprintf( _x( 'Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
159
+			'separate_items_with_commas' => wp_sprintf(_x('Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
160 160
 			/* translators: %s: Taxonomy plural name */
161
-			'add_or_remove_items'        => wp_sprintf( _x( 'Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
161
+			'add_or_remove_items'        => wp_sprintf(_x('Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
162 162
 			/* translators: %s: Taxonomy plural name */
163
-			'choose_from_most_used'      => wp_sprintf( _x( 'Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
163
+			'choose_from_most_used'      => wp_sprintf(_x('Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
164 164
 		);
165 165
 
166 166
 		$hierarchical_labels = array(
167 167
 			/* translators: %s: Taxonomy singular name */
168
-			'parent_item_colon' => wp_sprintf( _x( 'Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
168
+			'parent_item_colon' => wp_sprintf(_x('Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
169 169
 			/* translators: %s: Taxonomy singular name */
170
-			'parent_item'       => wp_sprintf( _x( 'Parent %s', '**', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
170
+			'parent_item'       => wp_sprintf(_x('Parent %s', '**', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
171 171
 			/* translators: %s: Taxonomy singular name */
172
-			'filter_by_item'    => wp_sprintf( _x( 'Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
172
+			'filter_by_item'    => wp_sprintf(_x('Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
173 173
 		);
174 174
 
175 175
 		$labels = array_merge(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		 * @param Taxonomy $taxonomy
186 186
 		 * @return array<string, string>
187 187
 		 */
188
-		$labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy );
188
+		$labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy);
189 189
 
190 190
 		// Compose args.
191 191
 		$args = array(
@@ -225,6 +225,6 @@  discard block
 block discarded – undo
225 225
 		 * @param Taxonomy $taxonomy
226 226
 		 * @return array<string, string|bool|int|null|array<string, string>
227 227
 		 */
228
-		return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy );
228
+		return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy);
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
src/Meta_Box.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
src/Registrar/Meta_Box_Registrar.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -64,30 +64,30 @@  discard block
 block discarded – undo
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,
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 			}
101 101
 		);
102 102
 		// If we have any hook calls, add them to the loader.
103
-		if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) {
104
-			foreach ( $meta_box->actions as $handle => $hook ) {
105
-				$this->loader->action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] );
103
+		if ($this->is_active($meta_box) && ! empty($meta_box->actions)) {
104
+			foreach ($meta_box->actions as $handle => $hook) {
105
+				$this->loader->action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']);
106 106
 			}
107 107
 		}
108 108
 
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 	 * @param \PinkCrab\Registerables\Meta_Box $meta_box
115 115
 	 * @return \PinkCrab\Registerables\Meta_Box
116 116
 	 */
117
-	protected function set_view_callback_from_callable( Meta_Box $meta_box ): Meta_Box {
117
+	protected function set_view_callback_from_callable(Meta_Box $meta_box): Meta_Box {
118 118
 
119 119
 		// Get the current view callback.
120 120
 		$current_callback = $meta_box->view;
121 121
 
122 122
 		$meta_box->view(
123
-			function ( \WP_Post $post, array $args ) use ( $meta_box, $current_callback ) {
123
+			function(\WP_Post $post, array $args) use ($meta_box, $current_callback) {
124 124
 
125 125
 				// Set the view args
126 126
 				$args['args']['post'] = $post;
127
-				$args['args']         = $this->filter_view_args( $meta_box, $post, $args['args'] );
127
+				$args['args']         = $this->filter_view_args($meta_box, $post, $args['args']);
128 128
 
129 129
 				// Render the callback.
130
-				if ( \is_callable( $current_callback ) ) {
131
-					call_user_func( $current_callback, $post, $args );
130
+				if (\is_callable($current_callback)) {
131
+					call_user_func($current_callback, $post, $args);
132 132
 				}
133 133
 			}
134 134
 		);
@@ -142,22 +142,22 @@  discard block
 block discarded – undo
142 142
 	 * @param \PinkCrab\Registerables\Meta_Box $meta_box
143 143
 	 * @return \PinkCrab\Registerables\Meta_Box
144 144
 	 */
145
-	protected function set_view_callback_from_renderable( Meta_Box $meta_box ): Meta_Box {
145
+	protected function set_view_callback_from_renderable(Meta_Box $meta_box): Meta_Box {
146 146
 
147 147
 		// Create View(View)
148
-		$view = $this->container->create( View::class );
149
-		if ( is_null( $view ) || ! is_a( $view, View::class ) ) {
150
-			throw new Exception( 'View not defined' );
148
+		$view = $this->container->create(View::class);
149
+		if (is_null($view) || ! is_a($view, View::class)) {
150
+			throw new Exception('View not defined');
151 151
 		}
152 152
 
153 153
 		$meta_box->view(
154
-			function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) {
154
+			function(\WP_Post $post, array $args) use ($meta_box, $view) {
155 155
 
156 156
 				$args['args']['post'] = $post;
157
-				$args['args']         = $this->filter_view_args( $meta_box, $post, $args['args'] );
157
+				$args['args']         = $this->filter_view_args($meta_box, $post, $args['args']);
158 158
 
159 159
 				// @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this)
160
-				$view->render( $meta_box->view_template, $args['args'] );
160
+				$view->render($meta_box->view_template, $args['args']);
161 161
 			}
162 162
 		);
163 163
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return boolean
171 171
 	 */
172
-	protected function is_active( Meta_Box $meta_box ): bool {
172
+	protected function is_active(Meta_Box $meta_box): bool {
173 173
 		global $current_screen;
174 174
 
175
-		return ! is_null( $current_screen )
176
-		&& ! empty( $current_screen->post_type )
177
-		&& in_array( $current_screen->post_type, $meta_box->screen, true );
175
+		return ! is_null($current_screen)
176
+		&& ! empty($current_screen->post_type)
177
+		&& in_array($current_screen->post_type, $meta_box->screen, true);
178 178
 	}
179 179
 
180 180
 	/**
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 	 * @param array<string, mixed> $view_args
186 186
 	 * @return array<string, mixed>
187 187
 	 */
188
-	public function filter_view_args( Meta_Box $meta_box, \WP_Post $post, array $view_args ): array {
189
-		if ( is_callable( $meta_box->view_data_filter ) ) {
190
-			$view_args = ( $meta_box->view_data_filter )( $post, $view_args );
188
+	public function filter_view_args(Meta_Box $meta_box, \WP_Post $post, array $view_args): array {
189
+		if (is_callable($meta_box->view_data_filter)) {
190
+			$view_args = ($meta_box->view_data_filter)($post, $view_args);
191 191
 		}
192 192
 		return $view_args;
193 193
 	}
Please login to merge, or discard this patch.
src/Shared_Meta_Box_Controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 	 * @param Meta_Data[] $meta_data
45 45
 	 * @return Meta_Data[]
46 46
 	 */
47
-	public function meta_data( array $meta_data ): array {
47
+	public function meta_data(array $meta_data): array {
48 48
 		return $meta_data;
49 49
 	}
50 50
 
Please login to merge, or discard this patch.
src/Registration_Middleware/Registerable_Middleware.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param \PinkCrab\Loader\Hook_Loader $loader
51 51
 	 * @return void
52 52
 	 */
53
-	public function set_hook_loader( Hook_Loader $loader ) {
53
+	public function set_hook_loader(Hook_Loader $loader) {
54 54
 		$this->loader = $loader;
55 55
 	}
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param \PinkCrab\Perique\Interfaces\DI_Container $container
61 61
 	 * @return void
62 62
 	 */
63
-	public function set_di_container( DI_Container $container ): void {
63
+	public function set_di_container(DI_Container $container): void {
64 64
 		$this->container = $container;
65 65
 	}
66 66
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 * @param object|Registerable $class
71 71
 	 * @return object
72 72
 	 */
73
-	public function process( $class ) {
74
-		if ( ! is_a( $class, Registerable::class ) ) {
73
+	public function process($class) {
74
+		if ( ! is_a($class, Registerable::class)) {
75 75
 			return $class;
76 76
 		}
77 77
 
78 78
 		// Based on the registerable type.
79
-		switch ( true ) {
80
-			case is_a( $class, Post_Type::class ):
81
-				$this->process_post_type( $class );
79
+		switch (true) {
80
+			case is_a($class, Post_Type::class):
81
+				$this->process_post_type($class);
82 82
 				break;
83 83
 
84
-			case is_a( $class, Taxonomy::class ):
85
-				$this->process_taxonomy( $class );
84
+			case is_a($class, Taxonomy::class):
85
+				$this->process_taxonomy($class);
86 86
 				break;
87 87
 
88
-			case is_a( $class, Shared_Meta_Box_Controller::class ):
89
-				$this->process_shared_meta_box( $class );
88
+			case is_a($class, Shared_Meta_Box_Controller::class):
89
+				$this->process_shared_meta_box($class);
90 90
 				break;
91 91
 
92 92
 			default:
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 * @since 0.7.0
106 106
 	 */
107
-	protected function process_taxonomy( Taxonomy $taxonomy ): void {
107
+	protected function process_taxonomy(Taxonomy $taxonomy): void {
108 108
 		$this->loader->action(
109 109
 			'init',
110
-			static function() use ( $taxonomy ) {
110
+			static function() use ($taxonomy) {
111 111
 				Registrar_Factory::new()
112
-					->create_from_registerable( $taxonomy )
113
-					->register( $taxonomy );
112
+					->create_from_registerable($taxonomy)
113
+					->register($taxonomy);
114 114
 			}
115 115
 		);
116 116
 	}
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 	 * @return void
123 123
 	 * @since 0.7.0
124 124
 	 */
125
-	protected function process_post_type( Post_Type $post_type_registerable ) {
125
+	protected function process_post_type(Post_Type $post_type_registerable) {
126 126
 		// Register registerable.
127 127
 		$this->loader->action(
128 128
 			'init',
129
-			static function() use ( $post_type_registerable ) {
129
+			static function() use ($post_type_registerable) {
130 130
 				Registrar_Factory::new()
131
-					->create_from_registerable( $post_type_registerable )
132
-					->register( $post_type_registerable );
131
+					->create_from_registerable($post_type_registerable)
132
+					->register($post_type_registerable);
133 133
 			}
134 134
 		);
135 135
 
136 136
 		// Define use of gutenberg
137 137
 		$this->loader->filter(
138 138
 			'use_block_editor_for_post_type',
139
-			static function( bool $state, string $post_type ) use ( $post_type_registerable ): bool {
139
+			static function(bool $state, string $post_type) use ($post_type_registerable): bool {
140 140
 					return $post_type === $post_type_registerable->key
141 141
 						? (bool) $post_type_registerable->gutenberg
142 142
 						: $state;
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		// Register meta boxes.
149
-		$meta_boxes = $post_type_registerable->meta_boxes( array() );
149
+		$meta_boxes = $post_type_registerable->meta_boxes(array());
150 150
 
151
-		if ( ! empty( $meta_boxes ) ) {
151
+		if ( ! empty($meta_boxes)) {
152 152
 			// Create the registrar
153 153
 			$meta_box_registrar = $this->get_meta_box_registrar();
154 154
 
155 155
 			// Register each meta box.
156
-			foreach ( $meta_boxes as $meta_box ) {
157
-				$meta_box_registrar->register( $meta_box );
156
+			foreach ($meta_boxes as $meta_box) {
157
+				$meta_box_registrar->register($meta_box);
158 158
 			}
159 159
 		}
160 160
 	}
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 * @return void
168 168
 	 * @since 0.7.0
169 169
 	 */
170
-	public function process_shared_meta_box( Shared_Meta_Box_Controller $controller ): void {
171
-		$registrar = new Shared_Meta_Box_Registrar( $this->get_meta_box_registrar() );
172
-		$registrar->register( $controller );
170
+	public function process_shared_meta_box(Shared_Meta_Box_Controller $controller): void {
171
+		$registrar = new Shared_Meta_Box_Registrar($this->get_meta_box_registrar());
172
+		$registrar->register($controller);
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @since 0.7.0
180 180
 	 */
181 181
 	public function get_meta_box_registrar(): Meta_Box_Registrar {
182
-		return Registrar_Factory::new()->meta_box_registrar( $this->container, $this->loader );
182
+		return Registrar_Factory::new()->meta_box_registrar($this->container, $this->loader);
183 183
 	}
184 184
 
185 185
 	public function setup(): void {
Please login to merge, or discard this patch.
src/Registrar/Shared_Meta_Box_Registrar.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	protected $meta_box_registrar;
43 43
 
44
-	public function __construct( Meta_Box_Registrar $meta_box_registrar ) {
44
+	public function __construct(Meta_Box_Registrar $meta_box_registrar) {
45 45
 		$this->meta_box_registrar = $meta_box_registrar;
46 46
 	}
47 47
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
52 52
 	 * @return void
53 53
 	 */
54
-	public function register( Registerable $registerable ): void {
55
-		if ( ! is_a( $registerable, Shared_Meta_Box_Controller::class ) ) {
54
+	public function register(Registerable $registerable): void {
55
+		if ( ! is_a($registerable, Shared_Meta_Box_Controller::class)) {
56 56
 			return;
57 57
 		}
58 58
 
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 
61 61
 		// Get the meta box and meta data.
62 62
 		$meta_box  = $registerable->meta_box();
63
-		$meta_data = $registerable->meta_data( array() );
63
+		$meta_data = $registerable->meta_data(array());
64 64
 
65 65
 		// Register the meta box.
66
-		$this->meta_box_registrar->register( $meta_box );
66
+		$this->meta_box_registrar->register($meta_box);
67 67
 
68 68
 		// Register all meta data.
69
-		foreach ( $this->filter_meta_data( $meta_data ) as $meta_field ) {
69
+		foreach ($this->filter_meta_data($meta_data) as $meta_field) {
70 70
 			// Register meta data for each post type.
71
-			foreach ( $meta_box->screen as $post_type ) {
72
-				$this->register_meta_data_for_post_type( $meta_field, $post_type );
71
+			foreach ($meta_box->screen as $post_type) {
72
+				$this->register_meta_data_for_post_type($meta_field, $post_type);
73 73
 			}
74 74
 		}
75 75
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 * @param mixed[] $meta_data
82 82
 	 * @return Meta_Data[]
83 83
 	 */
84
-	protected function filter_meta_data( array $meta_data ): array {
84
+	protected function filter_meta_data(array $meta_data): array {
85 85
 		return array_filter(
86 86
 			$meta_data,
87
-			function( $e ) {
88
-				return is_a( $e, Meta_Data::class );
87
+			function($e) {
88
+				return is_a($e, Meta_Data::class);
89 89
 			}
90 90
 		);
91 91
 	}
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 * @param string $post_type
98 98
 	 * @return void
99 99
 	 */
100
-	protected function register_meta_data_for_post_type( Meta_Data $meta_data, string $post_type ): void {
100
+	protected function register_meta_data_for_post_type(Meta_Data $meta_data, string $post_type): void {
101 101
 		// Clone and set the post type, while enforcing it as a post meta.
102 102
 		$meta_data = clone $meta_data;
103
-		$meta_data->object_subtype( $post_type );
104
-		$meta_data->meta_type( 'post' );
105
-		$result = register_meta( $meta_data->get_meta_type(), $meta_data->get_meta_key(), $meta_data->parse_args() );
106
-		if ( ! $result ) {
107
-			throw new \Exception( "Failed to register {$meta_data->get_meta_key()} (meta) for {$post_type} post type" );
103
+		$meta_data->object_subtype($post_type);
104
+		$meta_data->meta_type('post');
105
+		$result = register_meta($meta_data->get_meta_type(), $meta_data->get_meta_key(), $meta_data->parse_args());
106
+		if ( ! $result) {
107
+			throw new \Exception("Failed to register {$meta_data->get_meta_key()} (meta) for {$post_type} post type");
108 108
 		}
109 109
 	}
110 110
 
Please login to merge, or discard this patch.
src/Registrar/Registrar_Factory.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
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() );
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());
61 61
 
62
-			case is_a( $registerable, Taxonomy::class ):
63
-				return new Taxonomy_Registrar( new Taxonomy_Validator() );
62
+			case is_a($registerable, Taxonomy::class):
63
+				return new Taxonomy_Registrar(new Taxonomy_Validator());
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.